dronkowitz

LevelUp.cs

Oct 13th, 2021 (edited)
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.40 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class LevelUp : MonoBehaviour
  6. {
  7.     public GameObject levelUpHUD;
  8.     public GameObject levelUpParent;
  9.     public GameObject levelUpPrefab;
  10.     public List<AudioClip> characterSFX = new List<AudioClip>();
  11.     public bool levelingup;
  12.     public float speedCoreLevelUp;
  13.     public float powerCoreLevelUp;
  14.     public float flyCoreLevelUp;
  15.     public bool isSpeed, isFlying, isPower;
  16.     public Sprite bluePowerCore, redPowerCore, yellowPowerCore;
  17.     // Start is called before the first frame update
  18.     void Start()
  19.     {
  20.        
  21.     }
  22.  
  23.     // Update is called once per frame
  24.     void Update()
  25.     {
  26.        
  27.     }
  28.     public void LevelUpSound()
  29.     {
  30.         GetComponent<AudioSource>().Play();
  31.     }
  32.     public void OnTriggerEnter(Collider other)
  33.     {
  34.         if (other.CompareTag("Player")&&levelingup==false)
  35.         {
  36.             levelingup = true;
  37.             GetComponent<SpriteRenderer>().enabled = false;
  38.             GameInstance.speedLevelUp += 1;
  39.             GameInstance.flyLevelUp += 1;
  40.             GameInstance.powerLevelUp += 1;
  41.             Instantiate(levelUpPrefab, levelUpParent.transform);
  42.             StartCoroutine(PlayLevelUpSFX());
  43.             FindObjectOfType<HUD>().AddPower(5);
  44.         }
  45.     }
  46.    
  47.     public IEnumerator PlayLevelUpSFX()
  48.     {
  49.         GetComponent<AudioSource>().Play();
  50.         while (GetComponent<AudioSource>().isPlaying == true)
  51.         {
  52.             yield return new WaitForSeconds(Time.deltaTime);
  53.         }
  54.         GetComponent<AudioSource>().clip = characterSFX[GameInstance.currentTeam];
  55.         GetComponent<AudioSource>().Play();
  56.  
  57.         while (GetComponent<AudioSource>().isPlaying == true)
  58.         {
  59.             yield return new WaitForSeconds(Time.deltaTime);
  60.         }
  61.         Destroy(gameObject);
  62.     }
  63.     public IEnumerator LevelUpCharacter(GameObject speedCharacter)
  64.     {
  65.         speedCharacter.GetComponent<UltimatePlayerMovement>().leftFollower.SetActive(true);
  66.         speedCharacter.GetComponent<UltimatePlayerMovement>().rightFollower.SetActive(true);
  67.        
  68.  
  69.         yield return null;
  70.     }
  71.  
  72.     //This is the team selections setup from LevelUpCore.cs for Character Level Up Sound Effects to be played in correct team order
  73.     //Team Sonic = 0
  74.     //Team Dark = 1
  75.     //Team Rose = 2
  76.     //Team Chaotix = 3
  77.    
  78.    
  79. }
  80.  
Add Comment
Please, Sign In to add comment