98 lines
3.2 KiB
C#
98 lines
3.2 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
/// <summary>
|
|
/// 计量存储柜控制脚本
|
|
/// </summary>
|
|
public class CabinetController : PermanentTriggerBase
|
|
{
|
|
public GameObject screenCanvas;//计量存储柜显示屏
|
|
public string SubProcessStepName;
|
|
public GameObject Obstacle;//遮挡物,关闭时候遮挡,防止东西被拿取
|
|
private List<string> triggerDevives = new List<string>();
|
|
|
|
protected override void OnMEnter()
|
|
{
|
|
base.OnMEnter();
|
|
if (GameManager.RunModelMgr.ModeType != E_ModeType.Study)
|
|
{
|
|
_highlight.SetHighlighted(true);
|
|
}
|
|
}
|
|
protected override void OnMExit()
|
|
{
|
|
if (GameManager.RunModelMgr.ModeType != E_ModeType.Study)
|
|
_highlight.SetHighlighted(false);
|
|
base.OnMExit();
|
|
}
|
|
|
|
protected override void OnMDown()
|
|
{
|
|
if (GameManager.RunModelMgr.ModeType == E_ModeType.Study)
|
|
if (GameManager.ProcessMgr.IsRightSubProcessStepsTriggerID(triggerName, false) == 1)
|
|
return;
|
|
_highlight.SetHighlighted(false);
|
|
screenCanvas.SetActive(!screenCanvas.activeInHierarchy);
|
|
if (screenCanvas.activeInHierarchy)
|
|
{
|
|
triggerDevives.Clear();
|
|
string relevantDevices = "";
|
|
foreach (var p in GameManager.ProcessMgr.d_Scheme.processes)
|
|
{
|
|
foreach(var sub in p.subProcesses)
|
|
{
|
|
foreach (var step in sub.subProcessStepes)
|
|
{
|
|
if (step.subProcessStepName == SubProcessStepName)
|
|
{
|
|
relevantDevices = step.triggerID;
|
|
break;
|
|
}
|
|
}
|
|
if (relevantDevices != "") break;
|
|
}
|
|
if (relevantDevices != "") break;
|
|
}
|
|
|
|
triggerDevives = new List<string>(relevantDevices.Split(','));
|
|
SingleBubbleCtrl[] sbcInScene = FindObjectsOfType<SingleBubbleCtrl>();
|
|
foreach (var item in sbcInScene)
|
|
{
|
|
if (item.targetDevice == null)
|
|
item.RecoverGameObject();
|
|
if (item.targetDevice == null || item.targetDevice.GetComponent<Tool_SelectComponent>() == null)
|
|
{
|
|
item.BubbleInit(false);
|
|
}
|
|
else
|
|
{
|
|
int index = triggerDevives.IndexOf(item.targetDevice.name);
|
|
if (index != -1)
|
|
{
|
|
item.BubbleInit(true);
|
|
triggerDevives.RemoveAt(index);
|
|
}
|
|
else
|
|
item.BubbleInit(false);
|
|
|
|
} //foreach (var item in UsableDevices)
|
|
}
|
|
}
|
|
GameManager.ProcessMgr.IsRightSubProcessStepsTriggerID(triggerName, true);
|
|
}
|
|
|
|
public void Init()
|
|
{
|
|
screenCanvas.SetActive(false);
|
|
SingleBubbleCtrl[] sbcInScene = FindObjectsOfType<SingleBubbleCtrl>();
|
|
foreach (var item in sbcInScene)
|
|
item.BubbleReset();
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
Obstacle.SetActive(!screenCanvas.activeInHierarchy);
|
|
}
|
|
}
|