From 8b33f3ff5a3bf7e2524818b6644f609448166e57 Mon Sep 17 00:00:00 2001 From: henriquenakashima Date: Sat, 19 Sep 2020 21:18:27 -0400 Subject: [PATCH] Show cards in PlayArea --- Assets/Battle/BattleController.cs | 8 +-- Assets/Battle/BattlePlayerControls.cs | 74 ++++++++++++++++++++-- Assets/Battle/Cards/CardCover.cs | 1 - Assets/Battle/Cards/CardCrashingPunch.cs | 1 - Assets/Battle/Cards/CardLightningStrike.cs | 1 - Assets/Battle/Cards/CardThunderstorm.cs | 1 - 6 files changed, 70 insertions(+), 16 deletions(-) diff --git a/Assets/Battle/BattleController.cs b/Assets/Battle/BattleController.cs index 405ce0e..4ba2e7d 100644 --- a/Assets/Battle/BattleController.cs +++ b/Assets/Battle/BattleController.cs @@ -74,12 +74,12 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe } this.heroDeck = new HeroDeck(this.cardIds, cardOwners); - this.battlePlayerControls.Init(this.heroDeck); + this.playArea = new PlayArea(); + + this.battlePlayerControls.Init(this.heroDeck, this.playArea); this.battlePlayerControls.OnCardUsed += this.NotifyCardUsed; this.battlePlayerControls.OnTurnPassed += this.NotifyTurnPassed; this.heroDeck.OnHandPileChanged += this.battlePlayerControls.NotifyHandPileChanged; - - this.playArea = new PlayArea(); } private BattleParticipant FindHeroByClass(HeroId heroId) { @@ -139,7 +139,6 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe } public void NotifyCardUsed(BaseCard card) { - Debug.Log("NotifyCardUsed " + card); if (!CanUseCard(card)) { throw new System.InvalidOperationException("Cannot use card " + card.GetDisplayName()); } @@ -159,7 +158,6 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe public void NotifyTurnPassed() { if (this.heroTurn) { - Debug.Log("NotifyTurnPassed"); StartEnemyTurn(); } } diff --git a/Assets/Battle/BattlePlayerControls.cs b/Assets/Battle/BattlePlayerControls.cs index d83ec80..386b1e2 100644 --- a/Assets/Battle/BattlePlayerControls.cs +++ b/Assets/Battle/BattlePlayerControls.cs @@ -16,15 +16,21 @@ public class BattlePlayerControls : MonoBehaviour private HeroDeck heroDeck; private List cardsInHandUIs; + private PlayArea playArea; + private Dictionary cardsInPlayUIs; - public void Init(HeroDeck heroDeck) { + 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 @@ -45,19 +51,23 @@ public class BattlePlayerControls : MonoBehaviour BaseCard card = hand[i]; GameObject cardUI = Instantiate(this.cardPrefab, this.uiCanvas.transform); this.cardsInHandUIs.Add(cardUI); - cardUI.transform.position = CalculateCardPosition(i, hand.Count); + cardUI.transform.position = CalculateHandCardPosition(i, hand.Count); cardUI.GetComponent().Init(card); int cardIndex = i; cardUI.GetComponent