78 lines
1.7 KiB
C#
78 lines
1.7 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class DeviceStateManage : MonoBehaviour
|
|
{
|
|
public static DeviceStateManage instance;
|
|
|
|
#region 断路器
|
|
public static List<DLQ> DLQs = new List<DLQ>();
|
|
public static LadderState ladder = new LadderState();
|
|
#endregion
|
|
|
|
private void Awake()
|
|
{
|
|
instance = this;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 更新设备状态
|
|
/// </summary>
|
|
/// <typeparam name="T"></typeparam>
|
|
/// <param name="_data"></param>
|
|
public static void UpdateDeviceState<T>(T _data)
|
|
{
|
|
switch (typeof(T).Name)
|
|
{
|
|
case "DLQ":
|
|
DLQ data = (DLQ)Convert.ChangeType(_data, typeof(DLQ));
|
|
DLQ tmp = DLQs.Find(x => x.Name.Equals(data.Name));
|
|
if (tmp == null)
|
|
{
|
|
DLQs.Add(data);
|
|
}
|
|
else
|
|
{
|
|
int index = DLQs.IndexOf(tmp);
|
|
DLQs[index] = data;
|
|
}
|
|
break;
|
|
case "LadderState":
|
|
LadderState templadder = (LadderState)Convert.ChangeType(_data,typeof(LadderState));
|
|
ladder = templadder;
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// 断路器设备
|
|
/// </summary>
|
|
public class DLQ
|
|
{
|
|
/// <summary>
|
|
/// 名称
|
|
/// </summary>
|
|
public string Name;
|
|
/// <summary>
|
|
/// 分合闸
|
|
/// </summary>
|
|
public bool Gate;
|
|
}
|
|
public class LadderState
|
|
{
|
|
/// <summary>
|
|
/// 是否在梯子上
|
|
/// </summary>
|
|
public bool state=false;
|
|
/// <summary>
|
|
/// 当前人物坐标
|
|
/// </summary>
|
|
public Vector3 currentFpcPos;
|
|
} |