| 123456789101112131415161718192021222324252627282930313233343536373839404142 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class PowerDrop : MonoBehaviour
- {
- public float powerAmount = -100.0f;
- [SerializeField]
- private UnityEngine.UI.Text textField;
- private bool popped = false;
- void OnTriggerEnter(Collider other)
- {
- if (!popped)
- {
- if (other.tag == "Player")
- {
- other.GetComponent<Player>().PowerLevel += powerAmount;
- popped = true;
- Pop();
- }
- }
- }
- // Use this for initialization
- void Start()
- {
- textField.text = powerAmount.ToString();
- }
- // Update is called once per frame
- void Update()
- {
- }
- private void Pop()
- {
- GameObject.Destroy(gameObject);
- }
- }
|