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.
203 lines
6.5 KiB
203 lines
6.5 KiB
using System; |
|
using System.Collections; |
|
using System.Collections.Generic; |
|
using UnityEngine; |
|
using UnityEngine.UI; |
|
|
|
public class AskInsiderPanel : MonoBehaviour |
|
{ |
|
public Toggle InflamerToggle; |
|
public Toggle TrappedToggle; |
|
public Toggle FireLocationToggle; |
|
public Toggle DangerousToggle; |
|
public Toggle ValuablesToggle; |
|
public Toggle BuildStructToggle; |
|
public Toggle AvailableToggle; |
|
public Text InflamerText; |
|
public Text TrappedText; |
|
public Text FireLocationText; |
|
public Text DangerousText; |
|
public Text ValuableText; |
|
public Text BuildStructText; |
|
public Text AvailiableText; |
|
public Button TitleCloseButton; |
|
public Button AskConfirmButton; |
|
public Button AskCancelButton; |
|
public Button AnswerConfirmButton; |
|
public Transform AnswerContent; |
|
private static AskInsiderPanel instance; |
|
|
|
public bool FireFacilityUserAble; |
|
|
|
public static AskInsiderPanel Instance |
|
{ |
|
get |
|
{ |
|
if (instance==null) |
|
{ |
|
GameObject Prefabs = Resources.Load<GameObject>("AskInsiderPanel"); |
|
GameObject panel= Instantiate(Prefabs, GameObject.Find("Canvas").transform); |
|
instance = panel.GetComponent<AskInsiderPanel>(); |
|
} |
|
return instance; |
|
} |
|
} |
|
|
|
//public static AskInsiderPanel Instance; |
|
|
|
|
|
// Use this for initialization |
|
|
|
|
|
void Start() |
|
{ |
|
InflamerToggle.GetComponent<ToggleRecordByAC>().OutInterFaceToggle = InflamerToggleChange; |
|
TrappedToggle.GetComponent<ToggleRecordByAC>().OutInterFaceToggle = TrappedToggleChange; |
|
FireLocationToggle.GetComponent<ToggleRecordByAC>().OutInterFaceToggle = FireLocationToggleChange; |
|
DangerousToggle.GetComponent<ToggleRecordByAC>().OutInterFaceToggle = DangerousToggleChange; |
|
ValuablesToggle.GetComponent<ToggleRecordByAC>().OutInterFaceToggle = ValuablesToggleChange; |
|
BuildStructToggle.GetComponent<ToggleRecordByAC>().OutInterFaceToggle = BuildStructToggleChange; |
|
AvailableToggle.GetComponent<ToggleRecordByAC>().OutInterFaceToggle = AvailableToggleChange; |
|
TitleCloseButton.GetComponent<ButtonRecordByAC>().OutInterFaceButton = TitleCloseButtonClick; |
|
AskConfirmButton.GetComponent<ButtonRecordByAC>().OutInterFaceButton = AskConfirmButtonClick; |
|
AskCancelButton.GetComponent<ButtonRecordByAC>().OutInterFaceButton = AskCancelButtonClick; |
|
AnswerConfirmButton.GetComponent<ButtonRecordByAC>().OutInterFaceButton = AnswerConfirmButtonClick; |
|
|
|
} |
|
public void Show() |
|
{ |
|
|
|
if (!gameObject.activeInHierarchy) |
|
{ |
|
Reset(); |
|
gameObject.SetActive(true); |
|
} |
|
|
|
|
|
} |
|
|
|
private void InflamerToggleChange(bool obj) |
|
{ |
|
InflamerText.gameObject.SetActive(obj); |
|
} |
|
|
|
private void TrappedToggleChange(bool obj) |
|
{ |
|
TrappedText.gameObject.SetActive(obj); |
|
} |
|
|
|
private void FireLocationToggleChange(bool obj) |
|
{ |
|
FireLocationText.gameObject.SetActive(obj); |
|
} |
|
|
|
private void DangerousToggleChange(bool obj) |
|
{ |
|
DangerousText.gameObject.SetActive(obj); |
|
} |
|
|
|
private void ValuablesToggleChange(bool obj) |
|
{ |
|
ValuableText.gameObject.SetActive(obj); |
|
} |
|
|
|
private void BuildStructToggleChange(bool obj) |
|
{ |
|
BuildStructText.gameObject.SetActive(obj); |
|
} |
|
|
|
private void AvailableToggleChange(bool obj) |
|
{ |
|
AvailiableText.gameObject.SetActive(obj); |
|
} |
|
|
|
private void TitleCloseButtonClick() |
|
{ |
|
Reset(); |
|
gameObject.SetActive(false); |
|
} |
|
|
|
private void AskConfirmButtonClick() |
|
{ |
|
SetAnswer(); |
|
transform.Find("AskPanel").gameObject.SetActive(false); |
|
transform.Find("AnswerPanel").gameObject.SetActive(true); |
|
} |
|
|
|
private void AskCancelButtonClick() |
|
{ |
|
Reset(); |
|
gameObject.SetActive(false); |
|
} |
|
|
|
private void AnswerConfirmButtonClick() |
|
{ |
|
Reset(); |
|
gameObject.SetActive(false); |
|
} |
|
public void Reset() |
|
{ |
|
Toggle[] allToggle = GetComponentsInChildren<Toggle>(); |
|
for (int i = 0; i < allToggle.Length; i++) |
|
{ |
|
allToggle[i].isOn = false; |
|
} |
|
Text[] allAnswerText = AnswerContent.GetComponentsInChildren<Text>(); |
|
for (int i = 0; i < allAnswerText.Length; i++) |
|
{ |
|
allAnswerText[i].text = ""; |
|
allAnswerText[i].gameObject.SetActive(false); |
|
} |
|
transform.Find("AskPanel").gameObject.SetActive(true); |
|
transform.Find("AnswerPanel").gameObject.SetActive(false); |
|
} |
|
|
|
void SetAnswer() |
|
{ |
|
Transform Pdister = GameObject.Find("P_AllParent").transform.Find("P_Disasters"); |
|
string comburent = ""; |
|
string position = ""; |
|
FireSpreadCtrl[] fireNormal = Pdister.Find("P_FireNormal").GetComponentsInChildren<FireSpreadCtrl>(); |
|
for (int i = 0; i < fireNormal.Length; i++) |
|
{ |
|
string thisfirecomburent = fireNormal[i].fireAttribute.comburent; |
|
string thisfireposition = fireNormal[i].fireAttribute.position; |
|
if (!comburent.Contains(thisfirecomburent)) |
|
{ |
|
comburent += thisfirecomburent; |
|
comburent += " "; |
|
} |
|
if (!position.Contains(thisfireposition)) |
|
{ |
|
position += thisfireposition; |
|
position += " "; |
|
} |
|
} |
|
if (comburent.Trim().Length > 0) |
|
{ |
|
InflamerText.text = "* 燃烧物为:" + comburent; |
|
} |
|
else |
|
{ |
|
InflamerText.text = "* 燃烧物为:" + "不详"; |
|
} |
|
|
|
int wonder = Pdister.transform.Find("P_Wounded").childCount; |
|
int Trapped = Pdister.transform.Find("P_TrappedPerson").childCount; |
|
string trap = wonder + Trapped > 0 ? "* 有被困人员" : "* 没有被困人员"; |
|
TrappedText.text = trap; |
|
if (position.Trim().Length > 0) |
|
{ |
|
FireLocationText.text = "* 火灾位置为:" + position; |
|
} |
|
else |
|
{ |
|
FireLocationText.text = "* 火灾位置为:" + "不详"; |
|
} |
|
int dangerous = Pdister.transform.Find("P_DangerousCargo").childCount; |
|
DangerousText.text = dangerous > 0 ? "* 有危险品" : "* 没有危险品"; |
|
ValuableText.text = "* 无贵重物品"; |
|
BuildStructText.text = "* 燃烧的建筑物的结构特点及其毗连建筑物的状况"; |
|
AvailiableText.text = "* 起火建筑物内消防设施的可利用情况"; |
|
} |
|
}
|
|
|