public void usePowerUp() { if (stack != -1) { if (isActive) { terminatePowerUp(); } activePowerUp = stack; stack = -1; timeLeft = 10; isActive = true; Movement m = GetComponent <Movement>(); PlayerHitBoxControl phb = GetComponent <PlayerHitBoxControl>(); switch (activePowerUp) { case 0: phb.setShield(true); //Debug.Log ("Shield"); break; case 1: m.jumpForce *= 3; m.maxSpeed *= 2; // m.acceleration *=2; // m.maxAirSpeed *=2; m.airAcceleration *= 2; //Debug.Log ("Estic super saltant"); break; case 2: m.maxSpeed *= 2; m.acceleration *= 2; m.maxAirSpeed *= 1.5f; // m.airAcceleration *=2; //Debug.Log ("Estic super corrents"); break; case 3: rigidbody.useGravity = false; //Debug.Log ("No tinc gravetat"); break; default: break; } } }
void terminatePowerUp() { isActive = false; timeLeft = 0; Movement m = GetComponent <Movement>(); PlayerHitBoxControl pHB = GetComponent <PlayerHitBoxControl>(); switch (activePowerUp) { case 0: pHB.setShield(false); break; case 1: m.jumpForce /= 3; m.maxSpeed /= 2; // m.acceleration /=2; // m.maxAirSpeed /=2; m.airAcceleration /= 2; break; case 2: m.maxSpeed /= 2; m.acceleration /= 2; m.maxAirSpeed /= 1.5f; // m.airAcceleration /=2; break; case 3: rigidbody.useGravity = true; break; default: break; } activePowerUp = -1; }