Implement Meditate

This commit is contained in:
henriquenakashima 2020-09-22 01:09:20 -04:00
parent 03ca23d484
commit ceb46f98b2
14 changed files with 207 additions and 28 deletions

View file

@ -35,6 +35,7 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
private bool heroPassedTurn;
private EnergyPool heroEnergy;
private EnergyPool monsterEnergy;
private InsightLevel insightLevel;
void Awake() {
this.heroCardDatabase = new HeroCardDatabase();
@ -47,6 +48,8 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
this.monsterEnergyUI.Init(this.monsterEnergy);
this.monsterEnergy.OnEnergyChanged += this.monsterEnergyUI.NotifyEnergyChanged;
this.insightLevel = new InsightLevel(1);
heroes = new BattleHero[3];
heroSprites = new GameObject[3];
heroUIs = new HeroInfoUI[3];
@ -109,9 +112,11 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
this.playArea = new PlayArea();
this.battlePlayerControls.Init(this.heroDeck, this.monsterDeck, this.playArea);
this.battlePlayerControls.Init(
this.heroDeck, this.monsterDeck, this.playArea, this.insightLevel);
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;
}
@ -215,9 +220,9 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
}
public IEnumerator UseHeroCard(HeroCard card) {
yield return card.Use(this, battlePlayerControls);
this.heroEnergy.PayForCard(card);
this.heroDeck.RemoveCardFromHand(card);
yield return card.Use(this, battlePlayerControls);
if (card.IsPermanent()) {
this.playArea.AddPlayedHeroPermanent(card);
} else {
@ -229,9 +234,9 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
}
public IEnumerator UseMonsterCard(MonsterCard card) {
yield return card.Use(this, this);
this.monsterEnergy.PayForCard(card);
this.monsterDeck.RemoveCardFromHand(card);
yield return card.Use(this, this);
if (card.IsPermanent()) {
this.playArea.AddPlayedMonsterPermanent(card);
} else {
@ -311,6 +316,22 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
effect.Target.IncreaseMaxHP(effect.Amount);
}
public void ModifyInsight(ModifyInsightEffect effect) {
this.insightLevel.Modify(effect.Amount);
}
public void DrawCards(DrawCardsEffect effect) {
if (effect.Team == TeamChoice.Heroes) {
for (int i = 0; i < effect.Amount; i++) {
this.heroDeck.DrawCard();
}
} else {
for (int i = 0; i < effect.Amount; i++) {
this.monsterDeck.DrawCard();
}
}
}
public void AcquireCards(AcquireCardsEffect effect) {
if (effect.Participant == null) return;
@ -349,11 +370,9 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
private List<DamageTrigger> damageTriggers = new List<DamageTrigger>();
public int DealDamage(DealDamageEffect effect) {
Debug.Log("DealDamage to " + effect.Target.GetDisplayName() + " " + effect.Amount);
if (effect.Target == null) return 0;
int damageDealt = effect.Target.DealDamage(effect.Amount);
Debug.Log("damageDealt " + damageDealt);
foreach (DamageTrigger dt in this.damageTriggers) {
if (dt.IsTriggeredBy(effect)) {
EnqueueActivatedTrigger(dt);