using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Device_Switch : Device_Base
{
public bool isOpen;
///
/// 操作开关事件
///
private Action actionBack;
///
/// 添加开关操作回调
///
///
public void AddAction(Action actionBack)
{
this.actionBack = actionBack;
}
protected override void OnMDown()
{
base.OnMDown();
if ((triggerAction == null ? 0 : triggerAction.Invoke(triggerName, true)) == 0)
{
if (isOpen)
{
isOpen = false;
transform.localEulerAngles = new Vector3(0, 45, 0);
}
else
{
isOpen = true;
transform.localEulerAngles = new Vector3(0, 0, 0);
}
//调用自定义事件
if (actionBack != null)
{
actionBack.Invoke(isOpen);
}
}
}
///
/// 开关打开状态
///
public void OpenState()
{
isOpen = true;
transform.localEulerAngles = new Vector3(0, 0, 0);
}
///
/// 开关关闭状态
///
public void CloseState()
{
isOpen = false;
transform.localEulerAngles = new Vector3(0, 45, 0);
}
}