85 lines
2.4 KiB
C#
85 lines
2.4 KiB
C#
using DG.Tweening;
|
|
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
/// <summary>
|
|
/// 导电片
|
|
/// </summary>
|
|
public class Device_ConductiveSheet : Device_Base
|
|
{
|
|
public bool isClose;
|
|
/// <summary>
|
|
/// 铁片固定扳手螺丝
|
|
/// </summary>
|
|
public Tool_SpannerScrew screw;
|
|
/// <summary>
|
|
///低压电流互感器安装触发区
|
|
/// </summary>
|
|
public DeviceTrigger LowVoltageCurrentTransformer_Trigger;
|
|
/// <summary>
|
|
/// 低压电流互感器
|
|
/// </summary>
|
|
public Device_LowVoltageCurrentTransformer transformer;
|
|
|
|
/// <summary>
|
|
/// 合闸关闸回调
|
|
/// </summary>
|
|
public Action<bool> openOrCloseAction;
|
|
protected override void OnMDown()
|
|
{
|
|
base.OnMDown();
|
|
|
|
if (!screw.isInstall)
|
|
{
|
|
if ((triggerAction == null ? 0 : triggerAction.Invoke(triggerName, true)) == 0)
|
|
{
|
|
if (isClose)
|
|
{
|
|
//打开
|
|
transform.DOLocalRotate(new Vector3(90, 0, 25), 0.5f).OnComplete(() =>
|
|
{
|
|
isClose = false;
|
|
openOrCloseAction?.Invoke(isClose);
|
|
base.CallScoreAction(false);
|
|
});
|
|
}
|
|
else
|
|
{
|
|
//合上
|
|
transform.DOLocalRotate(new Vector3(90, 0, 0), 0.5f).OnComplete(() =>
|
|
{
|
|
isClose = true;
|
|
openOrCloseAction?.Invoke(isClose);
|
|
base.CallScoreAction(true);
|
|
});
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 直接设置开关状态
|
|
/// </summary>
|
|
/// <param name="isClose"></param>
|
|
public void SetState(bool isClose)
|
|
{
|
|
this.isClose = isClose;
|
|
if(isClose)
|
|
{
|
|
//合上状态
|
|
transform.localEulerAngles = new Vector3(90, 0, 0);
|
|
screw.isInstall = true;
|
|
screw.transform.localPosition = new Vector3(screw.transform.localPosition.x, screw.initPostionY, screw.transform.localPosition.z);
|
|
}
|
|
else
|
|
{
|
|
//打开状态
|
|
transform.localEulerAngles = new Vector3(90, 0, 25);
|
|
screw.isInstall = false;
|
|
screw.transform.localPosition = new Vector3(screw.transform.localPosition.x, screw.initPostionY- 0.03f, screw.transform.localPosition.z);
|
|
}
|
|
}
|
|
}
|