// Update is called once per frame void Update() { if (oxygenSupply != null && playerMovement != null) { ParticlesEnabled(playerMovement.isBeingMoved); if (playerMovement.isBeingMoved) { oxygenSupply.ApplyDelta(-depletionAmountPerSecond * Time.deltaTime); sounds.volume += 0.1f; sounds.pitch = ownerBody.velocity.magnitude / 3.5f; if (!sounds.isPlaying) { sounds.Play(); } } else { sounds.volume -= 0.2f; if (sounds.pitch > 1) { sounds.pitch -= 0.2f; } sounds.Stop(); } } }
// Update is called once per frame void Update() { if (oxygenSupply != null) { float oxygenToDrain = oxygenDrainPerSecond * Time.deltaTime; oxygenSupply.ApplyDelta(-oxygenToDrain); } }
void OnCollisionStay2D(Collision2D collision) { if (time <= 0 && canBeCollectedByEntitesTagged.Contains(collision.gameObject.tag)) { // Trigger Oxygen Replenishment, if the reciever has one Oxygen oxygen = collision.gameObject.GetComponent <Oxygen>(); if (oxygen != null && !self.isOut) { if (oxygen != null && self != null) { self.oxygen -= grantingRate; oxygen.ApplyDelta(grantingRate); } } } }