228 lines
8.3 KiB
C#
228 lines
8.3 KiB
C#
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<Transform> boxs = new List<Transform>();
|
|
/// <summary>
|
|
/// 是否已经打开了盒子
|
|
/// </summary>
|
|
public bool isClick = false;
|
|
/// <summary>
|
|
/// 是否已经上架到仓位
|
|
/// </summary>
|
|
public bool isUp = false;
|
|
/// <summary>
|
|
/// 是否已经播放完打开盒子动画
|
|
/// </summary>
|
|
public bool isover = true;
|
|
/// <summary>
|
|
/// 初始位置
|
|
/// </summary>
|
|
public Vector3 InitPos;
|
|
|
|
void Start()
|
|
{
|
|
InitPos = transform.position;
|
|
}
|
|
|
|
|
|
void Update()
|
|
{
|
|
if (MotionEngine.GetModule<ProcessManager>().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<BoxCollider>().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());
|
|
}
|
|
|
|
/// <summary>
|
|
/// 设置不同物资的旋转角度
|
|
/// </summary>
|
|
public IEnumerator SetMaritalRot()
|
|
{
|
|
isover = false;
|
|
if (MotionEngine.GetModule<GlobalDataStorage>().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<GlobalDataStorage>().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<GlobalDataStorage>().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<GlobalDataStorage>().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;
|
|
}
|
|
}
|
|
}
|
|
}
|