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

리소스 추가, 랜덤 캐릭터 배정

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