Add monster energy indicator
This commit is contained in:
parent
537538a6ca
commit
4ca7b7537a
6 changed files with 228 additions and 50 deletions
41
Assets/Battle/EnergyPool.cs
Normal file
41
Assets/Battle/EnergyPool.cs
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class EnergyPool
|
||||
{
|
||||
private int maxEnergy;
|
||||
private int energy;
|
||||
|
||||
public delegate void EnergyChangedAction();
|
||||
public event EnergyChangedAction OnEnergyChanged;
|
||||
|
||||
public void Replenish() {
|
||||
this.energy = this.maxEnergy;
|
||||
TriggerOnEnergyChanged();
|
||||
}
|
||||
|
||||
public void DropOneEmotion() {
|
||||
this.maxEnergy++;
|
||||
this.energy++;
|
||||
TriggerOnEnergyChanged();
|
||||
}
|
||||
|
||||
public bool CanPayForCard(BaseCard card) {
|
||||
return this.energy >= card.GetCost();
|
||||
}
|
||||
|
||||
public void PayForCard(BaseCard card) {
|
||||
this.energy -= card.GetCost();
|
||||
TriggerOnEnergyChanged();
|
||||
}
|
||||
|
||||
private void TriggerOnEnergyChanged() {
|
||||
if (this.OnEnergyChanged != null) {
|
||||
OnEnergyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public int MaxEnergy {get => this.maxEnergy; set => this.maxEnergy = value;}
|
||||
public int Energy {get => this.energy;}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue