上海虹口龙之梦项目
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

122 lines
4.0 KiB

using UnityEngine;
using UnityEngine.UI;
using UniRx;
public class CreationPanel : UIView
{
public Text TitleText;
public Toggle CreateToggle;
public Button SaveButton;
public Button ClearButton;
public override void Awake()
{
base.Awake();
//创建
CreateToggle.OnValueChangedAsObservable()
.Subscribe(value => CloneObject(value)).AddTo(gameObject);
ClearButton.OnClickAsObservable()
.Subscribe(_ => EquipmentManager.Instance.OnCleraButtonClicked());
SaveButton.OnClickAsObservable()
.Subscribe(_ => EquipmentManager.Instance.SaveData());
transform.Find("TitleBar/CloseButton").GetComponent<Button>().OnClickAsObservable()
.Subscribe(_ => Hide());
Observable.EveryLateUpdate()
.Where(_ => Input.GetMouseButtonDown(1))
.Subscribe(_ => CreateToggle.isOn = false);
}
public override void Show()
{
base.Show();
switch (EquipmentManager.Instance.CreationType)
{
case EquipmentType.NoParking:
TitleText.text = "禁停区";
break;
case EquipmentType.KeyArea:
TitleText.text = "重点区域";
break;
case EquipmentType.ImageMarked:
TitleText.text = "图片标注";
break;
case EquipmentType.FireClimbingSite:
TitleText.text = "登高作业面";
break;
case EquipmentType.HazardSource:
TitleText.text = "危险源";
break;
case EquipmentType.ForcedDraftFan:
TitleText.text = "送风机";
break;
case EquipmentType.AirVent:
TitleText.text = "送风口";
break;
case EquipmentType.SmokeExtractionFan:
TitleText.text = "排烟风机";
break;
case EquipmentType.SmokeVent:
TitleText.text = "排烟口";
break;
case EquipmentType.EscapeWin:
TitleText.text = "逃生窗";
break;
case EquipmentType.BreakPoint:
TitleText.text = "破拆点";
break;
}
}
public override void Hide()
{
base.Hide();
CreateToggle.isOn = false;
}
private void CloneObject(bool isOn)
{
switch (EquipmentManager.Instance.CreationType)
{
case EquipmentType.NoParking:
EquipmentManager.Instance.Clone("NoParking", isOn, 0.01f);
break;
case EquipmentType.KeyArea:
EquipmentManager.Instance.Clone("KeyArea", isOn, 0);
break;
case EquipmentType.ImageMarked:
EquipmentManager.Instance.Clone("ImageMarked", isOn, 0);
break;
case EquipmentType.FireClimbingSite:
EquipmentManager.Instance.Clone( "FireClimbingSurface", isOn, 0.01f);
break;
case EquipmentType.HazardSource:
EquipmentManager.Instance.Clone( "HazardSource", isOn, 0);
break;
case EquipmentType.ForcedDraftFan:
EquipmentManager.Instance.Clone("ForcedDraftFan", isOn, 0);
break;
case EquipmentType.AirVent:
EquipmentManager.Instance.Clone("AirVent", isOn, 0);
break;
case EquipmentType.SmokeExtractionFan:
EquipmentManager.Instance.Clone("SmokeExtractionFan", isOn, 0);
break;
case EquipmentType.SmokeVent:
EquipmentManager.Instance.Clone( "SmokeVent", isOn, 5);
break;
case EquipmentType.EscapeWin:
EquipmentManager.Instance.Clone("EscapeWindow", isOn, 0);
break;
case EquipmentType.BreakPoint:
EquipmentManager.Instance.Clone("BreakPoint", isOn, 0);
break;
}
}
}