private IEnumerator IncreaseIntensity() { // Increase intensity each frame until it reaches total energy to absorb while (light.intensity < energyToAbsorb) { float amount = Time.deltaTime * energyAbsorbPerSecond; // Take energy from the player energy.GiveEnergy(amount); // Increase light intensity light.intensity += amount; yield return(new WaitForEndOfFrame()); } }
private void OnCollisionStay(Collision collision) { // If the enemy collide with the player if (collision.gameObject.CompareTag("Player")) { Energizer energizer = collision.gameObject.GetComponentInChildren <Energizer>(); if (energizer != null) { // Enemy steal energy to the player energizer.GiveEnergy(energyAbsorbPerSecond * Time.deltaTime); } } }