Пример #1
0
 public void AddEnergy(int amount)
 {
     energy += amount;
     if (energy > 100)
     {
         energy = 100;
     }
     playerLight.SwitchOnPointLight();
     if (onEnergyChangedCallback != null)
     {
         onEnergyChangedCallback.Invoke();
     }
 }
Пример #2
0
    public void ChangeEnergy(int energyCount)
    {
        int currentEnergy = PlayerPrefs.GetInt("Player.Energy");
        int newBalance    = currentEnergy + energyCount;

        PlayerPrefs.SetInt("Player.Energy", newBalance);
        OnEnergyChanged?.Invoke(newBalance, energyCount);
    }
Пример #3
0
    public void RegenEnergyOverTime(float regenSpeed)
    {
        currentEnergy += regenSpeed * Time.deltaTime;
        ClampEnergy();

        OnEnergyChanged?.Invoke(this, new OnEnergyChangedEventArgs {
            CurrentEnergy = currentEnergy
        });
    }
Пример #4
0
    public void RegenEnergy(float regenAmount)
    {
        currentEnergy += regenAmount;
        ClampEnergy();

        OnEnergyChanged?.Invoke(this, new OnEnergyChangedEventArgs {
            CurrentEnergy = currentEnergy
        });
    }
Пример #5
0
    public void DrainEnergy(float drainAmount)
    {
        currentEnergy -= drainAmount;
        ClampEnergy();

        OnEnergyChanged?.Invoke(this, new OnEnergyChangedEventArgs {
            CurrentEnergy = currentEnergy
        });
    }
Пример #6
0
        public void SendEnergy(int amount, NodeController destination)
        {
            if (node is IEnergyTransmitter transmitter)
            {
                transmitter.TransmitEnergy(destination, amount);
            }

            OnEnergyChanged?.Invoke();
        }
Пример #7
0
        public void AddEnergy(int amount, NetworkIdentity sender)
        {
            if (node is IEnergyReceiver receiver)
            {
                receiver.ReceiveEnergy(amount, sender);
            }

            OnEnergyChanged?.Invoke();
        }
Пример #8
0
 private void SpendEnergy()
 {
     Energy--;
     OnEnergyChanged?.Invoke(Energy);
     if (Energy < 1)
     {
         OnOutOfEnergy?.Invoke();
         Energy = 0;
     }
 }
Пример #9
0
 private void Awake()
 {
     Energy = MaxEnergy;
     OnEnergyChanged?.Invoke(Energy);
 }
Пример #10
0
 protected virtual void InvokeEnergyChanged(float oldValue, float newValue)
 {
     OnEnergyChanged?.Invoke(this, oldValue, newValue);
 }
Пример #11
0
 public void EnergyChanged()
 {
     OnEnergyChanged?.Invoke(this);
 }