Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2018
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1. enum CHEST {LOCKED, OPEN};
  2. private CHEST myChest = CHEST.LOCKED;
  3. private Animator anim;
  4. private Interactor ic;
  5. private GameManager gm;
  6. private GameObject key;
  7. public TextHints th;
  8. public GameObject potion;
  9. // Use this for initialization
  10. void Start () {
  11. anim = transform.parent.GetComponent<Animator>();
  12. ic = GetComponent<Interactor>();
  13. gm = GetComponent<GameManager>();
  14. key = GameObject.Find("KeyAtLock");
  15. }
  16.  
  17. // Update is called once per frame
  18. void Update () {
  19.  
  20. }
  21. private void OnMouseDown()
  22. {
  23. if(ic.WithinRange())
  24. {
  25. if (GameManager.HaveKey == true)
  26. {
  27. transform.parent.GetChild(2).gameObject.SetActive(true);
  28. anim.SetBool("OpenChest", true);
  29. myChest = CHEST.OPEN;
  30. Invoke("delay", 1);
  31. }
  32. else
  33. {
  34. print("Find a key");
  35. th.DisplayHint2();
  36. }
  37. }
  38. else
  39. {
  40. anim.SetBool("OpenChest", false);
  41. myChest = CHEST.LOCKED;
  42. }
  43. }
  44.  
  45. private void delay()
  46. {
  47. potion.SetActive(true);
  48. }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement