public void EndPowerup() { PowerupActive = PowerupType.None; PowerupTimer = null; PowerupPanel.gameObject.SetActive(false); }
public override void OnUpdate() { if (PowerupTimer != null) { PowerupTime.value = 1 - (PowerupTimer.Elapsed / 20); } float direction = 0f; if (Input.GetKey(KeyCode.LeftArrow) || LeftButtonPressed) { direction = -1; } else if (Input.GetKey(KeyCode.RightArrow) || RightButtonPressed) { direction = 1; } X += direction * Speed * Time.deltaTime; if (Input.GetKeyDown(KeyCode.Space)) { FireButtonClicked(); } Laser.enabled = false; if (Input.GetKey(KeyCode.Space) || FireButtonPressed) { if (PowerupActive == PowerupType.Bacon) { BaconLazer(); } if (PowerupActive == PowerupType.RapidFire) { var Missile = Clone(RapidMissileType); Missile.Rotate(Random.Range(-RapidFireSpread, RapidFireSpread)); } } var TouchingPowerup = GetTouchingSprite<PowerupSprite>(); if (TouchingPowerup != null) { TouchingPowerup.Destroy(); PowerupActive = (PowerupType)TouchingPowerup.CostumeNumber; if (PowerupTimer != null) { PowerupTimer.Active = false; } PowerupTimer = Wait(20, EndPowerup); PowerupImage.sprite = TouchingPowerup.Costumes[TouchingPowerup.CostumeNumber]; PowerupPanel.gameObject.SetActive(true); } }