Advertisement
bekovski

LD42_pickup_update

Aug 12th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.90 KB | None | 0 0
  1. public void UpdatePickUps(float deltaTime) {
  2.         for(int i=0; i < spawnedPickUps.Count; ++i) {
  3.             PickUp pu = spawnedPickUps [i];
  4.  
  5.             // if spawned count down spawn time
  6.             if(pu.pickUp.activeSelf) {
  7.                 pu.timeLeftDespawn -= deltaTime;
  8.             }
  9.             // else count down despawnTime (TODO: must also check if collected by player!)
  10.             else {
  11.                 pu.timeLeftActive -= deltaTime;
  12.             }
  13.  
  14.             // despawn if time is up
  15.             if(pu.timeLeftDespawn <= 0) {
  16.                 pu.pickUp.SetActive (false);
  17.                 spawnedPickUps.Remove (pu);
  18.             }
  19.  
  20.             // deactivate effects if time is up
  21.             if(pu.timeLeftActive <= 0) {
  22.                 spawnedPickUps.Remove (pu);
  23.                 // TODO: remove effects
  24.                 if(pu is GreenPickUp) {
  25.                    
  26.                 } // endif GreenPickUp
  27.                 else {
  28.                     if(((RedPickUp)pu).isSlowPlayerDown) {
  29.                         DebuffSlowPlayerDownRevert (); 
  30.                     }
  31.                 } // endif RedPickUp
  32.             } // endif timeLeftActive
  33.  
  34.         } // foreach()
  35.     } // UpdatePickUps()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement