Advertisement
Guest User

Untitled

a guest
Jul 28th, 2018
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.78 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class PowerUpCM : MonoBehaviour {
  6.  
  7.     void OnTriggerEnter(Collider other)
  8.     {
  9.         if (other.gameObject.CompareTag("Player"))
  10.         {
  11.             StartCoroutine(CMPickup(other));
  12.         }
  13.     }
  14.  
  15.     IEnumerator CMPickup(Collider other)
  16.     {
  17.         Debug.Log("PowerUp Picked Up!");
  18.  
  19.         GameManager coins = other.gameObject.GetComponent<GameManager>();
  20.         coins.coinAmount *= FindObjectOfType<GameManager>().coinMultiplier;
  21.  
  22.         gameObject.SetActive(false);
  23.  
  24.         yield return new WaitForSeconds(FindObjectOfType<GameManager>().coinMultDuration);
  25.  
  26.         coins.coinAmount /= FindObjectOfType<GameManager>().coinMultiplier;
  27.  
  28.         Destroy(gameObject);
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement