天津23维预案
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.
 
 
 
 
 
 

470 lines
16 KiB

using UnityEngine;
using System.Collections;
using System;
using UnityEngine.UI;
using AX.MessageSystem;
using AX.TrackRecord;
using System.Collections.Generic;
/// <summary>
/// 挂载在Canvas下InsiderWind界面上
/// 主要是获取着火源,位置,被困人员信息
/// 核心方法是CloseInsiderWin();
/// </summary>
public class InsiderControl : MonoBehaviour
{
public static InsiderControl Instance;
[HideInInspector]
public List<string> Comburent;
[HideInInspector]
public List<string> Position;
private List<GameObject> GameObj = new List<GameObject>();
public static bool isWounded = false;
[HideInInspector]
public Toggle QiHuoYuan;
[HideInInspector]
public Toggle BeiKunRenYuanx;
[HideInInspector]
public Toggle WeiZhi;
[HideInInspector]
public Toggle BiNanCengPosition;
/*
* ############################################
* 下列这段代码修改时间是 2017-10-1, by Lucifer
* ############################################
*/
[HideInInspector]
public Toggle QuestionE;
[HideInInspector]
public Toggle QuestionF;
[HideInInspector]
public Toggle QuestionG;
// ############################################
[HideInInspector]
public InputField inputField;
[HideInInspector]
public GameObject obj_Mask;
//string TiShi;
private OtherArrribute_Fire fireAttri;
void Awake()
{
if (Instance == null)
{
Instance = this;
}
}
void Start()
{
transform.Find("OKButton").GetComponent<Button>().onClick.AddListener(CloseInsiderWin);
transform.Find("CloseButton").GetComponent<Button>().onClick.AddListener(CloseWin);
QiHuoYuan = transform.Find("起火源").GetComponent<Toggle>();
BeiKunRenYuanx = transform.Find("被困人员").GetComponent<Toggle>();
WeiZhi = transform.Find("位置").GetComponent<Toggle>();
MessageDispatcher.AddListener("ResetTheScene", ResettingInformation);
BiNanCengPosition = transform.Find("避难层所在位置").GetComponent<Toggle>();
inputField = transform.Find("InputField").GetComponent<InputField>();
obj_Mask = transform.Find("Mask").gameObject;
if (!MySceneManager.GetActiveScene().name.Equals("3"))//超高层显示避难层问题
{
BiNanCengPosition.gameObject.SetActive(false);
}
/*
* ############################################
* 下列这段代码修改时间是 2017-10-1, by Lucifer
* ############################################
*/
QuestionE = transform.Find("重大危险源").GetComponent<Toggle>();
QuestionF = transform.Find("室内消防设施情况").GetComponent<Toggle>();
QuestionG = transform.Find("有无建筑结构内部拆改").GetComponent<Toggle>();
// ############################################
}
void OnEnable()
{
StartCoroutine(delay());
}
IEnumerator delay()
{
yield return new WaitForEndOfFrame();
if (TrackRecordHelpClass.CheckIfCanClickUI())
{
obj_Mask.SetActive(false);
}
else
{
obj_Mask.SetActive(true);
}
}
public void CloseWin()
{
MessageDispatcher.SendMessage("CLOSE", (object)name, "CUBE");
QiHuoYuan.isOn = false;
BeiKunRenYuanx.isOn = false;
WeiZhi.isOn = false;
BiNanCengPosition.isOn = false;
inputField.text = "";
/*
* ############################################
* 下列这段代码修改时间是 2017-10-1, by Lucifer
* ############################################
*/
QuestionE.isOn = false;
QuestionF.isOn = false;
QuestionG.isOn = false;
// ############################################
}
public string NoChooseList = "";
private InsiderUIAttri insider;
public InsiderUIAttri Insider
{
get
{
insider = new InsiderUIAttri();
insider.FireLocationToggle = QiHuoYuan.isOn;
insider.WeiZhiToggle = WeiZhi.isOn;
insider.RefugeFloorLocationToggle = BiNanCengPosition.isOn;
insider.TrappedPersonToggle = BeiKunRenYuanx.isOn;
insider.OthersText = inputField.text;
insider.NoChoseQuestion = NoChooseList;
/*
* ############################################
* 下列这段代码修改时间是 2017-10-1, by Lucifer
* ############################################
*/
insider.QuestionEToggle = QuestionE.isOn;
insider.QuestionFToggle = QuestionF.isOn;
insider.QuestionGToggle = QuestionG.isOn;
// ############################################
return insider;
}
set
{
insider = value;
gameObject.SetActive(true);//打开提示面板
transform.Find("起火源").GetComponent<Toggle>().isOn = insider.FireLocationToggle;
transform.Find("位置").GetComponent<Toggle>().isOn = insider.WeiZhiToggle;
transform.Find("避难层所在位置").GetComponent<Toggle>().isOn = insider.RefugeFloorLocationToggle;
transform.Find("被困人员").GetComponent<Toggle>().isOn = insider.TrappedPersonToggle;
transform.Find("InputField").GetComponent<InputField>().text = insider.OthersText;
/*
* ############################################
* 下列这段代码修改时间是 2017-10-1, by Lucifer
* ############################################
*/
// FIXME: 这里的赋值为什么要这么做?好奇怪的做法;
// 下面的代码纯粹是照猫画虎,上面的代码怎么做,这里就怎么做;
transform.Find("重大危险源").GetComponent<Toggle>().isOn = insider.QuestionEToggle;//重大危险源
transform.Find("室内消防设施情况").GetComponent<Toggle>().isOn = insider.QuestionFToggle;//室内消防设施情况
transform.Find("有无建筑结构内部拆改").GetComponent<Toggle>().isOn = insider.QuestionGToggle;//有无建筑结构内部拆改
// ############################################
NoChooseList = insider.NoChoseQuestion;
timer = 10;
StarterWin();
}
}
private float timer = 10;
void Update()
{
if (LoadManager.Instance.IsPlayBacking && !LoadManager.Instance.IsPause)//回放时关闭 ”计时自动关闭功能“
{
if (timer > 0)
{
timer -= Time.deltaTime * LoadManager.Instance.LoadSpeed;
}
else
{
CloseInsiderWin();
}
}
}
public void CloseInsiderWin()//获取知情人相应的信息
{
//获取着火源,位置,被困人员信息
string TiShi = "";
MessageDispatcher.SendMessage("CLOSE", (object)name, "CUBE");
GameObject sy = GameObject.Find("pshangyuan1");
GameObject sy1 = GameObject.Find("pshangyuan2");
if (!QiHuoYuan.isOn && !BeiKunRenYuanx.isOn && !WeiZhi.isOn && !BiNanCengPosition.isOn && !QuestionE.isOn && !QuestionF.isOn && !QuestionG.isOn)
return;
GameObject fireChild = GameObject.Find("pfire");
foreach (Transform child in fireChild.transform)
{
if (!child.name.Contains("GroundFire"))
{
GameObj.Add(child.gameObject);
}
}
if (QiHuoYuan.isOn)
{
if (GameObj.Count == 0)
{
TiShi += "<color=red>着火源:</color>未设置 ";
}
else
{
for (int i = 0; i < GameObj.Count; i++)
{
if (!string.IsNullOrEmpty(GameObj[i].GetComponent<ShowFireSetWin>().fireAttri.Comburent))
{
Comburent.Add(GameObj[i].GetComponent<ShowFireSetWin>().fireAttri.Comburent);
}
}
if (Comburent.Count == 0)
{
TiShi += "<color=red>着火源:</color>不明确 ";
}
else if (Comburent.Count < 2)
{
if (string.IsNullOrEmpty(Comburent[0]))
{
TiShi += "<color=red>着火源:</color>不明确 ";
}
else
{
TiShi += " <color=red>着火源:</color>" + Comburent[0] + "\n";
}
}
else
{
if (string.IsNullOrEmpty(Comburent[0]) && string.IsNullOrEmpty(Comburent[2]))
{
TiShi += "<color=red>着火源:</color>不明确 ";
}
else if (!string.IsNullOrEmpty(Comburent[0]) && !string.IsNullOrEmpty(Comburent[2]))
{
TiShi += "<color=red>着火源:</color>" + Comburent[0] + "<color=red>和</color>" + Comburent[1] + "\n";
}
else if (!string.IsNullOrEmpty(Comburent[0]))
{
TiShi += "<color=red>着火源:</color>" + Comburent[0] + "\n";
}
else if (!string.IsNullOrEmpty(Comburent[1]))
{
TiShi += "<color=red>着火源:</color>" + Comburent[1] + "\n";
}
}
}
}
if (WeiZhi.isOn)
{
for (int i = 0; i < GameObj.Count; i++)
{
if (!string.IsNullOrEmpty(GameObj[i].GetComponent<ShowFireSetWin>().fireAttri.Position))
{
Position.Add(GameObj[i].GetComponent<ShowFireSetWin>().fireAttri.Position);
}
}
if (Position.Count == 0)
{
TiShi += "<color=red>位置:</color>不明确 ";
}
else if (Position.Count < 2)
{
if (string.IsNullOrEmpty(Position[0]))
{
TiShi += "<color=red>位置:</color>不明确 ";
}
else
{
TiShi += " <color=red>位置:</color>" + Position[0] + "\n";
}
}
else
{
if (string.IsNullOrEmpty(Position[0]) && string.IsNullOrEmpty(Position[2]))
{
TiShi += "<color=red>位置:</color>不明确 ";
}
else if (!string.IsNullOrEmpty(Position[0]) && !string.IsNullOrEmpty(Position[2]))
{
TiShi += "<color=red>位置:</color>" + Position[0] + "<color=red>和</color>" + Position[1] + "\n";
}
else if (!string.IsNullOrEmpty(Position[0]))
{
TiShi += "<color=red>位置:</color>" + Position[0] + "\n";
}
else if (!string.IsNullOrEmpty(Position[1]))
{
TiShi += "<color=red>位置:</color>" + Position[1] + "\n";
}
}
}
if (BeiKunRenYuanx.isOn)
{
if (sy.transform.childCount != 0 || sy1.transform.childCount != 0)
{
isWounded = true;
}
else
{
isWounded = false;
}
if (isWounded)
{
TiShi += "有<color=red>被困人员</color>" + "\n";
}
else
{
TiShi += "未发现有<color=red>被困人员</color>" + "\n";
}
}
if (BiNanCengPosition.isOn)
{
TiShi += "<color=red>避难层:</color>18" + "和" + "34" + "层";
}
/*
* ############################################
* 下列这段代码修改时间是 2017-10-1, by Lucifer
* ############################################
*/
if(QuestionE.isOn)
{
TiShi += "<color=red>重大危险源</color>不明确";
}
if(QuestionF.isOn)
{
TiShi += "<color=red>室内消防设施情况</color>不明确";
}
if(QuestionG.isOn)
{
TiShi += "<color=red>建筑结构内部拆改情况</color>不明确";
}
// ############################################
if (RecordManager.Instance.IsRecording)
{
string str = "";
if (!QiHuoYuan.isOn)
{
NoChooseList += "起火源未询问" + "\n";
str += "起火源、";
}
if (!WeiZhi.isOn)
{
NoChooseList += "起火位置未询问" + "\n";
str += "起火位置、";
}
if (!BeiKunRenYuanx.isOn)
{
NoChooseList += "被困人员未询问" + "\n";
str += "被困人员、";
}
if (MySceneManager.GetActiveScene().name.Equals("3"))
{
if (!BiNanCengPosition.isOn)
{
NoChooseList += "避火层未询问" + "\n";
str += "避火层、";
}
}
/*
* ############################################
* 下列这段代码修改时间是 2017-10-1, by Lucifer
* ############################################
*/
if(!QuestionE.isOn)
{
NoChooseList += "重大危险源未询问" + "\n";
str += "重大危险源、";
}
if(!QuestionF.isOn)
{
NoChooseList += "室内消防设施情况未询问" + "\n";
str += "室内消防设施情况、";
}
if(!QuestionG.isOn)
{
NoChooseList += "建筑结构内部拆改情况未询问" + "\n";
str += "建筑结构内部拆改情况、";
}
// ############################################
NoChooseList = str;
Insider.NoChoseQuestion = str;
MessageDispatcher.SendMessage("RecordEditInsiderEvent", Insider);
}
MessageDispatcher.SendMessage(0.1f, "Operatinghints", (object)TiShi);
}
//重置知情人面板信息
void ResettingInformation(IMessage message)
{
Position.Clear();
GameObject fireChild = GameObject.Find("pfire");
GameObj.Clear();
QiHuoYuan.isOn = false;
BeiKunRenYuanx.isOn = false;
WeiZhi.isOn = false;
BiNanCengPosition.isOn = false;
inputField.text = "";
/*
* ############################################
* 下列这段代码修改时间是 2017-10-1, By Lucifer
* ############################################
*/
QuestionE.isOn = false;
QuestionF.isOn = false;
QuestionG.isOn = false;
// ############################################
}
void OnDestroy()
{
MessageDispatcher.RemoveListener("ResetTheScene", ResettingInformation);
}
public void StarterWin()
{
Comburent.Clear();
Position.Clear();
GameObj.Clear();
if (MySceneManager.GetActiveScene().name.Equals("3"))
{
transform.Find("避难层所在位置").gameObject.SetActive(true);
}
else
{
transform.Find("避难层所在位置").gameObject.SetActive(false);
}
//transform.FindChild("避难层所在位置").gameObject.SetActive(false);//该场景不需要提示避难层
}
}