CoinPickup.cs 717 B

12345678910111213141516171819202122232425262728293031323334353637
  1. using System.Collections;
  2. using UnityEngine;
  3. namespace ZenFulcrum.EmbeddedBrowser {
  4. /** Game-specific logic for picking up coins. */
  5. public class CoinPickup : MonoBehaviour {
  6. private Transform coinVis;
  7. public float spinSpeed = 20;
  8. public bool isMassive = false;
  9. public void Start() {
  10. coinVis = transform.Find("Vis");
  11. }
  12. public void Update() {
  13. coinVis.transform.rotation *= Quaternion.AngleAxis(Time.deltaTime * spinSpeed, Vector3.up);
  14. }
  15. public void OnTriggerEnter(Collider other) {
  16. var inventory = other.GetComponent<PlayerInventory>();
  17. if (!inventory) return;
  18. if (isMassive) {
  19. HUDManager.Instance.LoadBrowseLevel();
  20. } else {
  21. inventory.AddCoin();
  22. }
  23. Destroy(gameObject);
  24. }
  25. }
  26. }