Create MonsterCard
This commit is contained in:
parent
169210efbe
commit
cce0b2891c
22 changed files with 203 additions and 27 deletions
|
|
@ -2,7 +2,7 @@
|
|||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffectResolver
|
||||
public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffectResolver, MonsterViewpoint
|
||||
{
|
||||
public HeroId[] heroIds;
|
||||
public MonsterId[] monsterIds;
|
||||
|
|
@ -77,8 +77,8 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
|
|||
this.playArea = new PlayArea();
|
||||
|
||||
this.battlePlayerControls.Init(this.heroDeck, this.playArea);
|
||||
this.battlePlayerControls.OnCardUsed += this.NotifyCardUsed;
|
||||
this.battlePlayerControls.OnTurnPassed += this.NotifyTurnPassed;
|
||||
this.battlePlayerControls.OnCardUsed += this.NotifyHeroCardUsed;
|
||||
this.battlePlayerControls.OnTurnPassed += this.NotifyHeroTurnPassed;
|
||||
this.heroDeck.OnHandPileChanged += this.battlePlayerControls.NotifyHandPileChanged;
|
||||
}
|
||||
|
||||
|
|
@ -141,14 +141,14 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
|
|||
Debug.Log("Will attack " + this.heroes[this.enemyTarget].GetDisplayName());
|
||||
}
|
||||
|
||||
public void NotifyCardUsed(BaseCard card) {
|
||||
if (!CanUseCard(card)) {
|
||||
public void NotifyHeroCardUsed(HeroCard card) {
|
||||
if (!CanUseHeroCard(card)) {
|
||||
throw new System.InvalidOperationException("Cannot use card " + card.GetDisplayName());
|
||||
}
|
||||
StartCoroutine(UseCard(card));
|
||||
StartCoroutine(UseHeroCard(card));
|
||||
}
|
||||
|
||||
public IEnumerator UseCard(BaseCard card) {
|
||||
public IEnumerator UseHeroCard(HeroCard card) {
|
||||
yield return card.Use(this, battlePlayerControls);
|
||||
PayCardCost(card);
|
||||
this.heroDeck.RemoveCardFromHand(card);
|
||||
|
|
@ -159,17 +159,17 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
|
|||
}
|
||||
}
|
||||
|
||||
public void NotifyTurnPassed() {
|
||||
public void NotifyHeroTurnPassed() {
|
||||
if (this.heroTurn) {
|
||||
StartEnemyTurn();
|
||||
}
|
||||
}
|
||||
|
||||
public bool CanUseCard(BaseCard card) {
|
||||
public bool CanUseHeroCard(HeroCard card) {
|
||||
return this.heroTurn && this.energy >= card.GetCost();
|
||||
}
|
||||
|
||||
private void PayCardCost(BaseCard card) {
|
||||
private void PayCardCost(HeroCard card) {
|
||||
this.energy -= card.GetCost();
|
||||
}
|
||||
|
||||
|
|
@ -237,6 +237,11 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
|
|||
return damageDealt;
|
||||
}
|
||||
|
||||
public int Heal(HealEffect effect) {
|
||||
int healedAmount = effect.Target.Heal(effect.Amount);
|
||||
return healedAmount;
|
||||
}
|
||||
|
||||
public void AddBlock(BattleParticipant target, int amount) {
|
||||
target.AddBlock(amount);
|
||||
}
|
||||
|
|
@ -258,4 +263,7 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
|
|||
// Cleanup expired triggers
|
||||
this.damageTriggers.RemoveAll(t => t.Expired);
|
||||
}
|
||||
|
||||
// MonsterViewpoint
|
||||
public BattleHero[] Heroes {get => this.heroes;}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue