195 lines
5.0 KiB
C#
195 lines
5.0 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public enum Title
|
|
{
|
|
Electriccharge,
|
|
Powersupply,
|
|
retreaty
|
|
}
|
|
public enum Judgmentstate
|
|
{
|
|
page1,
|
|
page2,
|
|
page3
|
|
}
|
|
public class ControlsManager : MonoBehaviour
|
|
{
|
|
/// <summary>
|
|
/// 电费核算按钮
|
|
/// </summary>
|
|
public Toggle electricitychargeaccounting;
|
|
/// <summary>
|
|
/// 供电合同
|
|
/// </summary>
|
|
public Toggle powersupplycontract;
|
|
/// <summary>
|
|
/// 合同覆约
|
|
/// </summary>
|
|
public Toggle contract;
|
|
/// <summary>
|
|
/// 退出按钮
|
|
/// </summary>
|
|
public Button quit;
|
|
/// <summary>
|
|
/// 退出确认页面
|
|
/// </summary>
|
|
public GameObject promptbox;
|
|
/// <summary>
|
|
/// 退出页面的确认按钮
|
|
/// </summary>
|
|
public Button verifybutton;
|
|
/// <summary>
|
|
/// 退出页面的取消按钮
|
|
/// </summary>
|
|
public Button cancelbutton;
|
|
/// <summary>
|
|
/// 枚举切换标题
|
|
/// </summary>
|
|
public Title title = Title.retreaty;
|
|
/// <summary>
|
|
/// 提示切换页面
|
|
/// </summary>
|
|
public GameObject topicswitchingpanl;
|
|
/// <summary>
|
|
/// 提示页面确认按钮
|
|
/// </summary>
|
|
public Button okbutton3;
|
|
/// <summary>
|
|
/// 提示页面取消按钮
|
|
/// </summary>
|
|
public Button nobutton3;
|
|
/// <summary>
|
|
/// 判断取消界面按钮菜单的状态
|
|
/// </summary>
|
|
public Judgmentstate judgmentstate = Judgmentstate.page3;
|
|
/// <summary>
|
|
/// 覆约合同页面
|
|
/// </summary>
|
|
public GameObject retreatypanl;
|
|
/// <summary>
|
|
/// 供电合同页面
|
|
/// </summary>
|
|
public GameObject powersupplypanl;
|
|
/// <summary>
|
|
/// 电费核算页面
|
|
/// </summary>
|
|
public GameObject electricchargepanl;
|
|
void Start()
|
|
{
|
|
quit.onClick.AddListener(() =>
|
|
{
|
|
promptbox.SetActive(true);
|
|
});
|
|
verifybutton.onClick.AddListener(() =>
|
|
{
|
|
// 退出应用程序
|
|
#if UNITY_EDITOR
|
|
UnityEditor.EditorApplication.isPlaying = false;
|
|
#else
|
|
Application.Quit();
|
|
#endif
|
|
});
|
|
cancelbutton.onClick.AddListener(() =>
|
|
{
|
|
promptbox.SetActive(false);
|
|
});
|
|
electricitychargeaccounting.onValueChanged.AddListener((ison) =>
|
|
{
|
|
if (ison)
|
|
{
|
|
if (title != Title.Electriccharge)
|
|
{
|
|
topicswitchingpanl.SetActive(true);
|
|
title = Title.Electriccharge;
|
|
}
|
|
}
|
|
});
|
|
powersupplycontract.onValueChanged.AddListener((ison) =>
|
|
{
|
|
if (ison)
|
|
{
|
|
if (title != Title.Powersupply)
|
|
{
|
|
topicswitchingpanl.SetActive(true);
|
|
title = Title.Powersupply;
|
|
}
|
|
}
|
|
});
|
|
contract.onValueChanged.AddListener((ison) =>
|
|
{
|
|
if (ison)
|
|
{
|
|
if (title != Title.retreaty)
|
|
{
|
|
topicswitchingpanl.SetActive(true);
|
|
title = Title.retreaty;
|
|
}
|
|
}
|
|
});
|
|
nobutton3.onClick.AddListener(Cancelbutn);
|
|
okbutton3.onClick.AddListener(Theme);
|
|
}
|
|
/// <summary>
|
|
/// 取消菜单切换按钮
|
|
/// </summary>
|
|
public void Cancelbutn()
|
|
{
|
|
switch (judgmentstate)
|
|
{
|
|
case Judgmentstate.page1:
|
|
electricitychargeaccounting.isOn = true;
|
|
topicswitchingpanl.SetActive(false);
|
|
break;
|
|
case Judgmentstate.page2:
|
|
powersupplycontract.isOn = true;
|
|
topicswitchingpanl.SetActive(false);
|
|
break;
|
|
case Judgmentstate.page3:
|
|
contract.isOn = true;
|
|
topicswitchingpanl.SetActive(false);
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 切换菜单确认按钮
|
|
/// </summary>
|
|
public void Theme()
|
|
{
|
|
switch (title)
|
|
{
|
|
case Title.Electriccharge:
|
|
topicswitchingpanl.SetActive(false);
|
|
retreatypanl.SetActive(false);
|
|
powersupplypanl.SetActive(false);
|
|
electricchargepanl.SetActive(true);
|
|
judgmentstate = Judgmentstate.page1;
|
|
break;
|
|
case Title.Powersupply:
|
|
topicswitchingpanl.SetActive(false);
|
|
retreatypanl.SetActive(false);
|
|
powersupplypanl.SetActive(true);
|
|
electricchargepanl.SetActive(false);
|
|
judgmentstate = Judgmentstate.page2;
|
|
break;
|
|
case Title.retreaty:
|
|
topicswitchingpanl.SetActive(false);
|
|
retreatypanl.SetActive(true);
|
|
powersupplypanl.SetActive(false);
|
|
electricchargepanl.SetActive(false);
|
|
judgmentstate = Judgmentstate.page3;
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
void Update()
|
|
{
|
|
|
|
}
|
|
}
|