79 lines
1.8 KiB
C#
79 lines
1.8 KiB
C#
using DG.Tweening;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using Unity.VisualScripting.Antlr3.Runtime;
|
|
using UnityEngine;
|
|
|
|
/// <summary>
|
|
/// 接线盖子
|
|
/// </summary>
|
|
public class Device_Cover : Device_Base
|
|
{
|
|
/// <summary>
|
|
/// 盖子是否已打开
|
|
/// </summary>
|
|
public bool isOpen;
|
|
/// <summary>
|
|
/// 是否检查接线完好
|
|
/// </summary>
|
|
public bool isCheckOK;
|
|
|
|
|
|
[Tooltip("左盖子螺丝")]
|
|
public Tool_Screw cover_screw_Left;
|
|
[Tooltip("右盖子螺丝")]
|
|
public Tool_Screw cover_screw_Right;
|
|
[Tooltip("左盖子封印")]
|
|
public Device_Seal cover_seal_Left;
|
|
[Tooltip("右盖子封印")]
|
|
public Device_Seal cover_seal_Right;
|
|
|
|
private void OnMouseDown()
|
|
{
|
|
if ((triggerAction == null ? 0 : triggerAction.Invoke(triggerName, false)) == 0)
|
|
{
|
|
isCheckOK = true;
|
|
|
|
if (!isOpen)
|
|
{
|
|
if (!cover_screw_Left.isInstall && !cover_screw_Right.isInstall)
|
|
{
|
|
Open();
|
|
}
|
|
}
|
|
else if (isOpen)
|
|
{
|
|
Close();
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 打开盖子
|
|
/// </summary>
|
|
public void Open()
|
|
{
|
|
Debug.Log("打开盖子");
|
|
isOpen = true;
|
|
transform.DOLocalMoveY(-0.1388763f, 2);
|
|
transform.DOLocalMoveZ(-0.2485413f, 2).OnComplete(() =>
|
|
{
|
|
int result = (triggerAction == null ? 0 : triggerAction.Invoke(triggerName, true));
|
|
});
|
|
}
|
|
|
|
/// <summary>
|
|
/// 盖上盖子
|
|
/// </summary>
|
|
public void Close()
|
|
{
|
|
Debug.Log("盖上盖子");
|
|
isOpen = false;
|
|
transform.DOLocalMoveY(0.01112366f, 2);
|
|
transform.DOLocalMoveZ(-0.09854126f, 2).OnComplete(() =>
|
|
{
|
|
int result = (triggerAction == null ? 0 : triggerAction.Invoke(triggerName, true));
|
|
});
|
|
}
|
|
}
|