/// <summary> /// Show powerup preview according to currently selected powerupType. /// </summary> public void Show(PlayerPowerupTypes powerupType) { switch (powerupType) { case PlayerPowerupTypes.INVINCIBILTY: foreach (Renderer renderer in snakeTailRenderer) { renderer.material = invincibiltySnakeMaterial; } break; case PlayerPowerupTypes.MAGNET: magnetParticles.SetActive(true); break; case PlayerPowerupTypes.THIN: foreach (Animator animator in thinAnimators) { animator.ResetTrigger(thinOffAnimationKey); animator.SetTrigger(thinOnAnimationKey); } foreach (GameObject go in thinTails) { go.SetActive(true); } break; } }
/// <summary> /// Respawn a random powerup based on which powerups are unlocked provided by the parameter. /// </summary> public void Respawn(List <PowerupObject> unlockedPowerups) { int randomPowerup = Random.Range(0, unlockedPowerups.Count); currentType = unlockedPowerups[randomPowerup].GetPowerupType(); duration = baseDuration + durationMultiplier * unlockedPowerups[randomPowerup].GetCurrentLevel(); }
/// <summary> /// Player collected powerup so find out which random one it is. /// </summary> public PlayerPowerupTypes PlayerCollectedPowerup() { soundManager.StopSound(SoundEffectType.SOUND_SLITHER); soundManager.PlaySound(SoundEffectType.SOUND_POWERUP_COLLECT, false); PlayerPowerupTypes collectedType = powerupSpawner.CollectPowerup(soundManager); guiManager.ShowPowerupIcon(collectedType); guiManager.SetPowerupDuration(powerupSpawner.GetPowerupDuration()); return(collectedType); }
/// <summary> /// Player has collected a powerup so show the right icon on the HUD. /// </summary> public void ShowPowerupIcon(PlayerPowerupTypes collectedType) { powerupIcon.enabled = true; switch (collectedType) { case PlayerPowerupTypes.INVINCIBILTY: powerupIcon.sprite = powerupInvincibilityIcon; break; case PlayerPowerupTypes.MAGNET: powerupIcon.sprite = powerupMagnetIcon; break; case PlayerPowerupTypes.THIN: powerupIcon.sprite = powerupThinIcon; break; } }
/// <summary> /// Player collected powerup so check which kind it was. /// </summary> public PlayerPowerupTypes CollectPowerup(SoundManager soundManager) { PlayerPowerupTypes currentType = powerup.GetCurrentType(); switch (currentType) { case PlayerPowerupTypes.INVINCIBILTY: soundManager.PlaySound(SoundEffectType.SOUND_INVINCIBILITY, false); break; case PlayerPowerupTypes.MAGNET: soundManager.PlaySound(SoundEffectType.SOUND_MAGNET, false); break; case PlayerPowerupTypes.THIN: soundManager.PlaySound(SoundEffectType.SOUND_THIN, false); break; } powerupGameObject.SetActive(false); StopAllCoroutines(); return(currentType); }