using DefaultNamespace; using DefaultNamespace.ProcessMode; using DG.Tweening; using MotionFramework; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.EventSystems; public class OpenBoxs : MonoBehaviour { public List boxs = new List(); /// /// 是否已经打开了盒子 /// public bool isClick = false; /// /// 是否已经上架到仓位 /// public bool isUp = false; /// /// 是否已经播放完打开盒子动画 /// public bool isover = true; /// /// 初始位置 /// public Vector3 InitPos; void Start() { InitPos = transform.position; } void Update() { if (MotionEngine.GetModule().GetCurrentActionTitle() == "物资上架" || InitPos != transform.position && !isUp) { // StartCoroutine(RotateBoxs(true)); if (boxs.Count == 1) { boxs[0].DOLocalRotateQuaternion(Quaternion.Euler(-90, -90, 90), 1.5f); isover = true; this.isClick = false; } else if (boxs.Count == 4) { boxs[2].DOLocalRotateQuaternion(Quaternion.Euler(-90, -90, 90), 1.5f); boxs[3].DOLocalRotateQuaternion(Quaternion.Euler(-90, 90, -90), 1.5f); boxs[0].DOLocalRotateQuaternion(Quaternion.Euler(-90, 0, 0), 1.5f); boxs[1].DOLocalRotateQuaternion(Quaternion.Euler(270, 0, 0), 1.5f); isover = true; this.isClick = false; } GetComponent().enabled = false; isUp = true; } } private void OnMouseDown() { if (EventSystem.current.IsPointerOverGameObject() || isUp) return; if (!isClick && isover) { RotateBoxs(); } else if (isClick && isover) { RotateBoxs(); } } void RotateBoxs() { #region //if (!isClick) //{ // if (boxs.Count == 1) // { // boxs[0].DOLocalRotateQuaternion(Quaternion.Euler(90, -90, 90), 1.5f); // yield return new WaitForSeconds(1.5f); // isover = true; // this.isClick = true; // } // else if (boxs.Count == 4) // { // boxs[0].DOLocalRotateQuaternion(Quaternion.Euler(90, 0, 0), 1.5f); // boxs[1].DOLocalRotate(new Vector3(-270, 0, 0), 1.5f); // yield return new WaitForSeconds(1.7f); // boxs[2].DOLocalRotateQuaternion(Quaternion.Euler(90, -90, 90), 1.5f); // boxs[3].DOLocalRotateQuaternion(Quaternion.Euler(90, 90, -90), 1.5f); // yield return new WaitForSeconds(1.7f); // isover = true; // this.isClick = true; // } //} //else //{ // if (boxs.Count == 1) // { // boxs[0].DOLocalRotateQuaternion(Quaternion.Euler(-90, -90, 90), 1.5f); // yield return new WaitForSeconds(1.5f); // isover = true; // this.isClick = false; // } // else if (boxs.Count == 4) // { // boxs[2].DOLocalRotateQuaternion(Quaternion.Euler(-90, -90, 90), 1.5f); // boxs[3].DOLocalRotateQuaternion(Quaternion.Euler(-90, 90, -90), 1.5f); // yield return new WaitForSeconds(1.7f); // boxs[0].DOLocalRotateQuaternion(Quaternion.Euler(-90, 0, 0), 1.5f); // boxs[1].DOLocalRotateQuaternion(Quaternion.Euler(270, 0, 0), 1.5f); // yield return new WaitForSeconds(1.7f); // isover = true; // this.isClick = false; // } //} #endregion StartCoroutine(SetMaritalRot()); } /// /// 设置不同物资的旋转角度 /// public IEnumerator SetMaritalRot() { isover = false; if (MotionEngine.GetModule().ExamName.Contains("三相隔离开关")) { if (!isClick) { boxs[0].DOLocalRotateQuaternion(Quaternion.Euler(90, 0, 0), 1.5f); boxs[1].DOLocalRotate(new Vector3(-270, 0, 0), 1.5f); yield return new WaitForSeconds(1.7f); boxs[2].DOLocalRotateQuaternion(Quaternion.Euler(90, -90, 90), 1.5f); boxs[3].DOLocalRotateQuaternion(Quaternion.Euler(90, 90, -90), 1.5f); yield return new WaitForSeconds(1.7f); isover = true; this.isClick = true; } else { boxs[2].DOLocalRotateQuaternion(Quaternion.Euler(-90, -90, 90), 1.5f); boxs[3].DOLocalRotateQuaternion(Quaternion.Euler(-90, 90, -90), 1.5f); yield return new WaitForSeconds(1.7f); boxs[0].DOLocalRotateQuaternion(Quaternion.Euler(-90, 0, 0), 1.5f); boxs[1].DOLocalRotateQuaternion(Quaternion.Euler(270, 0, 0), 1.5f); yield return new WaitForSeconds(1.7f); isover = true; this.isClick = false; } } if (MotionEngine.GetModule().ExamName.Contains("1KV电缆终端")) { if (!isClick) { boxs[0].DOLocalRotateQuaternion(Quaternion.Euler(90, -90, 90), 1.5f); yield return new WaitForSeconds(1.5f); isover = true; this.isClick = true; } else { boxs[0].DOLocalRotateQuaternion(Quaternion.Euler(-90, -90, 90), 1.5f); yield return new WaitForSeconds(1.5f); isover = true; this.isClick = false; } } if (MotionEngine.GetModule().ExamName.Contains("10KV电缆终端")) { if (!isClick) { boxs[0].DOLocalRotateQuaternion(Quaternion.Euler(90, 90, -90), 1.5f); boxs[1].DOLocalRotateQuaternion(Quaternion.Euler(90, -90, 90), 1.5f); yield return new WaitForSeconds(1.7f); boxs[3].DOLocalRotateQuaternion(Quaternion.Euler(90, 0, 0), 1.5f); boxs[2].DOLocalRotateQuaternion(Quaternion.Euler(-270, 0, 0), 1.5f); yield return new WaitForSeconds(1.7f); isover = true; this.isClick = true; } else { boxs[3].DOLocalRotateQuaternion(Quaternion.Euler(-90, 0, 0), 1.5f); boxs[2].DOLocalRotateQuaternion(Quaternion.Euler(-90, 0, 0), 1.5f); yield return new WaitForSeconds(1.7f); boxs[0].DOLocalRotateQuaternion(Quaternion.Euler(-90, 0, 0), 1.5f); boxs[1].DOLocalRotateQuaternion(Quaternion.Euler(-90, 0, 0), 1.5f); yield return new WaitForSeconds(1.7f); isover = true; this.isClick = false; } } if (MotionEngine.GetModule().ExamName.Contains("高压熔断器")) { if (!isClick) { boxs[0].DORotate(new Vector3(-270, 0, 0), 1.5f); boxs[1].DOLocalRotateQuaternion(Quaternion.Euler(90, 0, 0), 1.5f); yield return new WaitForSeconds(1.7f); boxs[2].DOLocalRotateQuaternion(Quaternion.Euler(90, -90, 90), 1.5f); boxs[3].DOLocalRotateQuaternion(Quaternion.Euler(90, 90, -90), 1.5f); yield return new WaitForSeconds(1.7f); isover = true; this.isClick = true; } else { boxs[3].DOLocalRotateQuaternion(Quaternion.Euler(-90, 0, 0), 1.5f); boxs[2].DOLocalRotateQuaternion(Quaternion.Euler(-90, 0, 0), 1.5f); yield return new WaitForSeconds(1.7f); boxs[0].DOLocalRotateQuaternion(Quaternion.Euler(270, 0, 0), 1.5f); boxs[1].DOLocalRotateQuaternion(Quaternion.Euler(-90, 0, 0), 1.5f); yield return new WaitForSeconds(1.7f); isover = true; this.isClick = false; } } } }