上海虹口龙之梦项目
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.
 
 
 
 

73 lines
3.5 KiB

using System.Collections;
using System.Collections.Generic;
using UniRx;
using UnityEngine;
using UnityEngine.UI;
public class NewSchemePanel : UIView
{
public InputField NameInput;
public override void Awake()
{
base.Awake();
transform.Find("TitleBar/CloseButton").GetComponent<Button>().OnClickAsObservable()
.Subscribe(_ => Hide());
transform.Find("Background/SetButton").GetComponent<Button>().OnClickAsObservable()
.Subscribe(_ => NewScheme());
}
private void NewScheme()
{
if (!string.IsNullOrEmpty(NameInput.text))
{
switch (PowerManager.Instance.PlanMode)
{
case DisposalPlanMode.:
if (UIManager.Instance.GetView<DisposalPlanPanel>().Plans.Find(a => a.Name == NameInput.text) == null)
{
GameObject go = Instantiate(UIManager.Instance.GetView<DisposalPlanPanel>().PlanItem) as GameObject;
go.SetActive(true);
go.name = NameInput.text;
go.transform.SetParent(UIManager.Instance.GetView<DisposalPlanPanel>().PlanItem.transform.parent, false);
go.transform.Find("Subtitles/Toggle/Label").GetComponent<Text>().text = NameInput.text;
Plan plan = new Plan() { Name = NameInput.text, Nodes = new List<Node>() };
UIManager.Instance.GetView<DisposalPlanPanel>().Plans.Add(plan);
UIManager.Instance.GetView<DisposalPlanPanel>().SavePlanList();
Hide();
}
else
{
MessageBox.Show("名称已存在!", Color.white, 1f);
}
break;
case DisposalPlanMode.:
var temp = UIManager.Instance.GetView<DisposalPlanPanel>().Plans.Find(a => a.Name == PowerManager.Instance.PlanName);
if (temp.Nodes.Find(a => a.Name == NameInput.text) == null)
{
GameObject go = Instantiate(UIManager.Instance.GetView<DisposalPlanPanel>().NodeItem) as GameObject;
go.SetActive(true);
go.name = NameInput.text;
go.transform.SetParent(PowerManager.Instance.NodeParent, false);
go.transform.Find("Load/Label").GetComponent<Text>().text = NameInput.text;
//go.transform.Find("Load").GetComponent<Toggle>().group = UIManager.Instance.GetView<DisposalPlanPanel>().NodeItem.transform.parent.GetComponent<ToggleGroup>();
temp.Nodes.Add(new Node() { Name = NameInput.text });
go.GetComponent<NodeController>().ImageButton.gameObject.name = $"ImageButton{AX.Network.Common.GUID.NewGuid()}";
//go.GetComponent<NodeController>().LoadToggle.isOn = true;
go.GetComponent<NodeController>().SaveNode();
//UIManager.Instance.GetView<DisposalPlanPanel>().SavePlanList();
Hide();
}
else
{
MessageBox.Show("名称已存在!", Color.white, 1f);
}
break;
}
}
else
{
MessageBox.Show("名称不能为空!", Color.white, 1f);
}
}
}