예제 #1
0
    // 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);
    }
예제 #2
0
    //Função que chama o evento para coletar energia
    public void GetEnergy(float energy)
    {
        _energy += energy;

        if (EnergyEvent != null)
        {
            EnergyEvent.Invoke(_energy / _maxEnergy);
        }
    }
예제 #3
0
 /// <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();
     }
 }
예제 #4
0
    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);
    }