From b6544199661e6fedac712cf7e6d8309812f0c125 Mon Sep 17 00:00:00 2001 From: henriquenakashima Date: Wed, 30 Sep 2020 19:33:53 -0400 Subject: [PATCH] Show playable cards in enemy hand --- Assets/Battle/BattleController.cs | 9 +++++++-- Assets/Battle/BattlePlayerControls.cs | 5 +++-- Assets/Battle/CheatBattle.cs | 3 +++ Assets/Battle/HandControls.cs | 2 +- Assets/Battle/UI/CardUI.cs | 10 ++++++++-- 5 files changed, 22 insertions(+), 7 deletions(-) diff --git a/Assets/Battle/BattleController.cs b/Assets/Battle/BattleController.cs index 7b03a75..74ed3e8 100644 --- a/Assets/Battle/BattleController.cs +++ b/Assets/Battle/BattleController.cs @@ -136,7 +136,8 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe this.battlePlayerControls.Init( this.heroDeck, this.monsterDeck, this.playArea, this.insightLevel, - this.heroHandPlayability, this.uiCanvas.transform.localScale.x); + this.heroHandPlayability, this.monsterHandPlayability, + this.uiCanvas.transform.localScale.x); this.insightLevel.OnChanged += this.battlePlayerControls.NotifyInsightLevelChanged; } @@ -155,9 +156,13 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe { StartCoroutine(RunBattleRounds()); - new GameObject("CheatBattle").AddComponent().OnWinCode += delegate { + CheatBattle cheat = new GameObject("CheatBattle").AddComponent(); + cheat.OnWinCode += delegate { BattleResult.FinishBattle(new BattleResult(true)); }; + cheat.OnInsightCode += delegate { + this.insightLevel.Modify(+5); + }; } // Update is called once per frame diff --git a/Assets/Battle/BattlePlayerControls.cs b/Assets/Battle/BattlePlayerControls.cs index 9d8d35e..60b1909 100644 --- a/Assets/Battle/BattlePlayerControls.cs +++ b/Assets/Battle/BattlePlayerControls.cs @@ -25,7 +25,8 @@ public class BattlePlayerControls : MonoBehaviour public void Init( BattleDeck heroDeck, BattleDeck monsterDeck, PlayArea playArea, - InsightLevel insightLevel, HandPlayability heroHandPlayability, float scale) { + InsightLevel insightLevel, HandPlayability heroHandPlayability, + HandPlayability monsterHandPlayability, float scale) { this.heroDeck = heroDeck; this.monsterDeck = monsterDeck; this.playArea = playArea; @@ -38,7 +39,7 @@ public class BattlePlayerControls : MonoBehaviour this.heroHandControls.OnCardClicked += OnHeroCardClicked; this.monsterHandControls = new HandControls( monsterDeck, this.uiCanvas, this.cardPrefab, HandControlsPosition.Top, - TeamChoice.Monsters, 1, null, this.scale); + TeamChoice.Monsters, 1, monsterHandPlayability, this.scale); this.monsterHandControls.OnCardClicked += OnMonsterCardClicked; this.cardsInPlayUIs = new Dictionary(); diff --git a/Assets/Battle/CheatBattle.cs b/Assets/Battle/CheatBattle.cs index eff8cbc..557c925 100644 --- a/Assets/Battle/CheatBattle.cs +++ b/Assets/Battle/CheatBattle.cs @@ -77,6 +77,7 @@ public class CheatBattle: MonoBehaviour public delegate void CheatAction(); public event CheatAction OnWinCode; + public event CheatAction OnInsightCode; private string lastCommands = ""; @@ -89,6 +90,8 @@ public class CheatBattle: MonoBehaviour if (this.lastCommands.EndsWith("win")) { this.OnWinCode(); + } else if (this.lastCommands.EndsWith("insight")) { + this.OnInsightCode(); } } } diff --git a/Assets/Battle/HandControls.cs b/Assets/Battle/HandControls.cs index d6cd921..eb1abcb 100644 --- a/Assets/Battle/HandControls.cs +++ b/Assets/Battle/HandControls.cs @@ -61,7 +61,7 @@ public class HandControls where BaseCardT : BaseCard get => this.insightLevel; set { this.insightLevel = value; - RenderHand(); + UpdateState(); } } diff --git a/Assets/Battle/UI/CardUI.cs b/Assets/Battle/UI/CardUI.cs index 21d7571..5cda27d 100644 --- a/Assets/Battle/UI/CardUI.cs +++ b/Assets/Battle/UI/CardUI.cs @@ -11,7 +11,10 @@ public class CardUI : MonoBehaviour public Image artImage; public Text effectText; + private bool hidden; + public void Init(BaseCard card) { + this.hidden = false; this.nameText.text = card.GetDisplayName(); this.typeText.text = card.GetDisplayType(); if (card.Type != CardType.Emotion) { @@ -25,6 +28,7 @@ public class CardUI : MonoBehaviour } public void InitHidden() { + this.hidden = true; Color BROWN = new Color(0.14f, 0.09f, 0.04f); this.nameText.text = "????"; this.typeText.text = "????"; @@ -53,8 +57,10 @@ public class CardUI : MonoBehaviour public bool Playable { set { - this.GetComponent().color = value ? Color.white : Color.grey; - this.artImage.color = value ? Color.white : Color.grey; + if (!this.hidden) { + this.GetComponent().color = value ? Color.white : Color.grey; + this.artImage.color = value ? Color.white : Color.grey; + } } } }