diff --git a/Assets/Battle/BattleCardPrefabConstants.cs b/Assets/Battle/BattleCardPrefabConstants.cs new file mode 100644 index 0000000..010f769 --- /dev/null +++ b/Assets/Battle/BattleCardPrefabConstants.cs @@ -0,0 +1,11 @@ +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using UnityEngine; +using UnityEngine.UI; + +public class BattleCardPrefabConstants +{ + public const int CARD_WIDTH = 122; + public const int CARD_HEIGHT = 155; +} diff --git a/Assets/Battle/BattleCardPrefabConstants.cs.meta b/Assets/Battle/BattleCardPrefabConstants.cs.meta new file mode 100644 index 0000000..9c8f705 --- /dev/null +++ b/Assets/Battle/BattleCardPrefabConstants.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 27a83f780e888aa4e936b6400b5b4eab +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Battle/BattlePlayerControls.cs b/Assets/Battle/BattlePlayerControls.cs index 738ee96..d53f310 100644 --- a/Assets/Battle/BattlePlayerControls.cs +++ b/Assets/Battle/BattlePlayerControls.cs @@ -19,8 +19,9 @@ public class BattlePlayerControls : MonoBehaviour private BattleDeck heroDeck; private BattleDeck monsterDeck; - private List cardsInHandUIs; private PlayArea playArea; + + private HeroHandControls heroHandControls; private Dictionary cardsInPlayUIs; public void Init( @@ -29,6 +30,8 @@ public class BattlePlayerControls : MonoBehaviour this.monsterDeck = monsterDeck; this.playArea = playArea; + this.heroHandControls = new HeroHandControls(this, this.uiCanvas, this.cardPrefab); + this.heroHandControls.OnCardClicked += OnCardClicked; this.cardsInPlayUIs = new Dictionary(); } @@ -45,41 +48,10 @@ public class BattlePlayerControls : MonoBehaviour } - private void SetHeroHand(List hand) { - if (this.cardsInHandUIs != null) { - foreach (GameObject cardInHandUI in this.cardsInHandUIs) { - Destroy(cardInHandUI); - } - } - - this.cardsInHandUIs = new List(); - for (int i = 0; i < hand.Count; i++) { - HeroCard card = hand[i]; - GameObject cardUI = Instantiate(this.cardPrefab, this.uiCanvas.transform); - this.cardsInHandUIs.Add(cardUI); - cardUI.transform.position = CalculateHandCardPosition(i, hand.Count); - cardUI.GetComponent().Init(card); - int cardIndex = i; - cardUI.GetComponent