FarmItem.cs 955 B

123456789101112131415161718192021222324252627282930313233
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class FarmItem : MonoBehaviour
  5. {
  6. public string lootDrop;
  7. public float farmingTime = 30f;
  8. public bool isAvailable = true;
  9. private void OnTriggerStay2D(Collider2D other) {
  10. if(other.tag == "Player"){
  11. //ui
  12. other.GetComponent<FarmManager>().ShowPopUp(this);
  13. }
  14. }
  15. private void OnTriggerExit2D(Collider2D other) {
  16. if(other.tag == "Player"){
  17. //
  18. Debug.Log("GameObject : " + gameObject);
  19. Debug.Log("active item : "+ other.GetComponent<FarmManager>().activeItem);
  20. if(other.GetComponent<FarmManager>().activeItem.gameObject == gameObject){
  21. other.GetComponent<FarmManager>().HidePopUp();
  22. Debug.Log("**** player exit from farm item ! ****");
  23. }
  24. }
  25. }
  26. public void Farm(){
  27. isAvailable = false;
  28. }
  29. }