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.
200 lines
7.6 KiB
200 lines
7.6 KiB
4 years ago
|
using System.Collections;
|
||
|
using System.Collections.Generic;
|
||
|
using UnityEngine;
|
||
|
using AX.MessageSystem;
|
||
|
using UnityEngine.UI;
|
||
|
|
||
|
public class DisasterLibrarySave : BaseButton
|
||
|
{
|
||
|
public GameObject disasterSaveWin;
|
||
|
public VictoryConditionPanel Victoryconditionpanel;
|
||
|
private Transform P_Disaster;
|
||
|
private PoliceCallPanel policecallpanel;
|
||
|
private void Start()
|
||
|
{
|
||
|
Victoryconditionpanel = GameObject.Find("DissaterSetting/SettingPanel/VictoryConditionTitle").GetComponent<VictoryConditionPanel>();
|
||
|
P_Disaster = GameObject.Find("P_AllParent").transform.Find("P_Disasters");
|
||
|
policecallpanel = GameObject.Find("DissaterSetting").transform.Find("PoliceCallPanel").GetComponent<PoliceCallPanel>();
|
||
|
if (GameSettings.othersSettings.isSelectedDisaster)
|
||
|
{
|
||
|
if (GameSettings.othersSettings.mode == Mode.DisasterManagement)
|
||
|
{
|
||
|
if (!GameSettings.disasterSetting.isEdit)
|
||
|
{//若是灾情库设置模式的查看,则不可以保存
|
||
|
gameObject.GetComponent<Button>().interactable = false;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
//若是灾情库设置模式的编辑,则可以保存
|
||
|
gameObject.GetComponent<Button>().interactable = true;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public override void RespondFun()
|
||
|
{
|
||
|
if (!victoryConditionSetJudge())
|
||
|
{
|
||
|
Victoryconditionpanel.GetComponent<Toggle>().isOn = true;
|
||
|
return;
|
||
|
}
|
||
|
if (!PolliceinfoSetJudge())
|
||
|
{
|
||
|
if (!policecallpanel.gameObject.activeInHierarchy)
|
||
|
{
|
||
|
policecallpanel.gameObject.SetActive(true);
|
||
|
}
|
||
|
return;
|
||
|
}
|
||
|
MessageDispatcher.SendMessage("DISASTER_LIBRARY_RECORD");
|
||
|
|
||
|
disasterSaveWin.SetActive(true);
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// 胜利条件设置判断
|
||
|
/// </summary>
|
||
|
private bool victoryConditionSetJudge()
|
||
|
{
|
||
|
bool ok = true;
|
||
|
//判断是否设置胜利条件
|
||
|
if (Victoryconditionpanel != null)
|
||
|
{
|
||
|
|
||
|
if (Victoryconditionpanel.SetCount <= 0)
|
||
|
{
|
||
|
LoadPromptWin.Instance.LoadTextPromptWindow("请先设置胜利条件", 1f);
|
||
|
Victoryconditionpanel.GetComponent<Toggle>().isOn = true;
|
||
|
ok = false;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
ok = true;
|
||
|
Toggle[] all = Victoryconditionpanel.VictoryScrollView.GetComponentsInChildren<Toggle>(true);
|
||
|
int select = 0;
|
||
|
for (int i = 0; i < all.Length; i++)
|
||
|
{
|
||
|
if (all[i].isOn)
|
||
|
{
|
||
|
select++;
|
||
|
}
|
||
|
}
|
||
|
if (select < Victoryconditionpanel.SetCount)
|
||
|
{
|
||
|
ok = false;
|
||
|
LoadPromptWin.Instance.LoadTextPromptWindow("胜利条件未设置完善", 1f);
|
||
|
}
|
||
|
if (Victoryconditionpanel.FireTimeToggle.GetComponent<Toggle>().isOn)
|
||
|
{
|
||
|
if (Victoryconditionpanel.FireTime <= 0)
|
||
|
{
|
||
|
ok = false;
|
||
|
LoadPromptWin.Instance.LoadTextPromptWindow("未设置着火时间", 1f);
|
||
|
}
|
||
|
}
|
||
|
if (Victoryconditionpanel.TrappedPersonToggle.GetComponent<Toggle>().isOn)
|
||
|
{
|
||
|
int trappedandwound = P_Disaster.Find("P_Wounded").childCount + P_Disaster.Find("P_TrappedPerson").childCount;
|
||
|
if (trappedandwound == 0)
|
||
|
{
|
||
|
ok = false;
|
||
|
LoadPromptWin.Instance.LoadTextPromptWindow("尚未设置伤员及被困人员灾情", 1f);
|
||
|
}
|
||
|
if (Victoryconditionpanel.Trapped <= 0 && trappedandwound > 0)
|
||
|
{
|
||
|
ok = false;
|
||
|
LoadPromptWin.Instance.LoadTextPromptWindow("未营救人员不能为0", 1f);
|
||
|
}
|
||
|
|
||
|
if (Victoryconditionpanel.Trapped > trappedandwound)
|
||
|
{
|
||
|
ok = false;
|
||
|
LoadPromptWin.Instance.LoadTextPromptWindow("未营救人数大于设置总人数", 1f);
|
||
|
}
|
||
|
}
|
||
|
if (Victoryconditionpanel.FireManSettingToggle.GetComponent<Toggle>().isOn)
|
||
|
{
|
||
|
if (Victoryconditionpanel.FireMan <= 0)
|
||
|
{
|
||
|
ok = false;
|
||
|
LoadPromptWin.Instance.LoadTextPromptWindow("未设置牺牲消防员人数", 1f);
|
||
|
}
|
||
|
}
|
||
|
if (Victoryconditionpanel.FireAreaToggle.GetComponent<Toggle>().isOn)
|
||
|
{
|
||
|
if (Victoryconditionpanel.FireArea > GetFireTotalArea().Value)
|
||
|
{
|
||
|
ok = false;
|
||
|
LoadPromptWin.Instance.LoadTextPromptWindow("火灾面积超过最大蔓延面积", 1f);
|
||
|
}
|
||
|
if (Victoryconditionpanel.FireArea < GetFireTotalArea().Key)
|
||
|
{
|
||
|
ok = false;
|
||
|
LoadPromptWin.Instance.LoadTextPromptWindow("火灾面积小于最小面积", 1f);
|
||
|
}
|
||
|
if (Victoryconditionpanel.FireArea <= 0)
|
||
|
{
|
||
|
ok = false;
|
||
|
LoadPromptWin.Instance.LoadTextPromptWindow("未设置过火面积", 1f);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
return ok;
|
||
|
}
|
||
|
|
||
|
private bool PolliceinfoSetJudge()
|
||
|
{
|
||
|
bool hasset = true;
|
||
|
if (string.IsNullOrEmpty(policecallpanel.callname) ||
|
||
|
string.IsNullOrEmpty(policecallpanel.phone)||
|
||
|
string.IsNullOrEmpty(policecallpanel.firePlace))
|
||
|
{
|
||
|
hasset = false;
|
||
|
LoadPromptWin.Instance.LoadTextPromptWindow("请先完善报警信息", 1f);
|
||
|
}
|
||
|
|
||
|
return hasset;
|
||
|
}
|
||
|
|
||
|
private KeyValuePair<int, int> GetFireTotalArea()
|
||
|
{
|
||
|
GameObject P_FireNormal = GameObject.Find("P_FireNormal");
|
||
|
GameObject P_FireLiquidLevel = GameObject.Find("P_FireLiquidLevel");
|
||
|
GameObject P_Leak1 = GameObject.Find("P_Leak1");
|
||
|
|
||
|
int fireMinAre = 0;
|
||
|
int fireMaxArea = 0;
|
||
|
|
||
|
foreach (Transform child in P_FireNormal.transform)
|
||
|
{
|
||
|
int tempMinFireArea = (int)child.GetComponent<FireInitialSizeSet>().selectedFireScale;
|
||
|
fireMinAre += tempMinFireArea;
|
||
|
|
||
|
int tempMaxFireArea = (int)child.GetComponent<FireInitialSizeSet>().selectedFireScale
|
||
|
+ child.GetComponent<FireSpreadCtrl>().spreadPoints.Count * 10;
|
||
|
fireMaxArea += tempMaxFireArea;
|
||
|
}
|
||
|
|
||
|
foreach (Transform child in P_FireLiquidLevel.transform)
|
||
|
{
|
||
|
int tempMinFireArea = Mathf.RoundToInt(child.GetComponent<BoxCollider>().size.x)
|
||
|
* Mathf.RoundToInt(child.GetComponent<BoxCollider>().size.z);
|
||
|
fireMinAre += tempMinFireArea;
|
||
|
|
||
|
int tempMaxFireArea = tempMinFireArea;
|
||
|
fireMaxArea += tempMaxFireArea;
|
||
|
}
|
||
|
|
||
|
foreach (Transform child in P_Leak1.transform)
|
||
|
{
|
||
|
int tempMaxFireArea = Mathf.RoundToInt(child.GetComponent<BoxCollider>().size.x)
|
||
|
* Mathf.RoundToInt(child.GetComponent<BoxCollider>().size.z);
|
||
|
fireMaxArea += tempMaxFireArea;
|
||
|
}
|
||
|
|
||
|
return new KeyValuePair<int, int>(fireMinAre, fireMaxArea);
|
||
|
}
|
||
|
}
|