820 lines
28 KiB
C#
820 lines
28 KiB
C#
using HighlightPlus;
|
|
using Sirenix.Utilities;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using UnityEngine;
|
|
|
|
/// <summary>
|
|
/// 10002_2002_计量装置轮换
|
|
/// </summary>
|
|
public class Device_Control_2002 : Device_Control
|
|
{
|
|
/// <summary>
|
|
/// 当前机柜中安装的三相四线电能表
|
|
/// </summary>
|
|
public Device_3Phase4WireMeter meteringDevice;
|
|
/// <summary>
|
|
/// 插座
|
|
/// </summary>
|
|
public Device_Socket socket;
|
|
/// <summary>
|
|
/// 进线开关
|
|
/// </summary>
|
|
public Device_Switch inSwitch;
|
|
/// <summary>
|
|
/// 出线开关
|
|
/// </summary>
|
|
public Device_Switch outSwitch;
|
|
/// <summary>
|
|
/// 2p开关
|
|
/// </summary>
|
|
public Device_Switch p2Switch;
|
|
/// <summary>
|
|
/// 电能表接线
|
|
/// </summary>
|
|
public List<Tool_Line> jieXian_lines;
|
|
|
|
/// <summary>
|
|
/// 电能表碰撞
|
|
/// </summary>
|
|
public DeviceTrigger dianTrigger;
|
|
/// <summary>
|
|
/// 电能表安装完成后的杂物
|
|
/// </summary>
|
|
public Device_Sundries sundries;
|
|
/// <summary>
|
|
/// 进线开关螺丝
|
|
/// </summary>
|
|
public List<Tool_Screw> inSwitchScrews;
|
|
/// <summary>
|
|
/// 出线开关螺丝
|
|
/// </summary>
|
|
public List<Tool_Screw> outSwitchScrews;
|
|
/// <summary>
|
|
/// 2p开关螺丝
|
|
/// </summary>
|
|
public List<Tool_Screw> p2SwitchScrews;
|
|
|
|
#region 柜门
|
|
/// <summary>
|
|
/// 柜门螺丝
|
|
/// </summary>
|
|
public Tool_Screw door_screw;
|
|
/// <summary>
|
|
/// 柜门
|
|
/// </summary>
|
|
public ClickMove cabinetDoor;
|
|
/// <summary>
|
|
/// 柜门封印
|
|
/// </summary>
|
|
public Device_Seal door_seal;
|
|
/// <summary>
|
|
/// 柜门封印触发区域
|
|
/// </summary>
|
|
public DeviceTrigger door_seal_trigger;
|
|
/// <summary>
|
|
/// 柜门螺丝盖子
|
|
/// </summary>
|
|
public ClickRotate door_cover;
|
|
#endregion
|
|
/// <summary>
|
|
/// 采集器连线(黄,绿)
|
|
/// </summary>
|
|
public List<Tool_Line> collect_lines;
|
|
|
|
#region 围栏和工作牌
|
|
/// <summary>
|
|
/// 围栏放置触发区域
|
|
/// </summary>
|
|
public List<DeviceTrigger> trigger_weiLans;
|
|
/// <summary>
|
|
/// 放置的围栏
|
|
/// </summary>
|
|
public List<Tool_Fence> tool_Fences = new List<Tool_Fence>();
|
|
|
|
public DeviceTrigger workCard_从此进出_trigger;
|
|
public DeviceTrigger workCard_在此工作_trigger;
|
|
/// <summary>
|
|
/// 当前悬挂的工作牌
|
|
/// </summary>
|
|
public Tool_WorkCard_InAndOut current_workCard_InAndOut;
|
|
/// <summary>
|
|
/// 当前悬挂的工作牌
|
|
/// </summary>
|
|
public Tool_WorkCard_workthere current_workCard_Workthere;
|
|
#endregion
|
|
|
|
|
|
|
|
private void Awake()
|
|
{
|
|
//设置控制脚本
|
|
StepStateControl.instance?.SetDeviceControl(2002, this);
|
|
ScoreManager.instance?.SetDeviceControl(2002, this);
|
|
|
|
AddActions();
|
|
|
|
sundries.gameObject.SetActive(false);
|
|
|
|
//设置验电角度
|
|
meteringDevice.jieXian_screws.ForEach(screw =>
|
|
{
|
|
//改变验电角度
|
|
screw.TestPenAng = screw.installPos.localEulerAngles + new Vector3(0, 180, 0);
|
|
});
|
|
|
|
//添加电能表区域点击事件
|
|
dianTrigger.clickAction += () =>
|
|
{
|
|
if (meteringDevice == null)
|
|
{
|
|
//安装电能表
|
|
if (LiveSceneManager.Instance.currentTool != null && LiveSceneManager.Instance.currentTool.name.Contains("三相四线费控智能电能表"))
|
|
{
|
|
Device_3Phase4WireMeter meter = LiveSceneManager.Instance.currentTool.GetComponent<Device_3Phase4WireMeter>();
|
|
if (!meter.isMoving)
|
|
{
|
|
if (GameManager.ProcessMgr?.IsRightSubProcessStepsTriggerID(dianTrigger.triggerName, false) == 0)
|
|
{
|
|
//修改盖子打开位置
|
|
meter.cover.openLocalPos = new Vector3(0.295f, 0.121f, -0.067f);
|
|
//安装
|
|
meter.Add(dianTrigger, new Vector3(-0.02999878f, -0.028f, 0.168f), isinstall =>
|
|
{
|
|
if (isinstall)
|
|
{
|
|
meteringDevice = meter;
|
|
meteringDevice.screemControl.ShowPanel(new List<ScreenType> { ScreenType.时间, ScreenType.电量正向有功谷, ScreenType.电量正向有功峰, ScreenType.电量正向有功总 });
|
|
//接线关联螺丝
|
|
SetLineScrew();
|
|
//添加螺丝拆装回调
|
|
meteringDevice.jieXian_screws.ForEach(screw =>
|
|
{
|
|
screw.AddinstallAction(isinstalled =>
|
|
{
|
|
//刷新带电状态
|
|
CheckHasElectricity();
|
|
});
|
|
|
|
//改变验电角度
|
|
screw.TestPenAng = screw.installPos.localEulerAngles + new Vector3(0, 180, 0); ;
|
|
});
|
|
//固定螺丝回调
|
|
meteringDevice.fix_screw_left.AddinstallAction(isinstall => { Check电能表TriggerShow(); });
|
|
meteringDevice.fix_screw_right.AddinstallAction(isinstall => { Check电能表TriggerShow(); });
|
|
//刷新带电状态
|
|
CheckHasElectricity();
|
|
//打分
|
|
dianTrigger.CallScoreAction(true);
|
|
}
|
|
});
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (!meteringDevice.isMoving)
|
|
{
|
|
if (GameManager.ProcessMgr?.IsRightSubProcessStepsTriggerID(dianTrigger.triggerName, false) == 0)
|
|
{
|
|
//拆下电能表
|
|
meteringDevice.Remove(a =>
|
|
{
|
|
if (a)
|
|
{
|
|
//拆下场景中自带的电能表才显示杂物
|
|
if (meteringDevice.name == "原三相四线费控智能电能表")
|
|
{
|
|
sundries.gameObject.SetActive(true);
|
|
}
|
|
meteringDevice = null;
|
|
//情况接线关联螺丝
|
|
ClearLineScrew();
|
|
GameManager.ProcessMgr?.IsRightSubProcessStepsTriggerID(dianTrigger.triggerName, true);
|
|
//打分
|
|
dianTrigger.CallScoreAction(false);
|
|
}
|
|
});
|
|
}
|
|
}
|
|
}
|
|
};
|
|
|
|
//柜门封印触发区点击事件
|
|
door_seal_trigger.clickAction += () =>
|
|
{
|
|
//安装封印
|
|
if (door_screw.isInstall && !door_cover.isOpen)//HQB 33 BUG
|
|
{
|
|
if (GameManager.ProcessMgr == null || GameManager.ProcessMgr.IsRightSubProcessStepsTriggerID(door_seal_trigger.name, true) == 0)
|
|
{
|
|
door_seal.Install();
|
|
door_seal_trigger.gameObject.SetActive(false);
|
|
}
|
|
}
|
|
};
|
|
}
|
|
|
|
private void Start()
|
|
{
|
|
base.hasInit = true;
|
|
//注册工具拿出和收回,显示隐藏物体的封印的触发
|
|
EventCenter.Instance.AddEventListener<GameObject>(Enum_EventType.TakeOutAndRetrievingTheTools, OnHandTool);
|
|
}
|
|
private void OnDestroy()
|
|
{
|
|
EventCenter.Instance.RemoveEventListener<GameObject>(Enum_EventType.TakeOutAndRetrievingTheTools, OnHandTool);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 添加各种操作回调
|
|
/// </summary>
|
|
public void AddActions()
|
|
{
|
|
#region 柜门
|
|
//柜门螺丝盖子打开条件
|
|
door_cover.canOpen += () =>
|
|
{
|
|
return door_seal.isCut;
|
|
};
|
|
|
|
//柜门打开条件
|
|
cabinetDoor.canOpen += () =>
|
|
{
|
|
return !door_screw.isInstall;
|
|
};
|
|
|
|
//柜门螺丝条件
|
|
door_screw.AddCheckAction(() =>
|
|
{
|
|
return door_seal.isCut && door_cover.isOpen && !cabinetDoor.isOpen;
|
|
});
|
|
|
|
#endregion
|
|
|
|
#region 围栏和工作牌
|
|
trigger_weiLans.ForEach(a => a.Awake());
|
|
workCard_从此进出_trigger.Awake();
|
|
workCard_在此工作_trigger.Awake();
|
|
|
|
workCard_从此进出_trigger.clickAction += () =>
|
|
{
|
|
if (current_workCard_InAndOut == null && LiveSceneManager.Instance.currentTool != null && LiveSceneManager.Instance.currentTool.name == "工作牌_从此进出")
|
|
{
|
|
current_workCard_InAndOut = LiveSceneManager.Instance.currentTool.GetComponent<Tool_WorkCard_InAndOut>();
|
|
current_workCard_InAndOut.Add(workCard_从此进出_trigger);
|
|
}
|
|
};
|
|
|
|
workCard_在此工作_trigger.clickAction += () =>
|
|
{
|
|
if (current_workCard_Workthere == null && LiveSceneManager.Instance.currentTool != null && LiveSceneManager.Instance.currentTool.name == "工作牌_在此工作")
|
|
{
|
|
current_workCard_Workthere = LiveSceneManager.Instance.currentTool.GetComponent<Tool_WorkCard_workthere>();
|
|
current_workCard_Workthere.Add(workCard_在此工作_trigger);
|
|
}
|
|
};
|
|
|
|
//围栏触发
|
|
trigger_weiLans.ForEach(trigger =>
|
|
{
|
|
trigger.clickAction += () =>
|
|
{
|
|
Tool_Fence fence = LiveSceneManager.Instance.currentTool.GetComponent<Tool_Fence>();
|
|
if (fence != null && !fence.isMoving)
|
|
{
|
|
fence.Install(trigger, isinstalled =>
|
|
{
|
|
if (isinstalled)
|
|
{
|
|
tool_Fences.Add(fence);
|
|
CheckWeiLanTriggerShow();
|
|
}
|
|
else
|
|
{
|
|
tool_Fences.Remove(fence);
|
|
}
|
|
});
|
|
}
|
|
};
|
|
});
|
|
#endregion
|
|
|
|
//拿隔离板需要取下接线
|
|
meteringDevice.isolationBoard.canOpen += () => { return collect_lines.All(a => !a.isConnected); };
|
|
|
|
//开关回调
|
|
inSwitch.AddAction(isopen =>
|
|
{
|
|
//刷新带点状态
|
|
CheckHasElectricity();
|
|
if (isopen)
|
|
{
|
|
//通电时,接线错误直接结束练习和考试
|
|
if (jieXian_lines.All(a => a.isConnected) && collect_lines.All(a => a.isConnected))
|
|
{
|
|
Debug.Log("接线全部正确");
|
|
}
|
|
else
|
|
{
|
|
Debug.Log("接线错误,直接结束练习");
|
|
GameManager.UIMgr.ShowPanel<UI_PracticeCompletedPanel>(E_UI_Layer.Mid, (p) =>
|
|
{
|
|
p.Init("电能表未接线,本次实训失败!");
|
|
});
|
|
GameManager.EventMgr.EventTrigger(Enum_EventType.Submit);
|
|
}
|
|
}
|
|
});
|
|
outSwitch.AddAction(isOpen => { CheckHasElectricity(); });
|
|
p2Switch.AddAction(isOpen => { CheckHasElectricity(); });
|
|
|
|
//添加通电检查
|
|
inSwitch.AddCheckAction(() =>
|
|
{
|
|
if (!inSwitch.isOpen)
|
|
{
|
|
//关打开开关检查接线
|
|
if (inSwitch.triggerAction?.Invoke(inSwitch.triggerName, false) == 0)
|
|
{
|
|
GameManager.UIMgr.ShowPanel<UI_MessagePanel>(E_UI_Layer.System, (p) =>
|
|
{
|
|
p.Init("提示", "请确认是否接线完好?", E_MessageType.Error, () =>
|
|
{
|
|
//if (inSwitch.triggerAction?.Invoke(inSwitch.triggerName, true) == 0)
|
|
//{
|
|
inSwitch.triggerAction?.Invoke(inSwitch.triggerName, true);
|
|
TipPanel.ShowTip("电能表接线完好!");
|
|
//触发接线检查trigger
|
|
if (inSwitch.triggerAction?.Invoke("接线检查", true) == 0)
|
|
{
|
|
inSwitch.MyClick();
|
|
}
|
|
//}
|
|
});
|
|
});
|
|
}
|
|
|
|
return false;
|
|
}
|
|
else
|
|
{
|
|
return true;
|
|
}
|
|
});
|
|
//添加通电检查
|
|
outSwitch.AddCheckAction(() =>
|
|
{
|
|
if (outSwitch.isOpen)
|
|
{
|
|
//关闭开关检查接线
|
|
if (outSwitch.triggerAction?.Invoke(outSwitch.triggerName, false) == 0)
|
|
{
|
|
GameManager.UIMgr.ShowPanel<UI_MessagePanel>(E_UI_Layer.System, (p) =>
|
|
{
|
|
p.Init("提示", "请确认是否接线完好?", E_MessageType.Error, () =>
|
|
{
|
|
//if (outSwitch.triggerAction?.Invoke(outSwitch.triggerName, true) == 0)
|
|
//{
|
|
outSwitch.triggerAction?.Invoke(outSwitch.triggerName, true);
|
|
TipPanel.ShowTip("电能表接线完好!");
|
|
//触发接线检查trigger
|
|
if (outSwitch.triggerAction?.Invoke("接线检查", true) == 0)
|
|
{
|
|
outSwitch.MyClick();
|
|
}
|
|
//}
|
|
});
|
|
});
|
|
}
|
|
|
|
return false;
|
|
}
|
|
else
|
|
{
|
|
return true;
|
|
}
|
|
});
|
|
|
|
//添加螺丝拆装回调
|
|
meteringDevice.jieXian_screws.ForEach(screw =>
|
|
{
|
|
screw.AddinstallAction(isinstalled =>
|
|
{
|
|
//刷新带电状态
|
|
CheckHasElectricity();
|
|
});
|
|
});
|
|
|
|
//接线连接和取下回调,判断回调
|
|
jieXian_lines.ForEach(line =>
|
|
{
|
|
//无电能表不可移动
|
|
line.AddCanMoveCheck(() => { return meteringDevice != null; });
|
|
|
|
line.AddCompleteAction(isConnected =>
|
|
{
|
|
//刷新带点状态
|
|
CheckHasElectricity();
|
|
});
|
|
});
|
|
|
|
//开关螺丝不可拆卸
|
|
inSwitchScrews.ForEach(a =>
|
|
{
|
|
a.AddCheckAction(() =>
|
|
{
|
|
//提示不可拆
|
|
TipPanel.ShowTip("当前螺丝不可拆卸!");
|
|
return false;
|
|
});
|
|
});
|
|
|
|
//接线操作触发
|
|
jieXian_lines.ForEach(line =>
|
|
{
|
|
line.AddCompleteAction(isconnect => { Check电能表TriggerShow(); });
|
|
});
|
|
|
|
//采集器黄线绿线影响电能表拆卸
|
|
collect_lines.ForEach(line =>
|
|
{
|
|
line.AddCompleteAction(isconnect => { Check电能表TriggerShow(); });
|
|
});
|
|
}
|
|
|
|
/// <summary>
|
|
/// 还原计量柜状态
|
|
/// </summary>
|
|
public void Init()
|
|
{
|
|
//还原三相四线电能表
|
|
if (meteringDevice == null)
|
|
{
|
|
meteringDevice = GameObject.Instantiate<GameObject>(Resources.Load<GameObject>("Prefabs/Objects/Tools/三相四线费控智能电能表")).GetComponent<Device_3Phase4WireMeter>();
|
|
meteringDevice.cover.openLocalPos = new Vector3(0.295f, 0.121f, -0.067f);
|
|
meteringDevice.transform.GetComponent<BoxCollider>().enabled = false;
|
|
meteringDevice.SetAddState(dianTrigger, new Vector3(-0.02999878f, -0.028f, 0.168f));
|
|
meteringDevice.screemControl.ShowPanel(new List<ScreenType> { ScreenType.时间, ScreenType.电量正向有功谷, ScreenType.电量正向有功峰, ScreenType.电量正向有功总 });
|
|
//接线关联螺丝
|
|
SetLineScrew();
|
|
//添加螺丝拆装回调
|
|
meteringDevice.jieXian_screws.ForEach(screw =>
|
|
{
|
|
screw.AddinstallAction(isinstalled =>
|
|
{
|
|
//刷新带电状态
|
|
CheckHasElectricity();
|
|
});
|
|
|
|
//改变验电角度
|
|
screw.TestPenAng = screw.installPos.localEulerAngles + new Vector3(0, 180, 0); ;
|
|
});
|
|
//固定螺丝回调
|
|
meteringDevice.fix_screw_left.AddinstallAction(isinstall => { Check电能表TriggerShow(); });
|
|
meteringDevice.fix_screw_right.AddinstallAction(isinstall => { Check电能表TriggerShow(); });
|
|
|
|
}
|
|
meteringDevice.gameObject.name = "原三相四线费控智能电能表";
|
|
meteringDevice.Init(true);
|
|
meteringDevice.isolationBoard.SetState(false);
|
|
//设置电表屏显未轮换值
|
|
meteringDevice.screemControl.SetValue(ScreenType.电量正向有功总, "891.34");
|
|
meteringDevice.screemControl.SetValue(ScreenType.电量正向有功峰, "833.08");
|
|
meteringDevice.screemControl.SetValue(ScreenType.电量正向有功谷, "58.26");
|
|
|
|
//还原柜门
|
|
cabinetDoor.SetState(false);
|
|
door_cover.SetState(false);
|
|
door_screw.isInstall = true;
|
|
door_screw.transform.localPosition = new Vector3(door_screw.transform.localPosition.x, door_screw.initPostionY, door_screw.transform.localPosition.z);
|
|
door_seal.isCut = false;
|
|
door_seal.gameObject.SetActive(true);
|
|
|
|
//还原插座
|
|
|
|
//还原开关
|
|
inSwitch.OpenState();
|
|
outSwitch.OpenState();
|
|
p2Switch.OpenState();
|
|
|
|
//还原电能表接线
|
|
jieXian_lines.ForEach(line =>
|
|
{
|
|
line.SetConenctState(true);
|
|
});
|
|
//还原集线器的线
|
|
collect_lines.ForEach(line =>
|
|
{
|
|
line.SetConenctState(true);
|
|
});
|
|
//还原杂物
|
|
sundries.gameObject.SetActive(false);
|
|
|
|
//删除围栏
|
|
tool_Fences.ForEach(fence =>
|
|
{
|
|
if (fence != null)
|
|
DestroyImmediate(fence.gameObject);
|
|
});
|
|
tool_Fences.Clear();
|
|
|
|
//删除工作牌
|
|
if (current_workCard_InAndOut != null)
|
|
{
|
|
DestroyImmediate(current_workCard_InAndOut.gameObject);
|
|
current_workCard_InAndOut = null;
|
|
}
|
|
if (current_workCard_Workthere != null)
|
|
{
|
|
DestroyImmediate(current_workCard_Workthere.gameObject);
|
|
current_workCard_Workthere = null;
|
|
}
|
|
|
|
//刷新验电状态
|
|
CheckHasElectricity();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 清空接线的螺丝参数
|
|
/// </summary>
|
|
public void ClearLineScrew()
|
|
{
|
|
Debug.Log("清除接线关联的螺丝");
|
|
jieXian_lines.ForEach(a =>
|
|
{
|
|
a.screws.Clear();
|
|
});
|
|
}
|
|
/// <summary>
|
|
/// 设置接线的螺丝参数
|
|
/// </summary>
|
|
public void SetLineScrew()
|
|
{
|
|
Debug.Log("接线重新关联螺丝");
|
|
jieXian_lines.ForEach(a =>
|
|
{
|
|
a.screws = meteringDevice.jieXian_screws.FindAll(b => b.gameObject.name.StartsWith(a.gameObject.name.Replace("线", "")));
|
|
if (a.screws == null || a.screws.Count == 0)
|
|
{
|
|
Debug.LogError("接线未找到对应螺丝");
|
|
}
|
|
});
|
|
}
|
|
|
|
/// <summary>
|
|
/// 刷新电能表螺丝带电状态
|
|
/// </summary>
|
|
public void CheckHasElectricity()
|
|
{
|
|
Debug.Log("带电状态刷新");
|
|
//进线螺丝是否带电
|
|
jieXian_lines.ForEach(a =>
|
|
{
|
|
if (!inSwitch.isOpen)
|
|
{
|
|
//开关关闭不带电
|
|
a.screws.ForEach(b => b.hasElectricity = false);
|
|
}
|
|
else
|
|
{
|
|
//开关打开--线接上--螺丝拧上带电
|
|
if (!a.isConnected)
|
|
{
|
|
a.screws.ForEach(b => b.hasElectricity = false);
|
|
}
|
|
else
|
|
{
|
|
a.screws.ForEach(b =>
|
|
{
|
|
//安装了则
|
|
//零线无电流,有电压
|
|
if (b.triggerName.Contains("零"))
|
|
{
|
|
if (b != null)
|
|
b.hasElectricity = false;
|
|
}
|
|
else
|
|
{
|
|
if (b != null)
|
|
//其他的看是否上电
|
|
b.hasElectricity = b.isInstall;
|
|
}
|
|
});
|
|
}
|
|
}
|
|
});
|
|
//进电开关螺丝是否带电
|
|
inSwitchScrews.ForEach(a =>
|
|
{
|
|
if (a != null)
|
|
a.hasElectricity = inSwitch.isOpen;
|
|
});
|
|
//出线螺丝是否带电
|
|
outSwitchScrews.ForEach(a =>
|
|
{
|
|
if (!inSwitch.isOpen)
|
|
{
|
|
if (a != null)
|
|
a.hasElectricity = false;
|
|
}
|
|
else
|
|
{
|
|
if (a != null)
|
|
a.hasElectricity = outSwitch.isOpen;
|
|
}
|
|
});
|
|
//2p螺丝是否带电
|
|
p2SwitchScrews.ForEach(a =>
|
|
{
|
|
if (a != null)
|
|
a.hasElectricity = p2Switch.isOpen;
|
|
});
|
|
//电能表是否带电
|
|
if (meteringDevice != null)
|
|
meteringDevice.screemControl.hasElectricity = (inSwitch.isOpen && jieXian_lines.All(line => line.isConnected));
|
|
}
|
|
|
|
/// <summary>
|
|
/// 检查显示或隐藏封印触发器
|
|
/// </summary>
|
|
/// <param name="obj"></param>
|
|
private void OnHandTool(GameObject obj)
|
|
{
|
|
if (obj == null)
|
|
{
|
|
//收回
|
|
Debug.Log("收回");
|
|
door_seal_trigger.gameObject.SetActive(false);
|
|
CheckWeiLanTriggerShow();
|
|
Check从此进出工作牌Show();
|
|
Check在此工作工作牌Show();
|
|
Check围栏碰撞();
|
|
Check电能表TriggerShow();
|
|
}
|
|
else
|
|
{
|
|
//拿出
|
|
Debug.Log("拿出");
|
|
if (obj.name == "盒装封印")
|
|
{
|
|
if (!cabinetDoor.isOpen && door_seal.isCut && door_screw.isInstall)
|
|
door_seal_trigger.gameObject.SetActive(true);
|
|
}
|
|
else if (obj.name == "围栏")
|
|
{
|
|
CheckWeiLanTriggerShow();
|
|
}
|
|
else if (obj.name == "工作牌_在此工作")
|
|
{
|
|
Check在此工作工作牌Show();
|
|
}
|
|
else if (obj.name == "工作牌_从此进出")
|
|
{
|
|
Check从此进出工作牌Show();
|
|
Check围栏碰撞();
|
|
}
|
|
else if (obj.name == "三相四线费控智能电能表")
|
|
{
|
|
Check电能表TriggerShow();
|
|
}
|
|
else if (obj.name == "绝缘螺丝刀")
|
|
{
|
|
obj.GetComponent<Tool_Screwdriver>().AddStartAction(Check电能表TriggerShow);
|
|
obj.GetComponent<Tool_Screwdriver>().AddEndAction(Check电能表TriggerShow);
|
|
}
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 刷新围栏触发器显示隐藏状态
|
|
/// </summary>
|
|
private void CheckWeiLanTriggerShow()
|
|
{
|
|
trigger_weiLans.ForEach(weilan =>
|
|
{
|
|
if (weilan != null)
|
|
weilan.gameObject.SetActive(false);
|
|
//手里拿着围栏
|
|
if (LiveSceneManager.Instance.currentTool != null && LiveSceneManager.Instance.currentTool.name.Contains("围栏"))
|
|
{
|
|
//且未安装
|
|
if (tool_Fences.All(fence => !fence.triggerName.Contains(weilan.triggerName)))
|
|
{
|
|
if (GameManager.RunModelMgr.ModeType == E_ModeType.Study)
|
|
{
|
|
//学习模式只显示当前
|
|
if (ProcessManager.Instance.subProcessStepTriggerID == weilan.triggerName)
|
|
{
|
|
weilan.gameObject.SetActive(true);
|
|
return;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
//其他模式显示所有
|
|
weilan.gameObject.SetActive(true);
|
|
return;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
|
|
}
|
|
}
|
|
});
|
|
}
|
|
private void Check从此进出工作牌Show()
|
|
{
|
|
if (LiveSceneManager.Instance.currentTool != null && LiveSceneManager.Instance.currentTool.name.Contains("工作牌_从此进出"))
|
|
{
|
|
if (current_workCard_InAndOut == null)
|
|
{
|
|
workCard_从此进出_trigger.gameObject.SetActive(true);
|
|
return;
|
|
}
|
|
}
|
|
|
|
if (workCard_从此进出_trigger != null)
|
|
workCard_从此进出_trigger.gameObject.SetActive(false);
|
|
}
|
|
|
|
private void Check在此工作工作牌Show()
|
|
{
|
|
if (LiveSceneManager.Instance.currentTool != null && LiveSceneManager.Instance.currentTool.name.Contains("工作牌_在此工作"))
|
|
{
|
|
if (current_workCard_Workthere == null)
|
|
{
|
|
workCard_在此工作_trigger.gameObject.SetActive(true);
|
|
return;
|
|
}
|
|
}
|
|
|
|
if (workCard_在此工作_trigger != null)
|
|
workCard_在此工作_trigger.gameObject.SetActive(false);
|
|
}
|
|
private void Check围栏碰撞()
|
|
{
|
|
if (LiveSceneManager.Instance.currentTool != null && LiveSceneManager.Instance.currentTool.name == "工作牌_从此进出")
|
|
{
|
|
//围栏碰撞暂时隐藏,防止误触
|
|
tool_Fences.ForEach(fence =>
|
|
{
|
|
if (fence != null)
|
|
{
|
|
fence.transform.GetComponent<BoxCollider>().enabled = false;
|
|
}
|
|
});
|
|
}
|
|
else
|
|
{
|
|
//围栏碰撞暂时隐藏,防止误触
|
|
tool_Fences.ForEach(fence =>
|
|
{
|
|
if (fence != null)
|
|
fence.transform.GetComponent<BoxCollider>().enabled = true;
|
|
});
|
|
}
|
|
}
|
|
|
|
public void Check电能表TriggerShow()
|
|
{
|
|
if (meteringDevice == null)
|
|
{
|
|
//安装
|
|
if (LiveSceneManager.Instance.currentTool != null && LiveSceneManager.Instance.currentTool.name.Contains("三相四线费控智能电能表"))
|
|
{
|
|
dianTrigger.gameObject.SetActive(true);
|
|
Debug.Log("显示安装");
|
|
return;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
//拆除 (固定螺丝已拆除 且 所有接线已断开)
|
|
if (!meteringDevice.fix_screw_left.isInstall && !meteringDevice.fix_screw_right.isInstall)
|
|
{
|
|
//所有接线已断开 (接线和采集器黄绿线)
|
|
if (jieXian_lines.TrueForAll(a => !a.isConnected) && collect_lines.TrueForAll(a => !a.isConnected))
|
|
{
|
|
//螺丝刀不能在使用
|
|
if (LiveSceneManager.Instance.currentTool != null &&
|
|
LiveSceneManager.Instance.currentTool.GetComponent<Tool_Screwdriver>() != null &&
|
|
LiveSceneManager.Instance.currentTool.GetComponent<Tool_Screwdriver>().isMoving)
|
|
{
|
|
dianTrigger.gameObject.SetActive(false);
|
|
Debug.Log("螺丝刀在使用,不显示安装");
|
|
return;
|
|
}
|
|
dianTrigger.gameObject.SetActive(true);
|
|
Debug.Log("显示安装");
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
dianTrigger.gameObject.SetActive(false);
|
|
Debug.Log("不显示安装");
|
|
}
|
|
}
|