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.
371 lines
14 KiB
371 lines
14 KiB
4 years ago
|
using AX.MessageSystem;
|
||
|
using System;
|
||
|
using System.Collections;
|
||
|
using System.Collections.Generic;
|
||
|
using UnityEngine;
|
||
|
using UnityEngine.UI;
|
||
|
|
||
|
public class VictoryConditionSetting
|
||
|
{
|
||
|
public int Count;//胜利条件条数
|
||
|
public int BurnedArea;//过火面积
|
||
|
public int FireManDied;//牺牲消防员个数
|
||
|
public int UnRescued;//未被营救的伤员和被困人员之和
|
||
|
public int BurnedTime;//燃烧时间
|
||
|
}
|
||
|
|
||
|
public class VictoryConditionPanel : MonoBehaviour
|
||
|
{
|
||
|
public Transform VictoryScrollView;
|
||
|
|
||
|
public Transform CountSettingInputField;
|
||
|
|
||
|
public Transform FireAreaToggle;
|
||
|
public Transform FireAreaInputField;
|
||
|
|
||
|
public Transform FireManSettingToggle;
|
||
|
public Transform FireMaSettingInputField;
|
||
|
|
||
|
public Transform TrappedPersonToggle;
|
||
|
public Transform TrappedPersonInputField;
|
||
|
|
||
|
public Transform FireTimeToggle;
|
||
|
public Transform FireTimeInputField;
|
||
|
|
||
|
private Toggle[] all;
|
||
|
public int SetCount;
|
||
|
public int FireArea;
|
||
|
public int FireMan;
|
||
|
public int Trapped;
|
||
|
public int FireTime;
|
||
|
|
||
|
private void Awake()
|
||
|
{
|
||
|
MessageDispatcher.AddListener("LOAD_UIDISASTER", LoadUIDisaster);
|
||
|
}
|
||
|
|
||
|
// Use this for initialization
|
||
|
void Start()
|
||
|
{
|
||
|
all = VictoryScrollView.transform.GetComponentsInChildren<Toggle>();
|
||
|
|
||
|
CountSettingInputField.GetComponent<InputFieldRecordByAC>().OutInterFaceInPutField = CountSettingInputFieldChange;
|
||
|
|
||
|
FireAreaToggle.GetComponent<ToggleRecordByAC>().OutInterFaceToggle = FireAreaToggleChange;
|
||
|
FireAreaInputField.GetComponent<InputFieldRecordByAC>().OutInterFaceInPutField = FireAreaInputFieldChange;
|
||
|
|
||
|
FireManSettingToggle.GetComponent<ToggleRecordByAC>().OutInterFaceToggle = FireManSettingToggleChange;
|
||
|
FireMaSettingInputField.GetComponent<InputFieldRecordByAC>().OutInterFaceInPutField = FireMaSettingInputFieldChange;
|
||
|
|
||
|
TrappedPersonToggle.GetComponent<ToggleRecordByAC>().OutInterFaceToggle = TrappedPersonToggleChange;
|
||
|
TrappedPersonInputField.GetComponent<InputFieldRecordByAC>().OutInterFaceInPutField = TrappedPersonInputFieldChange;
|
||
|
|
||
|
FireTimeToggle.GetComponent<ToggleRecordByAC>().OutInterFaceToggle = FireTimeToggleChange;
|
||
|
FireTimeInputField.GetComponent<InputFieldRecordByAC>().OutInterFaceInPutField = FireTimeInputFieldChange;
|
||
|
|
||
|
CountSettingInputField.GetComponentInChildren<InputField>().ActivateInputField();
|
||
|
|
||
|
}
|
||
|
|
||
|
private void OnDestroy()
|
||
|
{
|
||
|
MessageDispatcher.RemoveListener("LOAD_UIDISASTER", LoadUIDisaster);
|
||
|
}
|
||
|
|
||
|
private void LoadUIDisaster(IMessage obj)
|
||
|
{
|
||
|
if (GameSettings.othersSettings.isSelectedDisaster)
|
||
|
{
|
||
|
DataBind();
|
||
|
if (GameSettings.othersSettings.mode != Mode.DisasterManagement)
|
||
|
{//若是练习或演习模式进入导调组界面,则不可以修改
|
||
|
CountSettingInputField.GetComponent<InputField>().interactable = false;
|
||
|
FireAreaToggle.GetComponent<Toggle>().interactable = false;
|
||
|
FireAreaInputField.GetComponent<InputField>().interactable = false;
|
||
|
FireManSettingToggle.GetComponent<Toggle>().interactable = false;
|
||
|
FireMaSettingInputField.GetComponent<InputField>().interactable = false;
|
||
|
TrappedPersonToggle.GetComponent<Toggle>().interactable = false;
|
||
|
TrappedPersonInputField.GetComponent<InputField>().interactable = false;
|
||
|
FireTimeToggle.GetComponent<Toggle>().interactable = false;
|
||
|
FireTimeInputField.GetComponent<InputField>().interactable = false;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
if (!GameSettings.disasterSetting.isEdit)
|
||
|
{//若是灾情库设置模式的查看,则不可以修改
|
||
|
CountSettingInputField.GetComponent<InputField>().interactable = false;
|
||
|
FireAreaToggle.GetComponent<Toggle>().interactable = false;
|
||
|
FireAreaInputField.GetComponent<InputField>().interactable = false;
|
||
|
FireManSettingToggle.GetComponent<Toggle>().interactable = false;
|
||
|
FireMaSettingInputField.GetComponent<InputField>().interactable = false;
|
||
|
TrappedPersonToggle.GetComponent<Toggle>().interactable = false;
|
||
|
TrappedPersonInputField.GetComponent<InputField>().interactable = false;
|
||
|
FireTimeToggle.GetComponent<Toggle>().interactable = false;
|
||
|
FireTimeInputField.GetComponent<InputField>().interactable = false;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
//若是灾情库设置模式的编辑,则可以修改
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public void VictoryConditionSettingFunction()
|
||
|
{
|
||
|
VictoryConditionSetting vs = new VictoryConditionSetting
|
||
|
{
|
||
|
Count = SetCount,
|
||
|
BurnedArea = FireArea,
|
||
|
FireManDied = FireMan,
|
||
|
UnRescued = Trapped,
|
||
|
BurnedTime = FireTime,
|
||
|
};
|
||
|
Debug.Log(vs.Count + "setcount" + vs.BurnedArea + "firearea" + vs.FireManDied + "fireman" + vs.UnRescued + "trapped" + vs.BurnedTime + "firetime");
|
||
|
}
|
||
|
public VictoryConditionSetting VictoryConditionSetting()
|
||
|
{
|
||
|
VictoryConditionSetting vs = new VictoryConditionSetting
|
||
|
{
|
||
|
Count = SetCount,
|
||
|
BurnedArea = FireArea,
|
||
|
FireManDied = FireMan,
|
||
|
UnRescued = Trapped,
|
||
|
BurnedTime = FireTime,
|
||
|
};
|
||
|
return vs;
|
||
|
Debug.Log(vs.Count + "setcount" + vs.BurnedArea + "firearea" + vs.FireManDied + "fireman" + vs.UnRescued + "trapped" + vs.BurnedTime + "firetime");
|
||
|
}
|
||
|
void Update()
|
||
|
{
|
||
|
|
||
|
}
|
||
|
/// <summary>
|
||
|
/// 胜利条件条数设置
|
||
|
/// </summary>
|
||
|
void countSettingActiveJudge()
|
||
|
{
|
||
|
//Toggle[] all = VictoryScrollView.transform.GetComponentsInChildren<Toggle>();
|
||
|
if (int.Parse(CountSettingInputField.GetComponentInChildren<InputField>().text) >= 1)
|
||
|
{
|
||
|
|
||
|
FireAreaToggle.GetComponent<Toggle>().interactable = true;
|
||
|
FireManSettingToggle.GetComponent<Toggle>().interactable = true;
|
||
|
TrappedPersonToggle.GetComponent<Toggle>().interactable = true;
|
||
|
FireTimeToggle.GetComponent<Toggle>().interactable = true;
|
||
|
for (int i = 0; i < all.Length; i++)
|
||
|
{
|
||
|
all[i].isOn = false;
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
FireAreaToggle.GetComponent<Toggle>().interactable = false;
|
||
|
FireManSettingToggle.GetComponent<Toggle>().interactable = false;
|
||
|
TrappedPersonToggle.GetComponent<Toggle>().interactable = false;
|
||
|
FireTimeToggle.GetComponent<Toggle>().interactable = false;
|
||
|
for (int i = 0; i < all.Length; i++)
|
||
|
{
|
||
|
all[i].isOn = false;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
void toggleActiveJudge(Toggle myself, bool value, int max)
|
||
|
{
|
||
|
// Toggle[] all = VictoryScrollView.transform.GetComponentsInChildren<Toggle>();
|
||
|
if (value)
|
||
|
{
|
||
|
List<Toggle> ontoggle = new List<Toggle>();
|
||
|
for (int i = 0; i < all.Length; i++)
|
||
|
{
|
||
|
if (all[i].isOn)
|
||
|
{
|
||
|
ontoggle.Add(all[i]);
|
||
|
}
|
||
|
}
|
||
|
if (ontoggle.Count == max)
|
||
|
{
|
||
|
|
||
|
for (int i = 0; i < all.Length; i++)
|
||
|
{
|
||
|
if (!ontoggle.Contains(all[i]))
|
||
|
{
|
||
|
all[i].interactable = false;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
|
||
|
for (int i = 0; i < all.Length; i++)
|
||
|
{
|
||
|
all[i].interactable = true;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
//}
|
||
|
//超过几条,演练失败
|
||
|
private void CountSettingInputFieldChange(string value)
|
||
|
{
|
||
|
if (string.IsNullOrEmpty(value) || value == "" || int.Parse(value) < 1)
|
||
|
{
|
||
|
CountSettingInputField.GetComponentInChildren<InputField>().text = "0";
|
||
|
SetCount = 0;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
CountSettingInputField.GetComponentInChildren<InputField>().text = Mathf.Clamp(int.Parse(value.Substring(0, 1)), 0, all.Length).ToString();
|
||
|
SetCount = int.Parse(CountSettingInputField.GetComponentInChildren<InputField>().text);
|
||
|
}
|
||
|
countSettingActiveJudge();
|
||
|
}
|
||
|
/// <summary>
|
||
|
/// 火灾面积toggle
|
||
|
/// </summary>
|
||
|
/// <param name="value"></param>
|
||
|
private void FireAreaToggleChange(bool value)
|
||
|
{
|
||
|
FireAreaToggle.parent.Find("InputField").GetComponent<InputField>().interactable = value;
|
||
|
//toggleActiveJudge(FireAreaToggle.GetComponent<Toggle>(), value, int.Parse(CountSettingInputField.GetComponentInChildren<InputField>().text));
|
||
|
if (!value)
|
||
|
FireAreaToggle.parent.Find("InputField").GetComponent<InputField>().text = "";
|
||
|
}
|
||
|
/// <summary>
|
||
|
/// 火灾面积inputfield
|
||
|
/// </summary>
|
||
|
/// <param name="obj"></param>
|
||
|
private void FireAreaInputFieldChange(string value)
|
||
|
{
|
||
|
if (string.IsNullOrEmpty(value))
|
||
|
{
|
||
|
FireAreaInputField.GetComponentInChildren<InputField>().text = "";
|
||
|
FireArea = 0;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
FireAreaInputField.GetComponentInChildren<InputField>().text = Mathf.Clamp(int.Parse(value), 0, 99999).ToString();
|
||
|
FireArea = int.Parse(FireAreaInputField.GetComponentInChildren<InputField>().text);
|
||
|
}
|
||
|
|
||
|
}
|
||
|
/// <summary>
|
||
|
/// 消防员牺牲toggle
|
||
|
/// </summary>
|
||
|
/// <param name="obj"></param>
|
||
|
private void FireManSettingToggleChange(bool value)
|
||
|
{
|
||
|
FireManSettingToggle.parent.Find("InputField").GetComponent<InputField>().interactable = value;
|
||
|
// toggleActiveJudge(FireManSettingToggle.GetComponent<Toggle>(), value, int.Parse(CountSettingInputField.GetComponentInChildren<InputField>().text));
|
||
|
if (!value)
|
||
|
FireManSettingToggle.parent.Find("InputField").GetComponent<InputField>().text = "";
|
||
|
}
|
||
|
/// <summary>
|
||
|
/// 消防员牺牲Inputfield
|
||
|
/// </summary>
|
||
|
/// <param name="obj"></param>
|
||
|
private void FireMaSettingInputFieldChange(string value)
|
||
|
{
|
||
|
if (string.IsNullOrEmpty(value))
|
||
|
{
|
||
|
FireMaSettingInputField.GetComponentInChildren<InputField>().text = "";
|
||
|
FireMan = 0;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
FireMaSettingInputField.GetComponentInChildren<InputField>().text = Mathf.Clamp(int.Parse(value), 0, 999).ToString();
|
||
|
FireMan = int.Parse(FireMaSettingInputField.GetComponentInChildren<InputField>().text);
|
||
|
}
|
||
|
}
|
||
|
/// <summary>
|
||
|
/// 被困人员Toggle
|
||
|
/// </summary>
|
||
|
/// <param name="obj"></param>
|
||
|
private void TrappedPersonToggleChange(bool value)
|
||
|
{
|
||
|
TrappedPersonToggle.parent.Find("InputField").GetComponent<InputField>().interactable = value;
|
||
|
//toggleActiveJudge(TrappedPersonToggle.GetComponent<Toggle>(), value, int.Parse(CountSettingInputField.GetComponentInChildren<InputField>().text));
|
||
|
if (!value)
|
||
|
TrappedPersonToggle.parent.Find("InputField").GetComponent<InputField>().text = "";
|
||
|
}
|
||
|
/// <summary>
|
||
|
/// 被困人员Inputfield
|
||
|
/// </summary>
|
||
|
/// <param name="obj"></param>
|
||
|
private void TrappedPersonInputFieldChange(string value)
|
||
|
{
|
||
|
if (string.IsNullOrEmpty(value))
|
||
|
{
|
||
|
TrappedPersonInputField.GetComponentInChildren<InputField>().text = "";
|
||
|
Trapped = 0;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
TrappedPersonInputField.GetComponentInChildren<InputField>().text = Mathf.Clamp(int.Parse(value), 0, 999).ToString();
|
||
|
Trapped = int.Parse(TrappedPersonInputField.GetComponentInChildren<InputField>().text);
|
||
|
}
|
||
|
}
|
||
|
/// <summary>
|
||
|
/// 火灾时间Toggle
|
||
|
/// </summary>
|
||
|
/// <param name="obj"></param>
|
||
|
private void FireTimeToggleChange(bool value)
|
||
|
{
|
||
|
FireTimeToggle.parent.Find("InputField").GetComponent<InputField>().interactable = value;
|
||
|
//toggleActiveJudge(FireTimeToggle.GetComponent<Toggle>(), value, int.Parse(CountSettingInputField.GetComponentInChildren<InputField>().text));
|
||
|
if (!value)
|
||
|
FireTimeToggle.parent.Find("InputField").GetComponent<InputField>().text = "";
|
||
|
}
|
||
|
/// <summary>
|
||
|
/// 火灾时间Inputfield
|
||
|
/// </summary>
|
||
|
/// <param name="obj"></param>
|
||
|
private void FireTimeInputFieldChange(string value)
|
||
|
{
|
||
|
if (string.IsNullOrEmpty(value))
|
||
|
{
|
||
|
FireTimeInputField.GetComponentInChildren<InputField>().text = "";
|
||
|
FireTime = 0;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
FireTimeInputField.GetComponentInChildren<InputField>().text = Mathf.Clamp(int.Parse(value), 0, 999).ToString();
|
||
|
FireTime = int.Parse(FireTimeInputField.GetComponentInChildren<InputField>().text);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// 灾情库进来绑定胜利条件设置
|
||
|
/// </summary>
|
||
|
private void DataBind()
|
||
|
{
|
||
|
SetCount = GameSettings.othersSettings.disaster.VictoryCondition.Count;
|
||
|
CountSettingInputField.GetComponent<InputField>().text = SetCount.ToString();
|
||
|
|
||
|
if (GameSettings.othersSettings.disaster.VictoryCondition.BurnedArea > 0)
|
||
|
{
|
||
|
FireAreaToggle.GetComponent<Toggle>().isOn = true;
|
||
|
FireArea = GameSettings.othersSettings.disaster.VictoryCondition.BurnedArea;
|
||
|
FireAreaInputField.GetComponent<InputField>().text = FireArea.ToString();
|
||
|
}
|
||
|
if (GameSettings.othersSettings.disaster.VictoryCondition.FireManDied > 0)
|
||
|
{
|
||
|
FireManSettingToggle.GetComponent<Toggle>().isOn = true;
|
||
|
FireMan = GameSettings.othersSettings.disaster.VictoryCondition.FireManDied;
|
||
|
FireMaSettingInputField.GetComponent<InputField>().text = FireMan.ToString();
|
||
|
}
|
||
|
if (GameSettings.othersSettings.disaster.VictoryCondition.UnRescued > 0)
|
||
|
{
|
||
|
TrappedPersonToggle.GetComponent<Toggle>().isOn = true;
|
||
|
Trapped = GameSettings.othersSettings.disaster.VictoryCondition.UnRescued;
|
||
|
TrappedPersonInputField.GetComponent<InputField>().text = Trapped.ToString();
|
||
|
}
|
||
|
if (GameSettings.othersSettings.disaster.VictoryCondition.BurnedTime > 0)
|
||
|
{
|
||
|
FireTimeToggle.GetComponent<Toggle>().isOn = true;
|
||
|
FireTime = GameSettings.othersSettings.disaster.VictoryCondition.BurnedTime;
|
||
|
FireTimeInputField.GetComponent<InputField>().text = FireTime.ToString();
|
||
|
}
|
||
|
}
|
||
|
}
|