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.
269 lines
11 KiB
269 lines
11 KiB
3 years ago
|
using UnityEngine;
|
||
|
using System.Collections;
|
||
|
using UnityEngine.UI;
|
||
|
using AX.MessageSystem;
|
||
|
using System;
|
||
|
using System.Collections.Generic;
|
||
|
using AX.TrackRecord;
|
||
|
/// <summary>
|
||
|
/// 1、编辑中队名称,响应实例化物体时对物体的头顶名的修改
|
||
|
/// 2、挂载在Canvas下TeamNameWin
|
||
|
/// 3、核心方法:CloseEditForceWin(),ShowtheTeam()
|
||
|
///
|
||
|
/// </summary>
|
||
|
public class EditForceName : MonoBehaviour {
|
||
|
public static EditForceName Instance;
|
||
|
[HideInInspector]
|
||
|
public InputField Forceinput;
|
||
|
private GameObject ForceContent;
|
||
|
[HideInInspector]
|
||
|
public string JudgeName;
|
||
|
public string Editname = "";
|
||
|
private GameObject ThePowerUI;
|
||
|
private GameObject PingBiUI;
|
||
|
private Button ChongZhiButton;
|
||
|
public List<String> listName = new List<string>();
|
||
|
void Awake()
|
||
|
{
|
||
|
|
||
|
if (this.gameObject.name.Equals("PowerTeamNameWin") &&
|
||
|
ExamInfoHelpClass.applicationMode == ExamInfoHelpClass.ApplicationMode.PATHFINDING &&
|
||
|
(ExamInfoHelpClass.loadSceneMode == ExamInfoHelpClass.LoadSceneMode.CopyQuestion ||
|
||
|
ExamInfoHelpClass.loadSceneMode == ExamInfoHelpClass.LoadSceneMode.CreatQuestion ||
|
||
|
ExamInfoHelpClass.loadSceneMode == ExamInfoHelpClass.LoadSceneMode.EditQuestion
|
||
|
|| ExamInfoHelpClass.loadSceneMode == ExamInfoHelpClass.LoadSceneMode.CheckQuestion))
|
||
|
{
|
||
|
if (Instance == null)
|
||
|
{
|
||
|
Instance = this;
|
||
|
}
|
||
|
}
|
||
|
else if (this.gameObject.name.Equals("TeamNameWin"))
|
||
|
{
|
||
|
if (Instance == null)
|
||
|
{
|
||
|
Instance = this;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
MessageDispatcher.AddListener("ShowtheTeam", ShowtheTeam);
|
||
|
transform.Find("OKButton").GetComponent<Button>().onClick.AddListener(ChangeTeamName);
|
||
|
transform.Find("ChangeButton").GetComponent<Button>().onClick.AddListener(CloseEditForceWin);
|
||
|
Forceinput = transform.Find("InputField").GetComponent<InputField>();
|
||
|
ForceContent = transform.Find("Scroll View").Find("Viewport").Find("ForceContent").gameObject;
|
||
|
MessageDispatcher.AddListener("ResetTheScene", ResettingInformation);
|
||
|
transform.Find("CloseButton").GetComponent<Button>().onClick.AddListener(CloseEditWin);
|
||
|
if (ExamInfoHelpClass.applicationMode == ExamInfoHelpClass.ApplicationMode.PATHFINDING && this.gameObject.name.Equals("PowerTeamNameWin"))
|
||
|
{
|
||
|
transform.Find("ModeSelect/AllPower").GetComponent<Toggle>().onValueChanged.AddListener(AllPower);
|
||
|
transform.Find("ModeSelect/PartPower").GetComponent<Toggle>().onValueChanged.AddListener(PartPower);
|
||
|
PingBiUI = transform.Find("ModePingBi").gameObject;
|
||
|
ChongZhiButton = transform.Find("ChongZhiButton").GetComponent<Button>();
|
||
|
ThePowerUI = GameObject.Find("Canvas").transform.Find("PowerAttributeUI").gameObject;
|
||
|
transform.Find("ChongZhiButton").GetComponent<Button>().onClick.AddListener(ChongZhiBtn);
|
||
|
}
|
||
|
}
|
||
|
void Start() {
|
||
|
|
||
|
}
|
||
|
public void ShowtheTeam(IMessage message)
|
||
|
{
|
||
|
if (this.gameObject.name.Equals("PowerTeamNameWin"))
|
||
|
{
|
||
|
for (int i = 0; i < SetPowerScript.Instance.TeamList.Count; i++)
|
||
|
{
|
||
|
GameObject checkBox = Instantiate(Resources.Load<GameObject>("Prefabs/TaskList/TeamNameList")) as GameObject;
|
||
|
checkBox.transform.SetParent(ForceContent.transform);
|
||
|
checkBox.transform.localScale = Vector3.one;
|
||
|
checkBox.name = "item";
|
||
|
checkBox.transform.Find("Label").GetComponent<Text>().text = SetPowerScript.Instance.TeamList[i].TeamName;
|
||
|
Editname = checkBox.transform.Find("Label").GetComponent<Text>().text;
|
||
|
listName.Add(Editname);
|
||
|
if (ExamInfoHelpClass.loadSceneMode == ExamInfoHelpClass.LoadSceneMode.CheckQuestion)
|
||
|
{
|
||
|
checkBox.transform.Find("delect").GetComponent<Button>().enabled=false;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if (ExamInfoHelpClass.loadSceneMode == ExamInfoHelpClass.LoadSceneMode.CheckQuestion)
|
||
|
{
|
||
|
transform.Find("ChangeButton").GetComponent<Button>().interactable = false;
|
||
|
ChongZhiButton.interactable = false;
|
||
|
//PingBiUI.SetActive(true);
|
||
|
Forceinput.enabled = false;
|
||
|
GameObject.Find("Canvas").transform.Find("PowerAttributeUI").Find("PingBi").gameObject.SetActive(true);
|
||
|
transform.Find("ModeSelect/AllPower").GetComponent<Toggle>().interactable = false;
|
||
|
transform.Find("ModeSelect/PartPower").GetComponent<Toggle>().interactable = false;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|
||
|
public void AllPower(bool check)
|
||
|
{
|
||
|
transform.Find("ChangeButton").GetComponent<Button>().interactable=false;
|
||
|
ChongZhiButton.interactable = false;
|
||
|
PingBiUI.SetActive(true);
|
||
|
Forceinput.enabled = false;
|
||
|
SetPowerScript.Instance.modeType = ModeType.AllPower;
|
||
|
}
|
||
|
public void PartPower(bool check)
|
||
|
{
|
||
|
transform.Find("ChangeButton").GetComponent<Button>().interactable = true;
|
||
|
ChongZhiButton.interactable = true;
|
||
|
PingBiUI.SetActive(false);
|
||
|
Forceinput.enabled = true;
|
||
|
SetPowerScript.Instance.modeType = ModeType.PartPower;
|
||
|
}
|
||
|
public void ChongZhiBtn()
|
||
|
{
|
||
|
Forceinput.text = "";
|
||
|
JudgeName = "";
|
||
|
foreach (Transform child in ForceContent.transform)
|
||
|
{
|
||
|
Destroy(child.gameObject);
|
||
|
}
|
||
|
listName.Clear();
|
||
|
ThePowerUI.gameObject.SetActive(false);
|
||
|
SetPowerScript.Instance.TeamList.Clear();
|
||
|
}
|
||
|
public void ShowEditForceWin()
|
||
|
{
|
||
|
string PowerTeamNameWin = "PowerTeamNameWin";
|
||
|
string TeamNameWin = "TeamNameWin";
|
||
|
if (ExamInfoHelpClass.applicationMode == ExamInfoHelpClass.ApplicationMode.PATHFINDING && (ExamInfoHelpClass.loadSceneMode == ExamInfoHelpClass.LoadSceneMode.CopyQuestion ||
|
||
|
ExamInfoHelpClass.loadSceneMode == ExamInfoHelpClass.LoadSceneMode.CreatQuestion ||
|
||
|
ExamInfoHelpClass.loadSceneMode == ExamInfoHelpClass.LoadSceneMode.EditQuestion
|
||
|
|| ExamInfoHelpClass.loadSceneMode == ExamInfoHelpClass.LoadSceneMode.CheckQuestion))
|
||
|
{
|
||
|
MessageDispatcher.SendMessage("OPEN", (object)PowerTeamNameWin, "CUBE");
|
||
|
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
MessageDispatcher.SendMessage("OPEN", (object)TeamNameWin, "CUBE");
|
||
|
}
|
||
|
|
||
|
}
|
||
|
public void CloseEditWin()
|
||
|
{
|
||
|
string PowerTeamNameWin = "PowerTeamNameWin";
|
||
|
string TeamNameWin = "TeamNameWin";
|
||
|
if (ExamInfoHelpClass.applicationMode == ExamInfoHelpClass.ApplicationMode.PATHFINDING && (ExamInfoHelpClass.loadSceneMode == ExamInfoHelpClass.LoadSceneMode.CopyQuestion ||
|
||
|
ExamInfoHelpClass.loadSceneMode == ExamInfoHelpClass.LoadSceneMode.CreatQuestion ||
|
||
|
ExamInfoHelpClass.loadSceneMode == ExamInfoHelpClass.LoadSceneMode.EditQuestion))
|
||
|
{
|
||
|
MessageDispatcher.SendMessage("CLOSE", (object)PowerTeamNameWin, "CUBE");
|
||
|
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
MessageDispatcher.SendMessage("CLOSE", (object)TeamNameWin, "CUBE");
|
||
|
}
|
||
|
|
||
|
Forceinput.text = "";
|
||
|
}
|
||
|
/// <summary>
|
||
|
/// 判断输入框相对应方式
|
||
|
/// </summary>
|
||
|
public void CloseEditForceWin()
|
||
|
{
|
||
|
List<GameObject> list = new List<GameObject>();
|
||
|
if (Forceinput.text.Equals("已经有此名字") || Forceinput.text.Equals("名字不能为空"))
|
||
|
return;
|
||
|
if (Forceinput.text.Contains("-"))
|
||
|
{
|
||
|
Forceinput.text = "名字不能有"+":-";
|
||
|
return;
|
||
|
}
|
||
|
if (Forceinput.text == ""||Forceinput.text==null )
|
||
|
{
|
||
|
Forceinput.text = "名字不能为空";
|
||
|
return;
|
||
|
}
|
||
|
foreach (Transform child in ForceContent.transform)
|
||
|
{
|
||
|
if (Forceinput.text.Equals(child.transform.Find("Label").GetComponent<Text>().text))
|
||
|
{
|
||
|
Forceinput.text = "已经有此名字";
|
||
|
return;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
foreach (Transform child in ForceContent.transform)
|
||
|
{
|
||
|
list.Add(child.gameObject);
|
||
|
}
|
||
|
GameObject checkBox = Instantiate(Resources.Load<GameObject>("Prefabs/TaskList/TeamNameList")) as GameObject;
|
||
|
checkBox.transform.SetParent(ForceContent.transform);
|
||
|
checkBox.transform.localScale = Vector3.one;
|
||
|
checkBox.name = "item";
|
||
|
checkBox.transform.Find("Label").GetComponent<Text>().text = Forceinput.text;
|
||
|
Editname = checkBox.transform.Find("Label").GetComponent<Text>().text;
|
||
|
listName.Add(Editname);
|
||
|
|
||
|
//寻路模式下
|
||
|
if (ExamInfoHelpClass.applicationMode == ExamInfoHelpClass.ApplicationMode.PATHFINDING&&
|
||
|
( ExamInfoHelpClass.loadSceneMode == ExamInfoHelpClass.LoadSceneMode.CreatQuestion ||
|
||
|
ExamInfoHelpClass.loadSceneMode == ExamInfoHelpClass.LoadSceneMode.EditQuestion)
|
||
|
)
|
||
|
{
|
||
|
TeamAttri team = new TeamAttri();
|
||
|
team.TeamName = Editname;
|
||
|
SetPowerScript.Instance.TeamList.Add(team);
|
||
|
}
|
||
|
if (list.Count != 0)
|
||
|
{
|
||
|
GameObject game = list[0] as GameObject;
|
||
|
checkBox.transform.SetSiblingIndex(game.transform.GetSiblingIndex());
|
||
|
}
|
||
|
|
||
|
}
|
||
|
/// <summary>
|
||
|
/// 提交修改信息
|
||
|
/// </summary>
|
||
|
public void ChangeTeamName()
|
||
|
{
|
||
|
//选中单选框后才能进行消防车和消防员头顶名进行修改
|
||
|
foreach (Transform child in ForceContent.transform)
|
||
|
{
|
||
|
if (child.GetComponent<Toggle>().isOn==true)
|
||
|
{
|
||
|
JudgeName = child.GetComponent<TeamNameToggle>().EditName;
|
||
|
|
||
|
InstantiationCar.Instance.isboolCar = true;
|
||
|
InstantiationStaff.Instance.isboolStaff = true;
|
||
|
}
|
||
|
if (JudgeName != ""&& child.GetComponent<Toggle>().isOn == true)
|
||
|
{
|
||
|
MessageDispatcher.SendMessage("TeamSelect", (object)JudgeName);
|
||
|
|
||
|
}
|
||
|
}
|
||
|
MessageDispatcher.SendMessage("CLOSE", (object)this.name, "CUBE");
|
||
|
MessageDispatcher.SendMessage("IntercalateButton", (object)this.name);
|
||
|
|
||
|
|
||
|
}
|
||
|
/// <summary>
|
||
|
/// 重置中队名称信息
|
||
|
/// </summary>
|
||
|
/// <param name="message"></param>
|
||
|
void ResettingInformation(IMessage message)
|
||
|
{
|
||
|
Forceinput.text = "";
|
||
|
JudgeName = "";
|
||
|
foreach (Transform child in ForceContent.transform)
|
||
|
{
|
||
|
Destroy(child.gameObject);
|
||
|
}
|
||
|
listName.Clear();
|
||
|
|
||
|
}
|
||
|
void OnDestroy()
|
||
|
{
|
||
|
MessageDispatcher.RemoveListener("ResetTheScene", ResettingInformation);
|
||
|
MessageDispatcher.RemoveListener("ShowtheTeam", ShowtheTeam);
|
||
|
}
|
||
|
|
||
|
}
|