Advertisement
Guest User

Untitled

a guest
Mar 25th, 2019
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.58 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5.  
  6. public class Q001_Objective02 : MonoBehaviour {
  7.  
  8.     public float TheDistance;
  9.     public GameObject TreasureChest;
  10.     public GameObject ActionDisplay;
  11.     public GameObject ActionText;
  12.     public GameObject TheObjective;
  13.     public int CloseObjective;
  14.     public GameObject TakeSword;
  15.  
  16.     void Update () {
  17.         TheDistance = PlayerCasting.DistanceFromTarget;
  18.  
  19.         if(CloseObjective==3) {
  20.             if (TheObjective.transform.localScale.y <= 0.0f)
  21.             {
  22.                 CloseObjective = 0;
  23.                 TheObjective.SetActive(false);
  24.             }
  25.             else
  26.             {
  27.                 TheObjective.transform.localScale -= new Vector3(0.0f, 0.01f, 0.0f);
  28.             }
  29.         }
  30.     }
  31.  
  32.     void OnMouseOver() {
  33.         if(TheDistance<=3) {
  34.             ActionText.GetComponent<Text>().text = "Open Chest";
  35.             ActionText.SetActive(true);
  36.             ActionDisplay.SetActive(true);
  37.         }
  38.  
  39.         if (Input.GetButtonDown("Action")) {
  40.             if (TheDistance <= 3) {
  41.                 this.GetComponent<BoxCollider>().enabled = false;
  42.                 TreasureChest.GetComponent<Animation>().Play("Q01ChestOpen");
  43.                 TakeSword.SetActive(true);
  44.                 CloseObjective = 3;
  45.                 ActionText.SetActive(false);
  46.                 ActionDisplay.SetActive(false);
  47.             }
  48.         }
  49.     }
  50.  
  51.    void OnMouseExit() {
  52.         ActionDisplay.SetActive(false);
  53.         ActionText.SetActive(false);
  54.     }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement