Commit 5469b000 authored by 황호기's avatar 황호기

코드 정리, 액션 구현 준비

parent 7467222b
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1001 &100100000
Prefab:
m_ObjectHideFlags: 1
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications: []
m_RemovedComponents: []
m_SourcePrefab: {fileID: 0}
m_RootGameObject: {fileID: 1065852149083122}
m_IsPrefabAsset: 1
--- !u!1 &1065852149083122
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 6
m_Component:
- component: {fileID: 4720357335499590}
- component: {fileID: 212551309035066960}
- component: {fileID: 114001815718304154}
m_Layer: 0
m_Name: Action
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &4720357335499590
Transform:
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1065852149083122}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 0}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &114001815718304154
MonoBehaviour:
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1065852149083122}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 12ac29b0eca0308479ffd41c9c221ff0, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!212 &212551309035066960
SpriteRenderer:
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1065852149083122}
m_Enabled: 1
m_CastShadows: 0
m_ReceiveShadows: 0
m_DynamicOccludee: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RenderingLayerMask: 4294967295
m_Materials:
- {fileID: 10754, guid: 0000000000000000f000000000000000, type: 0}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 0
m_SelectedEditorRenderState: 0
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 1946958967
m_SortingLayer: 2
m_SortingOrder: 1
m_Sprite: {fileID: 21300000, guid: 5dbd10cd445f3ac4a8f907704069156b, type: 3}
m_Color: {r: 0, g: 1, b: 0.21687698, a: 1}
m_FlipX: 0
m_FlipY: 0
m_DrawMode: 0
m_Size: {x: 0.44, y: 0.43}
m_AdaptiveModeThreshold: 0.5
m_SpriteTileMode: 0
m_WasSpriteAssigned: 1
m_MaskInteraction: 0
m_SpriteSortPoint: 0
fileFormatVersion: 2
guid: fdc6b840fb7e5244f9ec7696a7226373
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 100100000
userData:
assetBundleName:
assetBundleVariant:
......@@ -101,7 +101,8 @@ public class GameLogic : MonoBehaviour {
dataLogic.UseSkill();
for ( int i = 0; i < 5; i++ )
{
yield return characters[ currentTurnParty, i ].UseSkill();
if( dataLogic.Parties[currentTurnParty].IsCharacterExist(i) && dataLogic.Parties[ currentTurnParty ].Characters[i].SelectedSkill != null)
yield return characters[ currentTurnParty, i ].UseSkill();
}
}
......@@ -110,7 +111,8 @@ public class GameLogic : MonoBehaviour {
dataLogic.Action();
for ( int i = 0; i < 5; i++ )
{
yield return characters[ currentTurnParty, i ].Action();
if ( dataLogic.Parties[ currentTurnParty ].IsCharacterExist( i ) )
yield return characters[ currentTurnParty, i ].Action();
}
}
......
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TBR.Data;
using TBR.TableData;
public class ActionObj : MonoBehaviour
{
private CharacterObj target;
private ActionElement element;
private ActionType type;
private int power;
private Vector3 targetPoint;
private Vector3 curMove;
private int nowtime;
private bool isForShield;
[SerializeField]
private Sprite[] eSprites = new Sprite[ 5 ];
private SpriteRenderer spriteRanderer;
// Use this for initialization
void Start()
{
nowtime = 0;
curMove = new Vector3( Random.Range( -0.06f, 0.06f ), Random.Range( -0.06f, 0.06f ), 0 );
}
public void AssignData( CharacterObj target, ActionElement element, ActionType type, int power, bool isForShield )
{
this.target = target;
this.element = element;
this.type = type;
this.power = power;
targetPoint = target.transform.position;
this.isForShield = isForShield;
float size = Mathf.Log( power ) / 4;
transform.localScale = new Vector3( size, size, 1 );
AssignSprite( element );
}
// Update is called once per frame
void FixedUpdate()
{
nowtime++;
transform.Translate( curMove );
if ( nowtime == 25 )
{
curMove = new Vector3( ( targetPoint.x - transform.position.x ) / 25f, ( targetPoint.y - transform.position.y ) / 25f, 0 );
}
if ( nowtime == 50 )
{
target.AssignAction( element, type, power, isForShield );
Destroy( gameObject );
}
}
void AssignSprite( ActionElement element )
{
spriteRanderer.sprite = eSprites[ ( int )element ];
if ( element == ActionElement.Sword )
spriteRanderer.color = Color.grey;
if ( element == ActionElement.Gun )
spriteRanderer.color = Color.green;
if ( element == ActionElement.Mana )
spriteRanderer.color = Color.blue;
if ( element == ActionElement.Shield )
spriteRanderer.color = Color.black;
if ( element == ActionElement.Heal )
spriteRanderer.color = Color.red;
}
}
fileFormatVersion: 2
guid: 12ac29b0eca0308479ffd41c9c221ff0
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
......@@ -4,6 +4,8 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using TBR.Game;
using TBR.Data;
using TBR.TableData;
public class CharacterObj : MonoBehaviour
{
......@@ -28,6 +30,7 @@ public class CharacterObj : MonoBehaviour
public void AssignDataAndResetCard()
{
characterUI.AssignDataAndResetCard();
characterImage.enabled = character.IsLive;
}
public IEnumerator SelectCard()
......@@ -37,11 +40,92 @@ public class CharacterObj : MonoBehaviour
public IEnumerator UseSkill()
{
yield return null;
yield return DoAction( character.SelectedSkill );
}
public IEnumerator Action()
{
yield return null;
var action = character.BaseData.ActionIds[ character.SelectedCard.Element ];
yield return DoAction( action );
}
private IEnumerator DoAction(ActionDescriptor action)
{
for ( int i = 0; i < action.BehaviorList.Count; i++ )
{
var behaivor = action.BehaviorList[ i ];
switch ( behaivor.Type )
{
case ActionType.Attack:
yield return Attack( behaivor, character.CurTarget[ i ] );
break;
case ActionType.Heal:
HealAction( behaivor, character.CurTarget[ i ] );
break;
case ActionType.Shield:
StackShield( behaivor, character.CurTarget[ i ] );
break;
case ActionType.Buff:
break;
}
}
}
private IEnumerator Attack( BehaviorDescriptor behavior, List<Character> targets )
{
foreach ( var target in targets )
{
for ( int i = 0; i < character.GetCurrentActionCount(); i++ )
{
yield return null;
}
}
}
private IEnumerator HealAction( BehaviorDescriptor behavior, List<Character> targets )
{
foreach ( var target in targets )
{
for ( int i = 0; i < character.GetCurrentActionCount(); i++ )
{
yield return null;
}
}
}
private IEnumerator StackShield( BehaviorDescriptor behavior, List<Character> targets )
{
foreach ( var target in targets )
{
for ( int i = 0; i < character.GetCurrentActionCount(); i++ )
{
yield return null;
}
}
}
public void AssignAction(ActionElement element, ActionType type, int power, bool isForShield)
{
switch (type)
{
case ActionType.Attack:
int damage;
if ( isForShield )
{
damage = power * Calculator.GetElementPower( element, true ) / 10;
}
else
{
damage = power * Calculator.GetElementPower( element, false ) / 10;
}
characterUI.ReceiveDamage( damage, isForShield );
break;
case ActionType.Heal:
characterUI.Heal( power );
break;
case ActionType.Shield:
characterUI.StackShield( power );
break;
}
}
}
......@@ -23,6 +23,9 @@ public class CharacterUI : MonoBehaviour
private Card cardPrefab;
private Card curCard;
private int curHP;
private int curShield;
public void SetCharacter( Character character )
{
this.character = character;
......@@ -31,10 +34,12 @@ public class CharacterUI : MonoBehaviour
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;
shieldText.text = character.ShieldStack.ToString();
curHP = character.HP;
curShield = character.ShieldStack;
hpBar.value = ( float )curHP / character.MaxHP;
shieldBar.value = ( float )curShield / character.MaxHP;
hpText.text = curHP + "/" + character.MaxHP;
shieldText.text = curShield.ToString();
}
public void SetCard()
......@@ -48,6 +53,39 @@ public class CharacterUI : MonoBehaviour
}
}
public void ReceiveDamage(int amount, bool toShield)
{
if ( toShield )
{
curShield -= amount;
if ( curShield < 0 )
curShield = 0;
shieldBar.value = ( float )curShield / character.MaxHP;
shieldText.text = curShield.ToString();
}
else
{
curHP -= amount;
hpBar.value = ( float )curHP / character.MaxHP;
hpText.text = curHP + "/" + character.MaxHP;
}
}
public void Heal( int amount )
{
curHP += amount;
if ( curHP > character.MaxHP )
curHP = character.MaxHP;
hpBar.value = ( float )curHP / character.MaxHP;
hpText.text = curHP + "/" + character.MaxHP;
}
public void StackShield( int amount )
{
curShield += amount;
shieldBar.value = ( float )curShield / character.MaxHP;
shieldText.text = curShield.ToString();
}
public void AssignDataAndResetCard()
{
......
......@@ -67,7 +67,7 @@ namespace TBR.Data
public class CardCase
{
public CardData Card { get; private set; }
public string SkillId { get; private set; }
public ActionDescriptor SkillDesc { get; private set; }
public bool[] ActionCondition { get; private set; }
public bool[] NumberCondition { get; private set; }
......
......@@ -4,6 +4,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using TBR.Data;
using TBR.TableData;
namespace TBR.Game
{
......@@ -20,10 +21,11 @@ namespace TBR.Game
public int Shield { get; private set; }
public int Heal { get; private set; }
public CardData SelectedCard { get; private set; }
public string SelectedSkill { get; private set; }
public ActionDescriptor SelectedSkill { get; private set; }
private int powerBonus;
private int countBonus;
public bool IsLive { get { return HP > 0; } }
public List<List<Character>> CurTarget { get; private set; }
public Character( CharacterData data )
{
......@@ -42,7 +44,7 @@ namespace TBR.Game
{
var selectedIndex = Random.Range( 0, 10 );
SelectedCard = BaseData.CardCases[ selectedIndex ].Card;
SelectedSkill = BaseData.CardCases[ selectedIndex ].SkillId;
SelectedSkill = BaseData.CardCases[ selectedIndex ].SkillDesc;
}
public void SetBonus( int powerBonus, int countBonus )
......@@ -53,12 +55,69 @@ namespace TBR.Game
public void UseSkill()
{
DoAction( SelectedSkill );
}
public void Action()
{
var action = BaseData.ActionIds[ SelectedCard.Element ];
DataLogic.CurDataLogic.DoAction( this, action );
DoAction( action );
}
private void DoAction(ActionDescriptor action)
{
CurTarget = DataLogic.CurDataLogic.GetTarget( this, action );
for ( int i = 0; i < action.BehaviorList.Count; i++ )
{
var behaivor = action.BehaviorList[ i ];
switch ( behaivor.Type )
{
case ActionType.Attack:
Attack( behaivor, CurTarget[i] );
break;
case ActionType.Heal:
HealAction( behaivor, CurTarget[ i ] );
break;
case ActionType.Shield:
StackShield(behaivor, CurTarget[ i ] );
break;
case ActionType.Buff:
break;
}
}
}
private void Attack(BehaviorDescriptor behavior, List<Character> targets )
{
foreach ( var target in targets )
{
for ( int i = 0; i < GetCurrentActionCount(); i++ )
{
target.ReceiveDamage( SelectedCard.Element, GetCurrentPower() );
}
}
}
private void HealAction( BehaviorDescriptor behavior, List<Character> targets )
{
foreach ( var target in targets )
{
for ( int i = 0; i < GetCurrentActionCount(); i++ )
{
target.RecoverHP( GetCurrentPower() );
}
}
}
private void StackShield( BehaviorDescriptor behavior, List<Character> targets )
{
foreach ( var target in targets )
{
for ( int i = 0; i < GetCurrentActionCount(); i++ )
{
target.StackShield( GetCurrentPower() );
}
}
}
public int GetElementPower(ActionElement element)
......
......@@ -54,74 +54,35 @@ namespace TBR.Game
Parties[ currentTurnParty ].Action();
}
public void DoAction( Character actor,ActionDescriptor action )
public List<List<Character>> GetTarget( Character actor, ActionDescriptor action )
{
var result = new List<List<Character>>();
for ( int i = 0; i < action.BehaviorList.Count; i++ )
{
var behaivor = action.BehaviorList[ i ];
switch ( behaivor.Type )
var behavior = action.BehaviorList[ i ];
switch ( behavior.Type )
{
case ActionType.Attack:
Attack( actor, behaivor );
switch ( behavior.Target )
{
case TargetType.Select:
result.Add( Calculator.GetTargetChatacters( Parties[ oppoTurnParty ].Characters, behavior.TargetList ) );
break;
}
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++ )
switch ( behavior.Target )
{
target.RecoverHP( actor.GetCurrentPower() );
case TargetType.Select:
result.Add( Calculator.GetTargetChatacters( Parties[ currentTurnParty ].Characters, behavior.TargetList ) );
break;
}
}
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;
break;
}
}
return result;
}
public bool CheckGameOver()
......
......@@ -36,7 +36,7 @@ namespace TBR.Game
{
for ( int i = 0; i < 5; i++ )
{
if ( IsCharacterExist( i ) && string.IsNullOrEmpty( Characters[ i ].SelectedSkill ) == false )
if ( IsCharacterExist( i ) && Characters[ i ].SelectedSkill != null )
Characters[ i ].UseSkill();
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment