...
 
Commits (3)
This diff is collapsed.
This diff is collapsed.
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using UnityEngine; using UnityEngine;
using UnityEngine.UI;
using TBR.Data; using TBR.Data;
using TBR.Game; using TBR.Game;
...@@ -9,12 +10,17 @@ public class GameLogic : MonoBehaviour { ...@@ -9,12 +10,17 @@ public class GameLogic : MonoBehaviour {
public static GameLogic CurGameLogic; public static GameLogic CurGameLogic;
[SerializeField] [SerializeField]
private CharacterObj[] p1Characters;
[SerializeField]
private CharacterObj[] p2Characters;
private CharacterObj[,] characters; private CharacterObj[,] characters;
private DataLogic dataLogic; private DataLogic dataLogic;
[SerializeField] [SerializeField]
private PartyUI partyUI1; private PartyUI partyUI1;
[SerializeField] [SerializeField]
private PartyUI partyUI2; private PartyUI partyUI2;
[SerializeField]
private Text turnText;
private int turn; private int turn;
private int firstTurnParty; private int firstTurnParty;
...@@ -22,6 +28,11 @@ public class GameLogic : MonoBehaviour { ...@@ -22,6 +28,11 @@ public class GameLogic : MonoBehaviour {
void Start () { void Start () {
CurGameLogic = this; CurGameLogic = this;
dataLogic = new DataLogic(); dataLogic = new DataLogic();
characters = new CharacterObj[2,5];
for ( int i = 0; i < 5; i++ )
characters[ 0, i ] = p1Characters[ i ];
for ( int i = 0; i < 5; i++ )
characters[ 1, i ] = p2Characters[ i ];
StartCoroutine( MainLogic() ); StartCoroutine( MainLogic() );
} }
...@@ -42,6 +53,7 @@ public class GameLogic : MonoBehaviour { ...@@ -42,6 +53,7 @@ public class GameLogic : MonoBehaviour {
} }
yield return null; yield return null;
turn = 0; turn = 0;
turnText.text = turn.ToString();
while (turn < 40) while (turn < 40)
{ {
int currentTurnParty = ( firstTurnParty + turn ) % 2; int currentTurnParty = ( firstTurnParty + turn ) % 2;
...@@ -54,6 +66,7 @@ public class GameLogic : MonoBehaviour { ...@@ -54,6 +66,7 @@ public class GameLogic : MonoBehaviour {
if ( CheckGameOver() ) if ( CheckGameOver() )
break; break;
turn++; turn++;
turnText.text = turn.ToString();
} }
} }
......
...@@ -7,11 +7,14 @@ using TBR.Game; ...@@ -7,11 +7,14 @@ using TBR.Game;
public class CharacterObj : MonoBehaviour public class CharacterObj : MonoBehaviour
{ {
[SerializeField]
private SpriteRenderer characterImage;
private Character character; private Character character;
public void SetCharacter(Character character) public void SetCharacter(Character character)
{ {
this.character = character; this.character = character;
characterImage.sprite = Resources.Load<Sprite>( "Characters/Game/" + character.BaseData.ImageId );
} }
public IEnumerator SelectCard() public IEnumerator SelectCard()
......
...@@ -12,18 +12,23 @@ namespace TBR.Data ...@@ -12,18 +12,23 @@ namespace TBR.Data
public static bool operator ==( CardData a, CardData b ) public static bool operator ==( CardData a, CardData b )
{ {
return a.Element == b.Element && a.Number == b.Number; if ( object.ReferenceEquals( a, null ) )
{
return object.ReferenceEquals( b, null );
}
return a.Equals( b );
} }
public static bool operator !=( CardData a, CardData b ) public static bool operator !=( CardData a, CardData b )
{ {
return a.Element != b.Element || a.Number != b.Number; return !( a == b );
} }
public override bool Equals( object obj ) public override bool Equals( object obj )
{ {
if ( !( obj is CardData ) ) if ( !( obj is CardData ) )
return false; return false;
else return (CardData)obj == this; var other = ( CardData )obj;
return other.Element == Element && other.Number == Number;
} }
public override int GetHashCode() public override int GetHashCode()
......
...@@ -8,6 +8,9 @@ namespace TBR.Data ...@@ -8,6 +8,9 @@ namespace TBR.Data
{ {
public class CharacterData public class CharacterData
{ {
//임시 코드
private static List<string> imageStringPool = new List<string>() { "gunner", "impotent", "japan", "knight", "magic_knight", "magician", "miku", "pig", "priest", "today", "trump", "warrior", "zombie" };
public string LeaderSkillId { get; private set; } public string LeaderSkillId { get; private set; }
public int Grade { get; private set; } public int Grade { get; private set; }
public int Level { get; private set; } public int Level { get; private set; }
...@@ -17,6 +20,7 @@ namespace TBR.Data ...@@ -17,6 +20,7 @@ namespace TBR.Data
public int Mana { get; private set; } public int Mana { get; private set; }
public int Shield { get; private set; } public int Shield { get; private set; }
public int Heal { get; private set; } public int Heal { get; private set; }
public string ImageId { get; private set; }
public Dictionary<ActionElement, ActionDescriptor> ActionIds { get; private set; } public Dictionary<ActionElement, ActionDescriptor> ActionIds { get; private set; }
public List<ActionData> actionPool; public List<ActionData> actionPool;
public List<CardData> CardPool; public List<CardData> CardPool;
...@@ -41,6 +45,8 @@ namespace TBR.Data ...@@ -41,6 +45,8 @@ namespace TBR.Data
Mana = Random.Range( 100, 200 ); Mana = Random.Range( 100, 200 );
Shield = Random.Range( 100, 200 ); Shield = Random.Range( 100, 200 );
CardCases = new CardCase[ 10 ]; CardCases = new CardCase[ 10 ];
for ( int i = 0; i < 10; i++ )
CardCases[ i ] = new CardCase();
List<CardData> selectedCards = new List<CardData>(); List<CardData> selectedCards = new List<CardData>();
foreach(var c in CardCases) foreach(var c in CardCases)
{ {
...@@ -53,6 +59,7 @@ namespace TBR.Data ...@@ -53,6 +59,7 @@ namespace TBR.Data
selectedCards.Add( card ); selectedCards.Add( card );
c.SetCard( card ); c.SetCard( card );
} }
ImageId = imageStringPool[ Random.Range( 0, imageStringPool.Count ) ];
} }
} }
......
...@@ -9,7 +9,7 @@ namespace TBR.Game ...@@ -9,7 +9,7 @@ namespace TBR.Game
{ {
public class Character public class Character
{ {
private CharacterData baseData; public CharacterData BaseData { get; private set; }
public int HP { get; private set; } public int HP { get; private set; }
public int MaxHP { get; private set; } public int MaxHP { get; private set; }
public int ShieldStack { get; private set; } public int ShieldStack { get; private set; }
...@@ -26,7 +26,7 @@ namespace TBR.Game ...@@ -26,7 +26,7 @@ namespace TBR.Game
public Character( CharacterData data ) public Character( CharacterData data )
{ {
baseData = data; BaseData = data;
HP = data.HP; HP = data.HP;
MaxHP = HP * 2; MaxHP = HP * 2;
buffs = new List<Buff>(); buffs = new List<Buff>();
...@@ -40,8 +40,8 @@ namespace TBR.Game ...@@ -40,8 +40,8 @@ namespace TBR.Game
public void SetCard() public void SetCard()
{ {
var selectedIndex = Random.Range( 0, 10 ); var selectedIndex = Random.Range( 0, 10 );
SelectedCard = baseData.CardCases[ selectedIndex ].Card; SelectedCard = BaseData.CardCases[ selectedIndex ].Card;
SelectedSkill = baseData.CardCases[ selectedIndex ].SkillId; SelectedSkill = BaseData.CardCases[ selectedIndex ].SkillId;
} }
public void SetBonus( int powerBonus, int countBonus ) public void SetBonus( int powerBonus, int countBonus )
...@@ -56,7 +56,7 @@ namespace TBR.Game ...@@ -56,7 +56,7 @@ namespace TBR.Game
public void Action() public void Action()
{ {
var actionId = baseData.ActionIds[ SelectedCard.Element ]; var actionId = BaseData.ActionIds[ SelectedCard.Element ];
} }
public static Character MakeRandomCharacter() public static Character MakeRandomCharacter()
......
using System; using UnityEngine;
using System.Collections; using System.Collections;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
...@@ -63,8 +63,13 @@ namespace TBR.Game ...@@ -63,8 +63,13 @@ namespace TBR.Game
party.Characters[ 2 ] = Character.MakeRandomCharacter(); party.Characters[ 2 ] = Character.MakeRandomCharacter();
party.Characters[ 3 ] = Character.MakeRandomCharacter(); party.Characters[ 3 ] = Character.MakeRandomCharacter();
party.Characters[ 4 ] = Character.MakeRandomCharacter(); party.Characters[ 4 ] = Character.MakeRandomCharacter();
party.SetRamdomLeader();
return party; return party;
} }
public void SetRamdomLeader()
{
LeaderIndex = Random.Range( 0, 5 );
}
} }
} }
m_EditorVersion: 2018.2.13f1 m_EditorVersion: 2018.2.12f1