Implement BattleEffects, add Thunderstorm

This commit is contained in:
henriquenakashima 2020-09-19 16:58:14 -04:00
parent fc427bd276
commit 00448fe919
20 changed files with 215 additions and 18 deletions

View file

@ -2,7 +2,7 @@
using System.Collections.Generic;
using UnityEngine;
public class BattleController : MonoBehaviour
public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffectResolver
{
public HeroId[] heroIds;
public MonsterId[] monsterIds;
@ -13,6 +13,7 @@ public class BattleController : MonoBehaviour
public BattlePlayerControls battlePlayerControls;
private HeroDeck heroDeck;
private PlayArea playArea;
public BattleHero[] heroes;
private GameObject[] heroSprites;
@ -77,6 +78,8 @@ public class BattleController : MonoBehaviour
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) {
@ -144,9 +147,14 @@ public class BattleController : MonoBehaviour
}
public IEnumerator UseCard(BaseCard card) {
yield return card.Use(battlePlayerControls);
yield return card.Use(this, battlePlayerControls);
PayCardCost(card);
this.heroDeck.DiscardPlayedCard(card);
this.heroDeck.RemoveCardFromHand(card);
if (card.IsPermanent()) {
this.playArea.AddPlayedHeroPermanent(card);
} else {
this.heroDeck.MoveCardToDiscard(card);
}
}
public void NotifyTurnPassed() {
@ -175,4 +183,18 @@ public class BattleController : MonoBehaviour
public HeroDeck GetHeroDeck() {
return this.heroDeck;
}
public PlayArea GetPlayArea() {
return this.playArea;
}
// IBattleEffectApplier
public void Apply(IBattleEffect effect) {
effect.Apply(this);
}
// IBattleEffectResolver
public void IncreaseMaxEnergy(int delta) {
this.maxEnergy += delta;
}
}