Commit 10291605 authored by 황호기's avatar 황호기

화면보호기 ver0.5 완성

parent 9a239a2c
fileFormatVersion: 2
guid: d6ff39f0a7cb0024c80aa392b6cf5569
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: UIGrayScale
m_Shader: {fileID: 4800000, guid: 8f02e9f12d5ec1f4188cf7a4c2644e85, type: 3}
m_ShaderKeywords:
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _BumpMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailAlbedoMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailMask:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailNormalMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _EmissionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ParallaxMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- _BrightnessAmount: 1
- _BumpScale: 1
- _ColorMask: 15
- _Cutoff: 0.5
- _DetailNormalMapScale: 1
- _DstBlend: 0
- _EffectAmount: 1
- _GlossMapScale: 1
- _Glossiness: 0.5
- _GlossyReflections: 1
- _Metallic: 0
- _Mode: 0
- _OcclusionStrength: 1
- _Parallax: 0.02
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _Stencil: 0
- _StencilComp: 8
- _StencilOp: 0
- _StencilReadMask: 255
- _StencilWriteMask: 255
- _UVSec: 0
- _ZWrite: 1
m_Colors:
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
fileFormatVersion: 2
guid: e77c353a4c249fa47bfcf383beac2c17
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 2100000
userData:
assetBundleName:
assetBundleVariant:
......@@ -402,6 +402,7 @@ MonoBehaviour:
shieldBar: {fileID: 114146048921004652}
hpText: {fileID: 114673570930832878}
shieldText: {fileID: 114667973635924324}
grayScaleMat: {fileID: 2100000, guid: e77c353a4c249fa47bfcf383beac2c17, type: 2}
cardPrefab: {fileID: 11441498, guid: 512204d60f1753c42af11e4e33c8ef5e, type: 2}
--- !u!114 &114667973635924324
MonoBehaviour:
......
This diff is collapsed.
......@@ -41,7 +41,7 @@ public class ActionEditor : MonoBehaviour
public void AddBehavior()
{
behaviors.Add( new BehaviorDescriptor( ActionTypeSelect.value, TargetTypeSelect.value, int.Parse( TargetArg.text ), int.Parse( Arg1.text ) ) );
behaviors.Add( new BehaviorDescriptor( ActionTypeSelect.value, TargetTypeSelect.value, TargetArg.text, int.Parse( Arg1.text ) ) );
RefreshBehavior();
}
......
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
using TBR.Data;
using TBR.Game;
......@@ -21,6 +22,8 @@ public class GameLogic : MonoBehaviour {
private PartyUI partyUI2;
[SerializeField]
private Text turnText;
[SerializeField]
private GameoverUI gameoverUI;
private int turn;
private int firstTurnParty;
private int currentTurnParty;
......@@ -60,18 +63,22 @@ public class GameLogic : MonoBehaviour {
{
turnText.text = ( turn / 2 + 1 ).ToString();
currentTurnParty = ( firstTurnParty + turn ) % 2;
dataLogic.SetCurrentTurnParty( currentTurnParty );
dataLogic.SetTurn(turn, currentTurnParty );
yield return ShowNonLeaderCard();
if ( dataLogic.Parties[ currentTurnParty ].LeaderAlive )
yield return SetLeaderCard();
yield return UseSkill();
dataLogic.CalcAndAssignBonus();
yield return Action();
AssignDataAndResetCard();
if ( CheckGameOver() )
break;
AssignDataAndResetCard();
turn++;
}
gameoverUI.gameObject.SetActive( true );
gameoverUI.SetWinnerText( currentTurnParty ==0 ? "아랫쪽" : "위쪽" );
yield return new WaitForSeconds( 3f );
SceneManager.LoadScene("GameScene");
}
public IEnumerator ShowNonLeaderCard()
......@@ -109,14 +116,17 @@ public class GameLogic : MonoBehaviour {
public void AssignDataAndResetCard()
{
for ( int i = 0; i < 5; i++ )
for ( int p = 0; p < 2; p++ )
{
characters[ currentTurnParty, i ].AssignDataAndResetCard();
for ( int i = 0; i < 5; i++ )
{
characters[ p, i ].AssignDataAndResetCard();
}
}
}
private bool CheckGameOver()
{
return false;
return dataLogic.CheckGameOver();
}
}
......@@ -16,6 +16,8 @@ public class CharacterUI : MonoBehaviour
private Text hpText;
[SerializeField]
private Text shieldText;
[SerializeField]
private Material grayScaleMat;
private Character character;
[SerializeField]
private Card cardPrefab;
......@@ -25,6 +27,10 @@ public class CharacterUI : MonoBehaviour
{
this.character = character;
image.sprite = Resources.Load<Sprite>( "Characters/Icon/" + character.BaseData.ImageId );
if ( character.HP <= 0 )
image.material = grayScaleMat;
else
image.material = null;
hpBar.value = ( float )character.HP / character.MaxHP;
shieldBar.value = ( float )character.ShieldStack / character.MaxHP;
hpText.text = character.HP + "/" + character.MaxHP;
......@@ -33,7 +39,7 @@ public class CharacterUI : MonoBehaviour
public void SetCard()
{
if ( character.SelectedCard != null )
if ( character.IsLive && character.SelectedCard != null )
{
if ( curCard != null )
Destroy( curCard.gameObject );
......@@ -45,6 +51,7 @@ public class CharacterUI : MonoBehaviour
public void AssignDataAndResetCard()
{
SetCharacter( character );
if ( curCard != null )
Destroy( curCard.gameObject );
}
......
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class GameoverUI : MonoBehaviour {
[SerializeField]
private Text winnerText;
public void SetWinnerText(string wimmerName)
{
winnerText.text = wimmerName + " 승리!";
}
}
fileFormatVersion: 2
guid: ec9e04de1e3538d4594b52c50cafd118
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
......@@ -15,7 +15,7 @@ namespace TBR.Data
CardData[] cardData = new CardData[ 5 ];
for ( int i = 0; i < 5; i++ )
{
if ( characters[ i ] != null )
if ( characters[ i ] != null && characters[i].IsLive )
cardData[ i ] = characters[ i ].SelectedCard;
}
//PowerBonus
......@@ -75,10 +75,72 @@ namespace TBR.Data
for ( int i = 0; i < 5; i++ )
{
if ( characters[ i ] != null )
if ( characters[ i ] != null && characters[ i ].IsLive )
characters[ i ].SetBonus( powerBonus[ i ], countBonus[ i ] );
}
return "";
}
public static List<Character> GetTargetChatacters(Character[] characters, List<int> targets)
{
int[] indexes = new int[] { 0, 1, 2, 3, 4 };
for(int i=0;i<5;i++ )
{
if(characters[i]==null || characters[ i ].IsLive == false)
{
for(int j=0;j<5;j++ )
{
if ( indexes[ j ] >= i )
indexes[ j ] = indexes[ j ] + 1;
}
}
}
int replace = 0;
for ( int i = 0; i < 5; i++ )
{
if ( indexes[ i ] != 5 )
replace = indexes[ i ];
else
indexes[ i ] = replace;
}
var result = new List<Character>();
foreach(var t in targets )
{
if ( result.Contains( characters[ indexes[ t-1 ] ] ) == false )
result.Add( characters[ indexes[ t-1 ] ] );
}
return result;
}
public static int GetElementPower(ActionElement element, bool isShield)
{
if(isShield)
{
switch ( element )
{
case ActionElement.Gun:
return 11;
case ActionElement.Mana:
return 15;
default:
return 10;
}
}
else
{
switch ( element )
{
case ActionElement.Gun:
return 11;
case ActionElement.Sword:
return 13;
default:
return 10;
}
}
}
}
}
......@@ -39,11 +39,12 @@ namespace TBR.Data
//임시 코드(HSymbol)
public void Randomize()
{
HP = Random.Range( 10000, 20000 );
HP = Random.Range( 30000, 60000 );
Sword = Random.Range( 100, 200 );
Gun = Random.Range( 100, 200 );
Mana = Random.Range( 100, 200 );
Shield = Random.Range( 100, 200 );
Shield = Random.Range( 300, 600 );
Heal = Random.Range( 300, 600 );
CardCases = new CardCase[ 10 ];
for ( int i = 0; i < 10; i++ )
CardCases[ i ] = new CardCase();
......
......@@ -23,6 +23,7 @@ namespace TBR.Game
public string SelectedSkill { get; private set; }
private int powerBonus;
private int countBonus;
public bool IsLive { get { return HP > 0; } }
public Character( CharacterData data )
{
......@@ -57,7 +58,7 @@ namespace TBR.Game
public void Action()
{
var action = BaseData.ActionIds[ SelectedCard.Element ];
DataLogic.CurDataLogic.DoAction( this, GetElementPower( SelectedCard.Element ), action );
DataLogic.CurDataLogic.DoAction( this, action );
}
public int GetElementPower(ActionElement element)
......@@ -78,10 +79,40 @@ namespace TBR.Game
return 0;
}
public bool ReceiveDamage(int damage)
public int GetCurrentPower()
{
HP -= damage;
return HP < 0;
return GetElementPower( SelectedCard.Element ) * powerBonus / ( DataLogic.CurDataLogic.Turn % 39 == 0 ? 2 : 1 );
}
public int GetCurrentActionCount()
{
return SelectedCard.Number + countBonus;
}
public void ReceiveDamage(ActionElement element, int damage)
{
if(ShieldStack>0)
{
ShieldStack -= damage * Calculator.GetElementPower( element, true ) / 10;
if ( ShieldStack < 0 )
ShieldStack = 0;
}
else
{
HP -= damage * Calculator.GetElementPower( element, false ) / 10;
}
}
public void RecoverHP(int amount)
{
HP += amount;
if ( HP > MaxHP )
HP = MaxHP;
}
public void StackShield( int amount )
{
ShieldStack += amount;
}
public static Character MakeRandomCharacter()
......
......@@ -11,7 +11,9 @@ namespace TBR.Game
{
public static DataLogic CurDataLogic;
public Party[] Parties { get; private set; }
public int Turn { get; private set; }
private int currentTurnParty;
private int oppoTurnParty { get { return 1 - currentTurnParty; } }
public DataLogic()
{
......@@ -19,8 +21,9 @@ namespace TBR.Game
CurDataLogic = this;
}
public void SetCurrentTurnParty( int partyNum )
public void SetTurn(int turn, int partyNum )
{
Turn = turn;
currentTurnParty = partyNum;
}
......@@ -51,36 +54,79 @@ namespace TBR.Game
Parties[ currentTurnParty ].Action();
}
public void DoAction( Character actor, int elementPower, ActionDescriptor action )
public void DoAction( Character actor,ActionDescriptor action )
{
List<bool> changeTarget = new List<bool>();
List<bool[]> target = new List<bool[]>();
for ( int i = 0; i < action.BehaviorList.Count; i++ )
{
changeTarget.Add( false );
target.Add( new bool[ 5 ] );
}
for ( int i = 0; i < action.BehaviorList.Count; i++ )
{
var behaivor = action.BehaviorList[ i ];
switch ( behaivor.Type )
{
case ActionType.Attack:
Attack( actor, behaivor );
break;
case ActionType.Heal:
Heal( actor, behaivor );
break;
case ActionType.Shield:
StackShield( actor, behaivor );
break;
case ActionType.Buff:
break;
}
}
}
public void Attack( Character actor, BehaviorDescriptor behavior)
{
switch (behavior.Target)
{
case TargetType.Select:
foreach( var target in Calculator.GetTargetChatacters(Parties[oppoTurnParty].Characters,behavior.TargetList))
{
for(int i=0;i<actor.GetCurrentActionCount();i++ )
{
target.ReceiveDamage( actor.SelectedCard.Element, actor.GetCurrentPower() );
}
}
break;
}
}
public void Heal( Character actor, BehaviorDescriptor behavior )
{
switch ( behavior.Target )
{
case TargetType.Select:
foreach ( var target in Calculator.GetTargetChatacters( Parties[ currentTurnParty ].Characters, behavior.TargetList ) )
{
for ( int i = 0; i < actor.GetCurrentActionCount(); i++ )
{
target.RecoverHP( actor.GetCurrentPower() );
}
}
break;
}
}
public void StackShield( Character actor, BehaviorDescriptor behavior )
{
switch ( behavior.Target )
{
case TargetType.Select:
foreach ( var target in Calculator.GetTargetChatacters( Parties[ currentTurnParty ].Characters, behavior.TargetList ) )
{
for ( int i = 0; i < actor.GetCurrentActionCount(); i++ )
{
target.StackShield( actor.GetCurrentPower() );
}
}
break;
}
}
// return 은 공격에 의해서 적이 죽었는지를 나타낸다.
public bool Attack( Character actor, int elementPower, Character target, int arg)
public bool CheckGameOver()
{
if(target != null || target.HP<=0)
return false;
return target.ReceiveDamage( elementPower * arg / 100 );
return Parties[ 0 ].CheckGameOver() || Parties[ 1 ].CheckGameOver();
}
}
}
......@@ -27,7 +27,7 @@ namespace TBR.Game
{
for ( int i = 0; i < 5; i++ )
{
if ( i != LeaderIndex || !LeaderAlive )
if ( ( i != LeaderIndex || !LeaderAlive ) && IsCharacterExist( i ) )
Characters[ i ].SetCard();
}
}
......@@ -36,7 +36,7 @@ namespace TBR.Game
{
for ( int i = 0; i < 5; i++ )
{
if ( Characters[ i ] != null && string.IsNullOrEmpty( Characters[ i ].SelectedSkill ) == false )
if ( IsCharacterExist( i ) && string.IsNullOrEmpty( Characters[ i ].SelectedSkill ) == false )
Characters[ i ].UseSkill();
}
}
......@@ -45,11 +45,21 @@ namespace TBR.Game
{
for ( int i = 0; i < 5; i++ )
{
if ( Characters[ i ] != null )
if ( IsCharacterExist(i) )
Characters[ i ].Action();
}
}
public bool IsCharacterExist(int index)
{
return Characters[ index ] != null && Characters[ index ].IsLive;
}
public bool CheckGameOver()
{
return !IsCharacterExist( 0 ) && !IsCharacterExist( 1 ) && !IsCharacterExist( 2 ) && !IsCharacterExist( 3 ) && !IsCharacterExist( 4 );
}
public string CalcAndAssignBonus()
{
return Calculator.CalcAndAssignBonus( Characters );
......
......@@ -46,6 +46,14 @@ namespace TBR.TableData
BehaviorList = new List<BehaviorDescriptor>( behaviors );
Desc = desc;
}
public void OnDeserialized()
{
foreach(var b in BehaviorList)
{
b.MakeTargetList();
}
}
}
public class BehaviorDescriptor
......@@ -57,7 +65,10 @@ namespace TBR.TableData
public TargetType Target { get; private set; }
[JsonProperty]
public int TargetArg { get; private set; }
public string TargetArg { get; private set; }
[JsonIgnore]
public List<int> TargetList;
[JsonProperty]
public int Arg1 { get; private set; }
......@@ -67,13 +78,21 @@ namespace TBR.TableData
}
public BehaviorDescriptor(int type, int target, int targetArg, int arg1)
public void MakeTargetList()
{
TargetList = new List<int>();
foreach(var t in TargetArg.Split(','))
{
TargetList.Add( int.Parse( t ) );
}
}
public BehaviorDescriptor(int type, int target, string targetArg, int arg1)
{
Type = ( ActionType)type;
Target = ( TargetType )target;
TargetArg = targetArg;
Arg1 = arg1;
}
}
}
......@@ -28,6 +28,7 @@ namespace TBR.TableData
var actions = JsonConvert.DeserializeObject<List< ActionDescriptor >>(Resources.Load<TextAsset>( "Table/ActionTable" ).text);
foreach(var a in actions)
{
a.OnDeserialized();
ActionTable.Add( a.Id, a );
}
}
......
fileFormatVersion: 2
guid: 9f112ef4aed500b43b34ee70a8af9a7a
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
Shader "Custom/UI/Grayscale"
{
Properties
{
[PerRendererData] _MainTex ("Sprite Texture", 2D) = "white" {}
_Color ("Tint", Color) = (1,1,1,1)
_StencilComp ("Stencil Comparison", Float) = 8
_Stencil ("Stencil ID", Float) = 0
_StencilOp ("Stencil Operation", Float) = 0
_StencilWriteMask ("Stencil Write Mask", Float) = 255
_StencilReadMask ("Stencil Read Mask", Float) = 255
_EffectAmount ("Effect Amount", Range (0, 1)) = 1.0
_BrightnessAmount ("Brightness Amount", Range(0.0, 3)) = 1.0
_ColorMask ("Color Mask", Float) = 15
}
SubShader
{
Tags
{
"Queue"="Transparent"
"IgnoreProjector"="True"
"RenderType"="Transparent"
"PreviewType"="Plane"
"CanUseSpriteAtlas"="True"
}
Stencil
{
Ref [_Stencil]
Comp [_StencilComp]
Pass [_StencilOp]
ReadMask [_StencilReadMask]
WriteMask [_StencilWriteMask]
}
Cull Off
Lighting Off
ZWrite Off
ZTest [unity_GUIZTestMode]
Blend SrcAlpha OneMinusSrcAlpha
ColorMask [_ColorMask]
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
#include "UnityUI.cginc"
struct appdata_t
{
float4 vertex : POSITION;
float4 color : COLOR;
float2 texcoord : TEXCOORD0;
};
struct v2f
{
float4 vertex : SV_POSITION;
fixed4 color : COLOR;
half2 texcoord : TEXCOORD0;
float4 worldPosition : TEXCOORD1;
};
fixed4 _Color;
fixed4 _TextureSampleAdd;
bool _UseClipRect;
float4 _ClipRect;
bool _UseAlphaClip;
uniform float _EffectAmount;
uniform float _BrightnessAmount;
v2f vert(appdata_t IN)
{
v2f OUT;
OUT.worldPosition = IN.vertex;
OUT.vertex = UnityObjectToClipPos(OUT.worldPosition);