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.
230 lines
6.6 KiB
230 lines
6.6 KiB
using System; |
|
using System.Collections; |
|
using System.Collections.Generic; |
|
using UnityEngine; |
|
using UnityEngine.UI; |
|
using UnityEngine.SceneManagement; |
|
using AX.NetworkSystem; |
|
using System.Xml; |
|
|
|
public class Menu : MonoBehaviour |
|
{ |
|
public Toggle DrillToggle; |
|
public Toggle ExerciseToggle; |
|
public Toggle VideoToggle; |
|
public Toggle DisaterToggle; |
|
public Toggle SysSettingToggle; |
|
public Toggle HelpToggle; |
|
public Button ExitButton; |
|
public GameObject Hint; |
|
public Text ShowText; |
|
|
|
public Button SureButton; |
|
public Button CancelButton; |
|
|
|
public GameObject SettingPanel; |
|
public GameObject DrillPanel; |
|
public GameObject ExercisePanel; |
|
public GameObject VideoPanel; |
|
public GameObject DisaterPanel; |
|
public GameObject HelpPanel; |
|
|
|
private Color oritextColor; |
|
|
|
public Text promptText; |
|
|
|
void Start() |
|
{ |
|
DrillToggle.onValueChanged.AddListener(DrillToggleChange); |
|
ExerciseToggle.onValueChanged.AddListener(ExerciseToggleChange); |
|
VideoToggle.onValueChanged.AddListener(VideoToggleChage); |
|
DisaterToggle.onValueChanged.AddListener(DisaterToggleChage); |
|
SysSettingToggle.onValueChanged.AddListener(SysSettingToggleChange); |
|
HelpToggle.onValueChanged.AddListener(HelpToggleChage); |
|
ExitButton.onClick.AddListener(Exit); |
|
SureButton.onClick.AddListener(Sure); |
|
CancelButton.onClick.AddListener(Cancel); |
|
oritextColor = DrillToggle.GetComponentInChildren<Text>().color; |
|
GetMaps(); |
|
} |
|
|
|
private void Cancel() |
|
{ |
|
Hint.SetActive(false); |
|
ShowText.text = ""; |
|
} |
|
|
|
private void Sure() |
|
{ |
|
Hint.SetActive(false); |
|
transform.Find("Panel").GetComponent<ToggleGroup>().SetAllTogglesOff(); |
|
ShowText.text = ""; |
|
//注销用户信息 |
|
//ToDo: |
|
UserData udata = new UserData |
|
{ |
|
UserInfo = CurrentUserInfo.mySelf, |
|
Role = Role.None, |
|
Org = null, |
|
IsReady = false |
|
}; |
|
NetworkManager.Default.SendRequestAsync("LOGOUT_SYNC", udata); |
|
//回到登入界面 |
|
//SceneManager.LoadScene("Login"); |
|
} |
|
|
|
private void Exit() |
|
{ |
|
Hint.SetActive(true); |
|
ShowText.text = "是否退出系统"; |
|
} |
|
|
|
private void HelpToggleChage(bool value) |
|
{ |
|
HelpPanel.SetActive(value); |
|
HelpToggle.GetComponentInChildren<Text>().color = value ? Color.white : oritextColor; |
|
promptText.text = ""; |
|
} |
|
|
|
private void SysSettingToggleChange(bool value) |
|
{ |
|
SettingPanel.SetActive(value); |
|
SysSettingToggle.GetComponentInChildren<Text>().color = value ? Color.white : oritextColor; |
|
promptText.text = ""; |
|
} |
|
|
|
private void DisaterToggleChage(bool value) |
|
{ |
|
DisaterPanel.SetActive(value); |
|
DisaterToggle.GetComponentInChildren<Text>().color = value ? Color.white : oritextColor; |
|
promptText.text = ""; |
|
} |
|
|
|
private void VideoToggleChage(bool value) |
|
{ |
|
VideoPanel.SetActive(value); |
|
VideoToggle.GetComponentInChildren<Text>().color = value ? Color.white : oritextColor; |
|
promptText.text = ""; |
|
} |
|
|
|
private void ExerciseToggleChange(bool value) |
|
{ |
|
ExercisePanel.SetActive(value); |
|
ExerciseToggle.GetComponentInChildren<Text>().color = value ? Color.white : oritextColor; |
|
promptText.text = ""; |
|
} |
|
|
|
private void DrillToggleChange(bool value) |
|
{ |
|
DrillPanel.SetActive(value); |
|
DrillToggle.GetComponentInChildren<Text>().color = value ? Color.white : oritextColor; |
|
promptText.text = ""; |
|
} |
|
/// <summary> |
|
/// 演习模式跳转 |
|
/// </summary> |
|
public void DrillOnClick() |
|
{ |
|
GameSettings.othersSettings.mode = Mode.manoeuvre; |
|
SceneManager.LoadScene("RolesSelection"); |
|
} |
|
/// <summary> |
|
/// 练习模式跳转 |
|
/// </summary> |
|
public void ExerciseOnClick() |
|
{ |
|
GameSettings.othersSettings.mode = Mode.Practice; |
|
SceneManager.LoadScene("RolesSelection"); |
|
} |
|
/// <summary> |
|
/// 观看录像 |
|
/// </summary> |
|
public void VideoOnClick() |
|
{ |
|
Debug.Log("观看录像"); |
|
} |
|
/// <summary> |
|
/// 灾情管理库跳转 |
|
/// </summary> |
|
public void DisaterOnClick() |
|
{ |
|
bool flag = false; |
|
|
|
foreach (var item in CurrentUserInfo.mySelf.Roles) |
|
{ |
|
if (item.DisplayName == "灾情库管理员") |
|
{ |
|
flag = true; |
|
break; |
|
} |
|
} |
|
|
|
if (flag) |
|
{ |
|
GameSettings.othersSettings.mode = Mode.DisasterManagement; |
|
Debug.Log("灾情管理"); |
|
SceneManager.LoadScene("DisasterLibraryManage"); |
|
} |
|
else |
|
{ |
|
promptText.text = "登录用户没有灾情管理权限"; |
|
} |
|
} |
|
|
|
private void GetMaps() |
|
{ |
|
var doc = new XmlDocument(); |
|
|
|
doc.Load(Application.dataPath + @"\StreamingAssets\MainMapXml.xml"); |
|
|
|
var children = doc.SelectSingleNode("Maps").ChildNodes; |
|
|
|
foreach (XmlElement node in children) |
|
{ |
|
var sceneType = node.GetAttribute("MapType"); |
|
var sceneTp = SceneType.None; |
|
if (sceneType == SceneType.化工建筑.ToString()) |
|
{ |
|
sceneTp = SceneType.化工建筑; |
|
} |
|
else if (sceneType == SceneType.高层建筑.ToString()) |
|
{ |
|
sceneTp = SceneType.高层建筑; |
|
} |
|
else if (sceneType == SceneType.地下建筑.ToString()) |
|
{ |
|
sceneTp = SceneType.地下建筑; |
|
} |
|
else if (sceneType == SceneType.综合体建筑.ToString()) |
|
{ |
|
sceneTp = SceneType.综合体建筑; |
|
} |
|
else if (sceneType == SceneType.大跨度建筑.ToString()) |
|
{ |
|
sceneTp = SceneType.大跨度建筑; |
|
} |
|
var mapName = node.GetAttribute("MapName"); |
|
GameSettings.othersSettings.SceneType = sceneTp; |
|
GameSettings.othersSettings.mapname = mapName; |
|
|
|
//var path = node.GetAttribute("Path"); |
|
//var unit = Unit.None; |
|
//if (path == Unit.DongYouLiQing.ToString()) |
|
//{ |
|
// unit = Unit.DongYouLiQing; |
|
//} |
|
|
|
|
|
//var intro = node.GetAttribute("Intro"); |
|
//var areaSquadron = node.GetAttribute("XiaQZD"); |
|
|
|
//mapType.sceneType = sceneTp; |
|
//mapType.unit = unit; |
|
//mapType.name = mapName; |
|
//mapType.introduction = intro; |
|
//mapType.areaSquadron = areaSquadron; |
|
|
|
//maps.Add(mapType.unit.ToString(), mapType); |
|
} |
|
} |
|
}
|
|
|