Add monster energy indicator
This commit is contained in:
parent
537538a6ca
commit
4ca7b7537a
6 changed files with 228 additions and 50 deletions
|
|
@ -14,6 +14,8 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
|
|||
public HeroInfoUI heroUIPrefab;
|
||||
public GameObject uiCanvas;
|
||||
public BattlePlayerControls battlePlayerControls;
|
||||
public EnergyUI heroEnergyUI;
|
||||
public EnergyUI monsterEnergyUI;
|
||||
|
||||
private HeroCardDatabase heroCardDatabase;
|
||||
private MonsterCardDatabase monsterCardDatabase;
|
||||
|
|
@ -31,15 +33,20 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
|
|||
|
||||
private bool heroTurn;
|
||||
private bool heroPassedTurn;
|
||||
private int maxEnergy;
|
||||
private int energy;
|
||||
private int maxMEnergy;
|
||||
private int mEnergy;
|
||||
private EnergyPool heroEnergy;
|
||||
private EnergyPool monsterEnergy;
|
||||
|
||||
void Awake() {
|
||||
this.heroCardDatabase = new HeroCardDatabase();
|
||||
this.monsterCardDatabase = new MonsterCardDatabase();
|
||||
|
||||
this.heroEnergy = new EnergyPool();
|
||||
this.heroEnergyUI.Init(this.heroEnergy);
|
||||
this.heroEnergy.OnEnergyChanged += this.heroEnergyUI.NotifyEnergyChanged;
|
||||
this.monsterEnergy = new EnergyPool();
|
||||
this.monsterEnergyUI.Init(this.monsterEnergy);
|
||||
this.monsterEnergy.OnEnergyChanged += this.monsterEnergyUI.NotifyEnergyChanged;
|
||||
|
||||
heroes = new BattleHero[3];
|
||||
heroSprites = new GameObject[3];
|
||||
heroUIs = new HeroInfoUI[3];
|
||||
|
|
@ -136,8 +143,8 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
|
|||
|
||||
this.damageTriggers.RemoveAll(t => t.Expiration == TriggerExpiration.StartOfNextHeroTurn);
|
||||
|
||||
this.energy = this.maxEnergy;
|
||||
this.mEnergy = this.maxMEnergy;
|
||||
heroEnergy.Replenish();
|
||||
monsterEnergy.Replenish();
|
||||
this.heroDeck.DrawHand();
|
||||
this.monsterDeck.DrawHand();
|
||||
|
||||
|
|
@ -149,9 +156,10 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
|
|||
|
||||
private IEnumerator RunHeroTurn() {
|
||||
// Start of hero turn
|
||||
if (this.maxEnergy < 9) {
|
||||
this.maxEnergy++;
|
||||
this.energy++;
|
||||
|
||||
// TODO: Play emotions from hand
|
||||
if (this.heroEnergy.MaxEnergy < 9) {
|
||||
this.heroEnergy.DropOneEmotion();
|
||||
}
|
||||
foreach (BattleHero hero in this.heroes) {
|
||||
hero.ResetBlock();
|
||||
|
|
@ -171,9 +179,8 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
|
|||
yield return new WaitForSeconds(0.5f);
|
||||
|
||||
// Start of monster turn
|
||||
if (this.maxMEnergy < 9) {
|
||||
this.maxMEnergy++;
|
||||
this.mEnergy++;
|
||||
if (this.monsterEnergy.MaxEnergy < 9) {
|
||||
this.monsterEnergy.DropOneEmotion();
|
||||
}
|
||||
foreach (BattleMonster monster in this.monsters) {
|
||||
monster.ResetBlock();
|
||||
|
|
@ -201,7 +208,7 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
|
|||
|
||||
public IEnumerator UseHeroCard(HeroCard card) {
|
||||
yield return card.Use(this, battlePlayerControls);
|
||||
PayHeroCardCost(card);
|
||||
this.heroEnergy.PayForCard(card);
|
||||
this.heroDeck.RemoveCardFromHand(card);
|
||||
if (card.IsPermanent()) {
|
||||
this.playArea.AddPlayedHeroPermanent(card);
|
||||
|
|
@ -212,7 +219,7 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
|
|||
|
||||
public IEnumerator UseMonsterCard(MonsterCard card) {
|
||||
yield return card.Use(this, this);
|
||||
PayMonsterCardCost(card);
|
||||
this.monsterEnergy.PayForCard(card);
|
||||
this.monsterDeck.RemoveCardFromHand(card);
|
||||
if (card.IsPermanent()) {
|
||||
this.playArea.AddPlayedMonsterPermanent(card);
|
||||
|
|
@ -230,27 +237,11 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
|
|||
}
|
||||
|
||||
public bool CanUseHeroCard(HeroCard card) {
|
||||
return this.heroTurn && this.energy >= card.GetCost();
|
||||
return this.heroTurn && this.heroEnergy.CanPayForCard(card);
|
||||
}
|
||||
|
||||
public bool CanUseMonsterCard(MonsterCard card) {
|
||||
return !this.heroTurn && this.mEnergy >= card.GetCost();
|
||||
}
|
||||
|
||||
private void PayHeroCardCost(HeroCard card) {
|
||||
this.energy -= card.GetCost();
|
||||
}
|
||||
|
||||
private void PayMonsterCardCost(MonsterCard card) {
|
||||
this.mEnergy -= card.GetCost();
|
||||
}
|
||||
|
||||
public int GetEnergy() {
|
||||
return this.energy;
|
||||
}
|
||||
|
||||
public int GetMaxEnergy() {
|
||||
return this.maxEnergy;
|
||||
return !this.heroTurn && this.monsterEnergy.CanPayForCard(card);
|
||||
}
|
||||
|
||||
public BattleDeck<HeroCard> GetHeroDeck() {
|
||||
|
|
@ -274,6 +265,9 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
|
|||
// Cleanup expired triggers
|
||||
this.damageTriggers.RemoveAll(t => t.Expired);
|
||||
}
|
||||
|
||||
public EnergyPool HeroEnergy {get => this.heroEnergy;}
|
||||
public EnergyPool MonsterEnergy {get => this.monsterEnergy;}
|
||||
|
||||
// IBattleEffectApplier
|
||||
public void Apply(IBattleEffect effect) {
|
||||
|
|
@ -282,7 +276,7 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
|
|||
|
||||
// IBattleEffectResolver
|
||||
public void IncreaseHeroMaxEnergy(IncreaseMaxEnergyEffect effect) {
|
||||
this.maxEnergy += effect.Amount;
|
||||
this.heroEnergy.MaxEnergy += effect.Amount;
|
||||
}
|
||||
|
||||
public void IncreaseMaxHP(IncreaseMaxHPEffect effect) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue