90 lines
2.0 KiB
C#
90 lines
2.0 KiB
C#
using DG.Tweening;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using Unity.VisualScripting;
|
|
using UnityEngine;
|
|
|
|
/// <summary>
|
|
/// 直接接入式电能计量装置
|
|
/// </summary>
|
|
public class Device_DirectAccessElectricEnergyMeteringDevice : Device_Base
|
|
{
|
|
public static Device_DirectAccessElectricEnergyMeteringDevice instance;
|
|
/// <summary>
|
|
/// 是否已被拆除
|
|
/// </summary>
|
|
public bool isRemove;
|
|
/// <summary>
|
|
/// 铭牌
|
|
/// </summary>
|
|
public Device_NamePlate namePlate;
|
|
|
|
/// <summary>
|
|
/// 接线盖子
|
|
/// </summary>
|
|
public Device_Cover cover;
|
|
|
|
|
|
/// <summary>
|
|
/// 电能表接线
|
|
/// </summary>
|
|
[Tooltip("接线")]
|
|
public List<Tool_Line> jieXian_lines;
|
|
|
|
/// <summary>
|
|
/// 电能表固定螺丝左
|
|
/// </summary>
|
|
public Tool_Screw fix_screw_left;
|
|
/// <summary>
|
|
/// 电能表固定螺丝右
|
|
/// </summary>
|
|
public Tool_Screw fix_screw_right;
|
|
|
|
|
|
private BoxCollider boxCollider;
|
|
|
|
private void Awake()
|
|
{
|
|
instance = this;
|
|
boxCollider = GetComponent<BoxCollider>();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 拆下电能表
|
|
/// </summary>
|
|
public void Remove()
|
|
{
|
|
if (!isRemove)
|
|
{
|
|
//拆下电能表
|
|
if (!fix_screw_left.isInstall && !fix_screw_right.isInstall)
|
|
{
|
|
isRemove = true;
|
|
Debug.Log("电能表已拆除");
|
|
transform.DOLocalMove(transform.localPosition - new Vector3(0, 0.2f, 0.2f), 2).OnComplete(() =>
|
|
{
|
|
gameObject.SetActive(false);
|
|
});
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 安装电能表
|
|
/// </summary>
|
|
public void Add()
|
|
{
|
|
if(isRemove)
|
|
{
|
|
gameObject.SetActive(true);
|
|
transform.DOLocalMove(transform.localPosition + new Vector3(0, 0.2f, 0.2f), 2).OnComplete(() =>
|
|
{
|
|
isRemove = false;
|
|
Debug.Log("电能表已安装");
|
|
});
|
|
}
|
|
|
|
}
|
|
|
|
}
|