using DG.Tweening;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
///
/// 柜门
///
public class Device_CabinetDoor : Device_Base
{
///
/// 验电位置
///
public Transform testPosAndRot;
///
/// 封印
///
public Device_Seal seal;
///
/// 是否打开
///
public bool isOpen;
///
/// 是否带点
///
public bool hasElectricity;
public void Open()
{
Debug.Log("开门");
//开锁
transform.Find("计量柜锁2/计量柜锁3").DOLocalRotate(new Vector3(-45f, 0, 0), 1).OnComplete(() =>
{
//开门
transform.DOLocalRotate(new Vector3(0, 0, 180), 3).OnComplete(() =>
{
isOpen = true;
});
});
}
public void Close()
{
Debug.Log("关门");
//关门
transform.DOLocalRotate(new Vector3(0,0,0), 3).OnComplete(() =>
{
//关锁
transform.Find("计量柜锁2/计量柜锁3").DOLocalRotate(new Vector3(0, 0, 0), 1).OnComplete(() =>
{
isOpen = false;
});
});
}
private void OnMouseDown()
{
if(seal.isCut)
{
if(isOpen)
{
Close();
}
else
{
Open();
}
}
}
}