// Process the energy and raise the event public int AbsorbEnergy(EnergySource source) { int energyAbsorbed = ProcessEnergy(source.energy); _energyAbsorbedEvent.Invoke(new EnergyEventData(source, this, energyAbsorbed)); return(energyAbsorbed); }
//Função que chama o evento para coletar energia public void GetEnergy(float energy) { _energy += energy; if (EnergyEvent != null) { EnergyEvent.Invoke(_energy / _maxEnergy); } }
/// <summary> /// Used to detect collisions with the player such as /// colliding with the charge station /// </summary> /// <param name="collision"></param> private void OnCollisionEnter2D(Collision2D collision) { if ((collision.gameObject.tag == "Charge Station") || (collision.gameObject.tag == "EnemyPistol")) { //invokes event to maximize the energy value AudioManager.Instance.Play(AudioClipName.gun_Charge); maxEnergyEvent.Invoke(); } }
protected virtual void Process(float deltaTime) { _energy = Mathf.Clamp(_energy, 0.0f, MaxEnergy + MaxExcessEnergy); float energyDrained = DrainRate.Value * deltaTime; OnProcessEnergy.Invoke(this, energyDrained); AddEnergy(-energyDrained); }