using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class BattlePlayerControls : MonoBehaviour { public BattleController battleController; public GameObject uiCanvas; public GameObject cardPrefab; public delegate void CardUsedAction(BaseCard card); public event CardUsedAction OnCardUsed; public delegate void TurnPassedAction(); public event TurnPassedAction OnTurnPassed; private HeroDeck heroDeck; private List cardsInHandUIs; private PlayArea playArea; private Dictionary cardsInPlayUIs; public void Init(HeroDeck heroDeck, PlayArea playArea) { this.heroDeck = heroDeck; this.playArea = playArea; this.cardsInPlayUIs = new Dictionary(); } // Start is called before the first frame update void Start() { NotifyPlayAreaChanged(); this.playArea.OnPlayAreaChanged += NotifyPlayAreaChanged; } // Update is called once per frame void Update() { } private void SetHand(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++) { BaseCard 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