using DG.Tweening; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class Fieldobservation : MonoBehaviour { /// /// 玩家相机 /// public Transform Cameraobj; /// /// 警告按钮 /// public Button ExclamationPointBtn; bool isclick; /// /// 上梯子后坐标 /// public Transform UptheladderPos; /// /// 打开封印 /// bool isOpenLock; /// /// 透明盖子 /// public Transform Transparentover; /// /// 透明盖子上的两颗螺丝 /// public GameObject[] screw; /// /// 判断封印盒子是否在手上 /// bool isbox = true; /// /// 透明盖子上的封印cube碰撞 /// public BoxCollider[] BOXseal; /// /// 柜门卡栓碰撞 /// public BoxCollider guimenkashuan; /// /// 透明盖子上的封印 /// public GameObject[] parentoverSeal; /// /// 电箱门 /// public GameObject guimen; /// /// 门锁01 /// public GameObject mensuo01; /// /// 柜门box碰撞 /// public BoxCollider guimenbox; void Start() { } void Update() { if (Input.GetMouseButtonDown(0)) { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; bool raycast = Physics.Raycast(ray, out hit); if (raycast) { if (hit.collider.gameObject.name == "盖_透明外壳") { StartCoroutine(IEparentoverSeal()); if (isbox) { BOXseal[0].enabled = true; BOXseal[1].enabled = true; isbox = false; } } if (hit.collider.gameObject.name == "透明盖子封印碰撞R") { if (isbox) { parentoverSeal[0].gameObject.SetActive(true); isbox = false; } } if (hit.collider.gameObject.name == "透明盖子封印碰撞L") { if (isbox) { parentoverSeal[1].gameObject.SetActive(true); guimenkashuan.enabled = true; isbox = false; } } if (hit.collider.gameObject.name == "柜门卡栓") { StartCoroutine(IEguimenkashuan()); if (isbox) { guimenbox.GetComponent().enabled = true; isbox = false; } } } } } /// /// 用户离开npc警告按钮消失 /// /// private void OnTriggerExit(Collider other) { if (other.name == "Man_stand") { ExclamationPointBtn.gameObject.SetActive(false); } } /// /// 透明外盖上的封印 /// /// IEnumerator IEparentoverSeal() { Transparentover.transform.DOLocalMove(new Vector3(-90f, 0, 0), 1f); yield return new WaitForSeconds(1); screw[0].gameObject.SetActive(true); Transparentover.transform.DOLocalMove(new Vector3(-90f, 0, 0), 1f); yield return new WaitForSeconds(1); screw[0].gameObject.SetActive(true); yield return new WaitForSeconds(0.5f); screw[0].gameObject.transform.DOLocalMove(new Vector3(-90f, 0, 0), 1f); screw[1].gameObject.SetActive(true); yield return new WaitForSeconds(0.5f); screw[1].gameObject.transform.DOLocalMove(new Vector3(-90f, 0, 0), 1f); } /// /// 点击柜门卡栓动画 /// /// IEnumerator IEguimenkashuan() { guimen.gameObject.transform.DOLocalMove(new Vector3(-90, 0, 0), 1); yield return new WaitForSeconds(1.1f); mensuo01.gameObject.transform.DOLocalMove(new Vector3(0, 0, 0), 1); } }