/// <summary> /// Adds a new powerup to the player, or resets a powerup if exists in the list. /// </summary> /// <param name="powerUp"></param> private void ResetOrAddPowerUp(PowerUp powerUp) { bool contains = false; foreach (PowerUp p in PowerUps) { if (p == powerUp) { p.Reset (); contains = true; break; } } if (!contains) { PowerUps.Add (powerUp); } }
/// <summary> /// Adds a new powerup to the player /// </summary> /// <param name="powerUp"></param> public void AddPowerUp(PowerUp powerUp) { if (powerUp.IsCumulative) PowerUps.Add(powerUp); else ResetOrAddPowerUp(powerUp); // Only the server can update the score, because the client receives score updates via RPC if(Network.isServer) Score += 1; }