diff --git a/Assets/Battle/BaseCard.cs b/Assets/Battle/BaseCard.cs index 3faaf08..91b925a 100644 --- a/Assets/Battle/BaseCard.cs +++ b/Assets/Battle/BaseCard.cs @@ -9,13 +9,15 @@ public abstract class BaseCard protected int cost; protected CardType type; protected string effectText; + protected string stringId; - public BaseCard(BattleParticipant owner, string displayName, int cost, CardType type, string effectText) { + public BaseCard(BattleParticipant owner, string displayName, int cost, CardType type, string effectText, string stringId) { this.owner = owner; this.displayName = displayName; this.cost = cost; this.type = type; this.effectText = effectText; + this.stringId = stringId; } public BattleParticipant Owner {get => this.owner;} @@ -38,4 +40,8 @@ public abstract class BaseCard public bool IsPermanent() { return this.type == CardType.Enchantment; } + + public string StringId { + get => this.stringId; + } } diff --git a/Assets/Battle/BattleController.cs b/Assets/Battle/BattleController.cs index 60b487a..8819f66 100644 --- a/Assets/Battle/BattleController.cs +++ b/Assets/Battle/BattleController.cs @@ -179,8 +179,10 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe this.monsterCardDatabase, mCardIds.Cast().ToArray(), mCardOwners); this.playArea = new PlayArea(); + this.heroHandPlayability = new HandPlayability( this.state, this.heroEnergy, TeamChoice.Heroes, this.heroDeck); + this.OnBattleStateChanged += this.heroHandPlayability.NotifyBattleStateChanged; this.battlePlayerControls.Init( this.heroDeck, this.monsterDeck, this.playArea, this.insightLevel, @@ -188,9 +190,6 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe this.battlePlayerControls.OnCardUsed += this.NotifyHeroCardUsed; this.battlePlayerControls.OnTurnPassed += this.NotifyHeroTurnPassed; this.insightLevel.OnChanged += this.battlePlayerControls.NotifyInsightLevelChanged; - this.heroDeck.OnHandPileChanged += this.battlePlayerControls.NotifyHeroHandPileChanged; - this.monsterDeck.OnHandPileChanged += this.battlePlayerControls.NotifyMonsterHandPileChanged; - this.OnBattleStateChanged += this.heroHandPlayability.NotifyBattleStateChanged; } private void PositionSprite(TeamChoice team, GameObject sprite, int i) { @@ -310,8 +309,8 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe public IEnumerator UseHeroCard(HeroCard card) { this.heroEnergy.PayForCard(card); - this.heroDeck.RemoveCardFromHand(card); yield return card.Use(this, this, battlePlayerControls); + this.heroDeck.RemoveCardFromHand(card); if (card.IsPermanent()) { this.playArea.AddPlayedHeroPermanent(card); } else { @@ -325,8 +324,8 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe public IEnumerator UseMonsterCard(MonsterCard card) { this.monsterEnergy.PayForCard(card); - this.monsterDeck.RemoveCardFromHand(card); yield return card.Use(this, this); + this.monsterDeck.RemoveCardFromHand(card); if (card.IsPermanent()) { this.playArea.AddPlayedMonsterPermanent(card); } else { diff --git a/Assets/Battle/BattlePlayerControls.cs b/Assets/Battle/BattlePlayerControls.cs index 1556e08..75f2dd4 100644 --- a/Assets/Battle/BattlePlayerControls.cs +++ b/Assets/Battle/BattlePlayerControls.cs @@ -35,11 +35,11 @@ public class BattlePlayerControls : MonoBehaviour this.insightLevel = insightLevel; this.heroHandControls = new HandControls( - this.uiCanvas, this.cardPrefab, HandControlsPosition.Bottom, TeamChoice.Heroes, + heroDeck, this.uiCanvas, this.cardPrefab, HandControlsPosition.Bottom, TeamChoice.Heroes, int.MaxValue, heroHandPlayability); this.heroHandControls.OnCardClicked += OnHeroCardClicked; this.monsterHandControls = new HandControls( - this.uiCanvas, this.cardPrefab, HandControlsPosition.Top, TeamChoice.Monsters, 1, null); + monsterDeck, this.uiCanvas, this.cardPrefab, HandControlsPosition.Top, TeamChoice.Monsters, 1, null); this.monsterHandControls.OnCardClicked += OnMonsterCardClicked; this.cardsInPlayUIs = new Dictionary(); @@ -94,14 +94,6 @@ public class BattlePlayerControls : MonoBehaviour return this.singleTargeting != null && this.singleTargeting.CanTarget(participant); } - public void NotifyHeroHandPileChanged() { - this.heroHandControls.SetHand(this.heroDeck.GetHandPile().ToList()); - } - - public void NotifyMonsterHandPileChanged() { - this.monsterHandControls.SetHand(this.monsterDeck.GetHandPile().ToList()); - } - private void NotifyPlayAreaChanged() { DestroyCardsThatLeftPlayArea(); CreateCardsThatEnteredPlayArea(); diff --git a/Assets/Battle/BattleScene.unity b/Assets/Battle/BattleScene.unity index 070a4bb..5303c91 100644 --- a/Assets/Battle/BattleScene.unity +++ b/Assets/Battle/BattleScene.unity @@ -153,9 +153,9 @@ RectTransform: m_Father: {fileID: 35522592} m_RootOrder: 1 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0.5, y: 0.5} - m_AnchorMax: {x: 0.5, y: 0.5} - m_AnchoredPosition: {x: 0, y: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 0, y: 0} + m_AnchoredPosition: {x: 565, y: 320} m_SizeDelta: {x: 100, y: 100} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &24180901 @@ -358,9 +358,9 @@ RectTransform: m_Father: {fileID: 35522592} m_RootOrder: 4 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0.5, y: 0.5} - m_AnchorMax: {x: 0.5, y: 0.5} - m_AnchoredPosition: {x: 0, y: 0} + m_AnchorMin: {x: 1, y: 1} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: -570, y: -338.11} m_SizeDelta: {x: 100, y: 100} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &431798876 @@ -493,7 +493,7 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0.5, y: 0.5} m_AnchorMax: {x: 0.5, y: 0.5} - m_AnchoredPosition: {x: -467.1, y: -316} + m_AnchoredPosition: {x: -467.1, y: -298.4} m_SizeDelta: {x: 171.60992, y: 30} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &527589755 @@ -637,7 +637,7 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0.5, y: 0.5} m_AnchorMax: {x: 0.5, y: 0.5} - m_AnchoredPosition: {x: -467.1, y: -316} + m_AnchoredPosition: {x: -467.1, y: -295} m_SizeDelta: {x: 171.60992, y: 30} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &1242658820 @@ -793,9 +793,9 @@ RectTransform: m_Father: {fileID: 35522592} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0.5, y: 0.5} - m_AnchorMax: {x: 0.5, y: 0.5} - m_AnchoredPosition: {x: 480.5, y: -314.1} + m_AnchorMin: {x: 1, y: 0} + m_AnchorMax: {x: 1, y: 0} + m_AnchoredPosition: {x: -83.3, y: 19.899994} m_SizeDelta: {x: 160, y: 30} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &1415908915 @@ -970,7 +970,7 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0.5, y: 0.5} m_AnchorMax: {x: 0.5, y: 0.5} - m_AnchoredPosition: {x: -467.1, y: -345.14} + m_AnchoredPosition: {x: -467.1, y: -321.3} m_SizeDelta: {x: 171.60992, y: 30} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &1522237122 @@ -1046,9 +1046,9 @@ RectTransform: m_Father: {fileID: 35522592} m_RootOrder: 2 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0.5, y: 0.5} - m_AnchorMax: {x: 0.5, y: 0.5} - m_AnchoredPosition: {x: 0, y: 60} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 0, y: 0} + m_AnchoredPosition: {x: 565, y: 380} m_SizeDelta: {x: 100, y: 100} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &1887276864 @@ -1097,9 +1097,9 @@ RectTransform: m_Father: {fileID: 35522592} m_RootOrder: 3 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0.5, y: 0.5} - m_AnchorMax: {x: 0.5, y: 0.5} - m_AnchoredPosition: {x: 0, y: 60} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 0, y: 0} + m_AnchoredPosition: {x: 565, y: 380} m_SizeDelta: {x: 100, y: 100} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &2103461258 diff --git a/Assets/Battle/CardsHeroes/IronskinDraughtHCard.cs b/Assets/Battle/CardsHeroes/IronskinDraughtHCard.cs index b54c9ee..3238445 100644 --- a/Assets/Battle/CardsHeroes/IronskinDraughtHCard.cs +++ b/Assets/Battle/CardsHeroes/IronskinDraughtHCard.cs @@ -5,7 +5,7 @@ using UnityEngine; public class IronskinDraughtHCard : HeroCard { public IronskinDraughtHCard(BattleParticipant owner) - : base(owner, HCardId.Cover, "Ironskin Draught", 3, CardType.Skill, + : base(owner, HCardId.IronskinDraught, "Ironskin Draught", 3, CardType.Skill, "Block 6 damage on target ally.") { } diff --git a/Assets/Battle/Graphics/HitAnimation.anim b/Assets/Battle/Graphics/HitAnimation.anim index 3312db3..b034dec 100644 --- a/Assets/Battle/Graphics/HitAnimation.anim +++ b/Assets/Battle/Graphics/HitAnimation.anim @@ -30,8 +30,8 @@ AnimationClip: inWeight: 0.33333334 outWeight: 0.33333334 - serializedVersion: 3 - time: 0.033333335 - value: 0.99937946 + time: 0.13333334 + value: 0.9790395 inSlope: 0.15729958 outSlope: 0.15729958 tangentMode: 1 @@ -39,8 +39,8 @@ AnimationClip: inWeight: 0.10925299 outWeight: 0.020041859 - serializedVersion: 3 - time: 0.21666667 - value: 0.012205221 + time: 0.26666668 + value: -0.008134745 inSlope: 0 outSlope: 0 tangentMode: 0 @@ -113,8 +113,8 @@ AnimationClip: inWeight: 0.33333334 outWeight: 0.33333334 - serializedVersion: 3 - time: 0.033333335 - value: 0.99937946 + time: 0.13333334 + value: 0.9790395 inSlope: 0.15729958 outSlope: 0.15729958 tangentMode: 1 @@ -122,8 +122,8 @@ AnimationClip: inWeight: 0.10925299 outWeight: 0.020041859 - serializedVersion: 3 - time: 0.21666667 - value: 0.012205221 + time: 0.26666668 + value: -0.008134745 inSlope: 0 outSlope: 0 tangentMode: 0 diff --git a/Assets/Battle/HandControls.cs b/Assets/Battle/HandControls.cs index e8dc628..1a2ae93 100644 --- a/Assets/Battle/HandControls.cs +++ b/Assets/Battle/HandControls.cs @@ -14,6 +14,7 @@ public class HandControls where BaseCardT : BaseCard public delegate void CardClickedAction(BaseCardT card); public event CardClickedAction OnCardClicked; + private BattleDeck deck; private GameObject uiCanvas; private GameObject cardPrefab; private HandControlsPosition position; @@ -24,8 +25,9 @@ public class HandControls where BaseCardT : BaseCard private int insightLevel; private HandPlayability playability; - public HandControls(GameObject uiCanvas, GameObject cardPrefab, HandControlsPosition position, + public HandControls(BattleDeck deck, GameObject uiCanvas, GameObject cardPrefab, HandControlsPosition position, TeamChoice team, int insightLevel, HandPlayability playability) { + this.deck = deck; this.uiCanvas = uiCanvas; this.cardPrefab = cardPrefab; this.position = position; @@ -33,16 +35,13 @@ public class HandControls where BaseCardT : BaseCard this.insightLevel = insightLevel; this.playability = playability; + deck.OnHandPileChanged += this.UpdateState; + if (playability != null) { - playability.OnPlayabilityChanged += UpdateCardPlayability; + playability.OnPlayabilityChanged += this.UpdateState; } } - public void SetHand(List hand) { - this.hand = hand; - RenderHand(); - } - private Vector3 CalculateHandCardPosition(int index, int count) { const int SPACING = 8; const int DELTA = BattleCardPrefabConstants.CARD_WIDTH + SPACING; @@ -89,6 +88,11 @@ public class HandControls where BaseCardT : BaseCard int cardIndex = i; cardUI.GetComponent