public void ChangeEnergy(int energyCount) { int currentEnergy = PlayerPrefs.GetInt("Player.Energy"); int newBalance = currentEnergy + energyCount; PlayerPrefs.SetInt("Player.Energy", newBalance); OnEnergyChanged?.Invoke(newBalance, energyCount); }
public void RegenEnergyOverTime(float regenSpeed) { currentEnergy += regenSpeed * Time.deltaTime; ClampEnergy(); OnEnergyChanged?.Invoke(this, new OnEnergyChangedEventArgs { CurrentEnergy = currentEnergy }); }
public void RegenEnergy(float regenAmount) { currentEnergy += regenAmount; ClampEnergy(); OnEnergyChanged?.Invoke(this, new OnEnergyChangedEventArgs { CurrentEnergy = currentEnergy }); }
public void DrainEnergy(float drainAmount) { currentEnergy -= drainAmount; ClampEnergy(); OnEnergyChanged?.Invoke(this, new OnEnergyChangedEventArgs { CurrentEnergy = currentEnergy }); }
public void SendEnergy(int amount, NodeController destination) { if (node is IEnergyTransmitter transmitter) { transmitter.TransmitEnergy(destination, amount); } OnEnergyChanged?.Invoke(); }
public void AddEnergy(int amount, NetworkIdentity sender) { if (node is IEnergyReceiver receiver) { receiver.ReceiveEnergy(amount, sender); } OnEnergyChanged?.Invoke(); }
private void SpendEnergy() { Energy--; OnEnergyChanged?.Invoke(Energy); if (Energy < 1) { OnOutOfEnergy?.Invoke(); Energy = 0; } }
private void Awake() { Energy = MaxEnergy; OnEnergyChanged?.Invoke(Energy); }
protected virtual void InvokeEnergyChanged(float oldValue, float newValue) { OnEnergyChanged?.Invoke(this, oldValue, newValue); }
void HandleEnergyChanged(OnEnergyChanged e) { timeText.text = $"{e.NewEnergy.ToString("0.0")} sec"; timeSlider.maxValue = e.NewEnergy; }
public void EnergyChanged() { OnEnergyChanged?.Invoke(this); }