using DG.Tweening; using System.Collections; using System.Collections.Generic; using Cysharp.Threading.Tasks; using DefaultNamespace.ProcessMode; using MotionFramework; using UnityEngine; using UnityEngine.UI; using HighlightPlus; using UnityEngine.EventSystems; public class Fieldobservation : MonoBehaviour { public static Fieldobservation Instance; [Header("警告按钮")] /// /// 警告按钮 /// public Button ExclamationPointBtn; [Header("玩家相机")] /// /// 玩家相机 /// public Transform Cameraobj; [Header("上梯子后坐标")] /// /// 上梯子后坐标 /// public Transform UptheladderPos; [Header("透明盖子")] /// /// 透明盖子 /// public Transform Transparentover; [Header("柜门卡栓碰撞")] /// /// 柜门卡栓碰撞 /// public BoxCollider guimenkashuan; [Header("电箱门")] /// /// 电箱门 /// public GameObject guimen; [Header("门锁01")] /// /// 门锁01 /// public GameObject mensuo01; [Header("柜门box碰撞")] /// /// 柜门box碰撞 /// public BoxCollider guimenbox; [Header("透明盖子上的封印cube碰撞")] /// /// 透明盖子上的封印cube碰撞 /// public BoxCollider[] BOXseal; [Header("透明盖子上的两颗螺丝")] /// /// 透明盖子上的两颗螺丝 /// public GameObject[] screw; [Header("判断")] /// /// 判断是否在梯子上 /// public bool isPlayerOnLadder = false; /// /// 判断封印盒子是否在手上 /// bool isbox = true; bool isclick; //public GameObject fengy; private void Awake() { Instance = this; } //public HighlightEffect _highlight; void Start() { } void Update() { if (EventSystem.current.IsPointerOverGameObject()) return; 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 == "盖_透明外壳") { ParentOverSealAsync(); BOXseal[0].enabled = true; BOXseal[1].enabled = true; //isbox = false; guimen.GetComponent().enabled = true; } if (hit.collider.gameObject.name == "变电箱_门") { StartCoroutine(IEguimenkashuan()); //if (isbox) //{ guimenbox.GetComponent().enabled = false; isbox = false; // } MotionEngine.GetModule().HandleClick(hit.collider.gameObject.name); guimenbox.GetComponent().enabled = true; } } } } /// /// 玩家与物体碰撞 /// /// private void OnTriggerEnter(Collider other) { if (other.gameObject.name == "UptheladderPos") { isPlayerOnLadder = true; Debug.Log(other.name); //ladder.OnPersonClose(); } if (other.gameObject.name == "检测是否到达场景后拿取工具碰撞") { isPlayerOnLadder = false; Debug.Log(other.name); //ladder.OnPersonClose(); } } /// /// 玩家离开npc警告按钮消失 /// /// private void OnTriggerExit(Collider other) { if (other.name == "Man_stand") { ExclamationPointBtn.gameObject.SetActive(false); } } /// /// 透明外盖上的封印动画 /// /// public async UniTask ParentOverSealAsync() { Transparentover.transform.localPosition = new Vector3(0, 0, 0); await UniTask.Delay(1000); // 等待1秒 screw[0].SetActive(true); await UniTask.Delay(500); // 等待0.5秒 screw[0].transform.localPosition = new Vector3(-0.07357633f, -0.01137948f, 0.003414989f); screw[1].SetActive(true); await UniTask.Delay(1500); // 等待1.5秒 screw[1].transform.localPosition = new Vector3(0.07394123f, 0.013731f, 0.003414989f); MotionEngine.GetModule().HandleClick("盖_透明外壳"); } /// /// 点击柜门卡栓动画 /// /// IEnumerator IEguimenkashuan() { guimen.gameObject.transform.DOLocalRotate(new Vector3(-90, 0, 0), 1); yield return new WaitForSeconds(1.1f); mensuo01.gameObject.transform.DOLocalRotate(new Vector3(0, 0, 0), 1); guimenkashuan.gameObject.GetComponent().enabled = true; } public bool IsPlayerOnLadder() { return isPlayerOnLadder; } }