Пример #1
0
 // 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();
         }
     }
 }
Пример #2
0
 // Update is called once per frame
 void Update()
 {
     if (oxygenSupply != null)
     {
         float oxygenToDrain = oxygenDrainPerSecond * Time.deltaTime;
         oxygenSupply.ApplyDelta(-oxygenToDrain);
     }
 }
Пример #3
0
 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);
             }
         }
     }
 }