51 lines
1.1 KiB
C#
51 lines
1.1 KiB
C#
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;
|
|
TriggerOnEnergyChanged();
|
|
}
|
|
}
|
|
public int Energy {get => this.energy;
|
|
set {
|
|
this.energy = value;
|
|
TriggerOnEnergyChanged();
|
|
}
|
|
}
|
|
}
|