Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine;
- public class DoorCellDistance : MonoBehaviour
- {
- public float TheDistance;
- public GameObject ActionDisplay;
- public GameObject ActionText;
- public GameObject TheDoor;
- public AudioSource CreakSound;
- public AudioSource CreakSoundClose;
- void Update()
- {
- TheDistance = PlayerCasting.DistanceFromTarget;
- }
- void OnMouseOver()
- {
- if (TheDistance <= 1)
- {
- ActionDisplay.SetActive(true);
- ActionText.SetActive(true);
- }
- if (Input.GetButtonDown("Action"))
- {
- if (TheDistance <= 1)
- {
- this.GetComponent<BoxCollider>().enabled = false;
- ActionDisplay.SetActive(false);
- ActionText.SetActive(false);
- TheDoor.GetComponent<Animation> ().Play ("DoorOpen001");
- CreakSound.Play();
- StartCoroutine(DoorClose());
- }
- }
- }
- void OnMouseExit()
- {
- ActionDisplay.SetActive(false);
- ActionText.SetActive(false);
- }
- IEnumerator DoorClose ()
- {
- yield return new WaitForSeconds(7);
- TheDoor.GetComponent<Animation>().Play("DoorClose001");
- CreakSoundClose.Play();
- yield return new WaitForSeconds(0);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement