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.
367 lines
15 KiB
367 lines
15 KiB
using AX.MessageSystem; |
|
using AX.NetworkSystem; |
|
using System; |
|
using System.Collections; |
|
using System.Collections.Generic; |
|
using UnityEngine; |
|
using UnityEngine.UI; |
|
|
|
public class PoliceCallPanel : MonoBehaviour |
|
{ |
|
public Transform PoliceCloseButton; |
|
|
|
public Transform CallMan; |
|
public Transform Phone; |
|
public Transform FirePlace; |
|
public Transform FireArea; |
|
public Transform FireReason; |
|
public Transform Trapped; |
|
public Transform FireLeave; |
|
public Transform Dangerous; |
|
public Transform PoliceCallButton; |
|
public Transform PoliceCallCancelButton; |
|
|
|
public Transform ArriveTimeTitle; |
|
|
|
public string callname; |
|
public string phone; |
|
public string firePlace; |
|
public string fireReason; |
|
public string fireArea; |
|
public string fireLevel; |
|
public string hasDangerous; |
|
public string hasTrapped; |
|
|
|
private string errortext; |
|
|
|
private Transform P_FireLiquidLevel; |
|
|
|
private Transform dis; |
|
private void Awake() |
|
{ |
|
dis = GameObject.Find("P_AllParent").transform.Find("P_Disasters"); |
|
MessageDispatcher.AddListener("LOAD_UIDISASTER", LoadUIDisaster); |
|
this.gameObject.SetActive(false); |
|
|
|
P_FireLiquidLevel = GameObject.Find("P_FireLiquidLevel").transform; |
|
} |
|
|
|
// Use this for initialization |
|
void Start() |
|
{ |
|
PoliceCloseButton.GetComponent<ButtonRecordByAC>().OutInterFaceButton = PoliceCloseButtonClick; |
|
CallMan.GetComponent<InputFieldRecordByAC>().OutInterFaceInPutField = CallManOnValueChange; |
|
Phone.GetComponent<InputFieldRecordByAC>().OutInterFaceInPutField = PhoneOnValueChange; |
|
FirePlace.GetComponent<InputFieldRecordByAC>().OutInterFaceInPutField = FirePlaceOnValueChange; |
|
FireArea.GetComponent<InputFieldRecordByAC>().OutInterFaceInPutField = FireAreaOnValueChange; |
|
FireReason.GetComponent<InputFieldRecordByAC>().OutInterFaceInPutField = FireReasonOnValueChange; |
|
FireLeave.GetComponent<DropDownRecordByAC>().OutInterFaceDropDown = FireLeaveOnValueChange; |
|
Dangerous.GetComponent<InputFieldRecordByAC>().OutInterFaceInPutField = DangerousOnValueChange; |
|
PoliceCallButton.GetComponent<ButtonRecordByAC>().OutInterFaceButton = PoliceCallButtonClick; |
|
PoliceCallCancelButton.GetComponent<ButtonRecordByAC>().OutInterFaceButton = PoliceCallCancelOnClick; |
|
|
|
fireReason = "不详"; |
|
fireArea = "不详"; |
|
hasDangerous = "不详"; |
|
fireLevel = "不详"; |
|
} |
|
|
|
public void OnEnable() |
|
{ |
|
int trap_wound = dis.Find("P_TrappedPerson").childCount + dis.Find("P_Wounded").childCount; |
|
Trapped.GetComponent<Text>().text = trap_wound > 0 ? "是" : "否"; |
|
} |
|
|
|
private void OnDestroy() |
|
{ |
|
MessageDispatcher.RemoveListener("LOAD_UIDISASTER", LoadUIDisaster); |
|
} |
|
|
|
private void LoadUIDisaster(IMessage obj) |
|
{ |
|
if (GameSettings.othersSettings.isSelectedDisaster) |
|
{ |
|
DataBind(); |
|
if (GameSettings.othersSettings.mode != Mode.DisasterManagement) |
|
{//若是练习或演习模式进入导调组界面,则不可以修改 |
|
CallMan.GetComponent<InputField>().interactable = false; |
|
Phone.GetComponent<InputField>().interactable = false; |
|
FirePlace.GetComponent<InputField>().interactable = false; |
|
FireArea.GetComponent<InputField>().interactable = false; |
|
FireReason.GetComponent<InputField>().interactable = false; |
|
FireLeave.GetComponent<Dropdown>().interactable = false; |
|
Dangerous.GetComponent<InputField>().interactable = false; |
|
} |
|
else |
|
{ |
|
if (!GameSettings.disasterSetting.isEdit) |
|
{//若是灾情库设置模式的查看,则不可以修改 |
|
CallMan.GetComponent<InputField>().interactable = false; |
|
Phone.GetComponent<InputField>().interactable = false; |
|
FirePlace.GetComponent<InputField>().interactable = false; |
|
FireArea.GetComponent<InputField>().interactable = false; |
|
FireReason.GetComponent<InputField>().interactable = false; |
|
FireLeave.GetComponent<Dropdown>().interactable = false; |
|
Dangerous.GetComponent<InputField>().interactable = false; |
|
PoliceCallButton.GetComponent<Button>().interactable = false; |
|
} |
|
else |
|
{ |
|
//若是灾情库设置模式的编辑,则可以修改 |
|
} |
|
} |
|
} |
|
} |
|
|
|
private void PoliceCloseButtonClick() |
|
{ |
|
gameObject.SetActive(false); |
|
} |
|
|
|
private void CallManOnValueChange(string value) |
|
{ |
|
if (!string.IsNullOrEmpty(value)) |
|
{ |
|
callname = value; |
|
} |
|
} |
|
|
|
private void PhoneOnValueChange(string value) |
|
{ |
|
if (!string.IsNullOrEmpty(value)) |
|
{ |
|
phone = value; |
|
} |
|
} |
|
private void FirePlaceOnValueChange(string value) |
|
{ |
|
if (!string.IsNullOrEmpty(value)) |
|
{ |
|
firePlace = value; |
|
} |
|
} |
|
|
|
private void FireAreaOnValueChange(string value) |
|
{ |
|
if (!string.IsNullOrEmpty(value)) |
|
{ |
|
fireArea = value; |
|
} |
|
else |
|
{ |
|
fireArea = "不详"; |
|
} |
|
} |
|
|
|
private void FireReasonOnValueChange(string value) |
|
{ |
|
if (!string.IsNullOrEmpty(value)) |
|
{ |
|
fireReason = value; |
|
} |
|
else |
|
{ |
|
fireReason = "不详"; |
|
} |
|
} |
|
|
|
private void FireLeaveOnValueChange(int value) |
|
{ |
|
fireLevel = FireLeave.GetComponent<Dropdown>().captionText.text; |
|
} |
|
|
|
private void DangerousOnValueChange(string value) |
|
{ |
|
if (!string.IsNullOrEmpty(value)) |
|
{ |
|
hasDangerous = value; |
|
} |
|
else |
|
{ |
|
hasDangerous = "不详"; |
|
} |
|
} |
|
|
|
private void PoliceCallButtonClick() |
|
{ |
|
if (string.IsNullOrEmpty(CallMan.GetComponent<InputField>().text) || CallMan.GetComponent<InputField>().text == "") |
|
{ |
|
errortext = "请填写报警人"; |
|
LoadPromptWin.Instance.LoadTextPromptWindow(errortext, 2f); |
|
} |
|
else |
|
{ |
|
|
|
if (string.IsNullOrEmpty(Phone.GetComponent<InputField>().text) || Phone.GetComponent<InputField>().text == "") |
|
{ |
|
errortext = "请填写电话号码"; |
|
LoadPromptWin.Instance.LoadTextPromptWindow(errortext, 2f); |
|
} |
|
else |
|
{ |
|
|
|
if (string.IsNullOrEmpty(FirePlace.GetComponent<InputField>().text) || FirePlace.GetComponent<InputField>().text == "") |
|
{ |
|
errortext = "请填写着火地点"; |
|
LoadPromptWin.Instance.LoadTextPromptWindow(errortext, 2f); |
|
} |
|
else |
|
{ |
|
PoliceCallData policedata = new PoliceCallData(); |
|
policedata.UserId = CurrentUserInfo.mySelf.Id; |
|
policedata.Name = callname; |
|
policedata.Phone = phone; |
|
policedata.FirePlace = firePlace; |
|
policedata.FireArea = fireArea; |
|
policedata.FireReason = fireReason; ; |
|
// Transform dis = GameObject.Find("P_AllParent").transform.Find("P_Disasters"); |
|
int trap_wound = dis.Find("P_TrappedPerson").childCount + dis.Find("P_Wounded").childCount; |
|
policedata.HasTrapped = trap_wound > 0 ? "是" : "否"; |
|
policedata.FireLevel = fireLevel; |
|
policedata.HasDangerous = hasDangerous; |
|
//时间键值对集合 |
|
if (GameSettings.othersSettings.mode != Mode.DisasterManagement) |
|
{ |
|
policedata.RoomID = CurrentUserInfo.room.Id; |
|
|
|
policedata.ArriveTimeList = ArriveTimeTitle.GetComponent<ArriveTimeContent>().ArriveTimeList; |
|
//Debug.Log(policedata.Name+"/"+policedata.Phone+"/"+policedata.FirePlace+"/"+policedata.FireArea+"/" |
|
// +policedata.FireReason+"/"+policedata.HasTrapped+"/"+policedata.HasDangerous+"/"+policedata.FireLevel); |
|
|
|
NetworkManager.Default.SendAsync("POLICE_CALL_SYNC", policedata); |
|
|
|
CallMan.GetComponent<InputField>().interactable = false; |
|
Phone.GetComponent<InputField>().interactable = false; |
|
FirePlace.GetComponent<InputField>().interactable = false; |
|
FireArea.GetComponent<InputField>().interactable = false; |
|
FireReason.GetComponent<InputField>().interactable = false; |
|
FireLeave.GetComponent<Dropdown>().interactable = false; |
|
Dangerous.GetComponent<InputField>().interactable = false; |
|
LoadPromptWin.Instance.LoadTextPromptWindow("已报警", 1f); |
|
PoliceCallButton.GetComponent<Button>().interactable = false; |
|
|
|
GameSettings.othersSettings.isStartDrill = true; |
|
transform.parent.Find("TopPanel/Tool/Button").GetComponentInChildren<Text>().text = "结束"; |
|
//思杨木业设置为可以随意设置灾情,去掉之前报警之后不能设置灾情的限制 |
|
// SetDisableInCustomPractice(); |
|
//导调组赋值灾情设置信息 |
|
//if (FindObjectOfType<DrillBeginButton>()&&FindObjectOfType<VictoryConditionPanel>()) |
|
//{ |
|
// FindObjectOfType<DrillBeginButton>().Victorysetting = FindObjectOfType<VictoryConditionPanel>().VictoryConditionSetting(); |
|
//} |
|
|
|
if (transform.parent.Find("TopPanel/Tool/Button").GetComponent<DrillBeginButton>() |
|
&& transform.parent.Find("SettingPanel/VictoryConditionTitle").GetComponent<VictoryConditionPanel>()) |
|
{ |
|
transform.parent.Find("TopPanel/Tool/Button").GetComponent<DrillBeginButton>().Victorysetting = |
|
transform.parent.Find("SettingPanel/VictoryConditionTitle").GetComponent<VictoryConditionPanel>().VictoryConditionSetting(); |
|
|
|
} |
|
// OilSetManager.GetInstance.SetInteractable();//油罐UI设置 |
|
//给导调组赋值报警信息 |
|
GameSettings.disasterSetting.policeCallData = policedata; |
|
MessageDispatcher.SendMessage("police_call"); |
|
|
|
//向服务端申请开始计时 |
|
KeyValuePair<long, bool> pair = new KeyValuePair<long, bool>(CurrentUserInfo.room.Id, true); |
|
NetworkManager.Default.SendAsync("TIMER_ENABLE_SYNC", pair); |
|
|
|
foreach (Transform child in P_FireLiquidLevel) |
|
{ |
|
if (child.GetComponent<FireLiquidLevelCtrl>().showTime != "00:00:00") |
|
{ |
|
NetworkManager.Default.SendAsync("SET_LIQUIP_HIDE_SYNC", child.GetComponent<BaseGameObjInfo>().gameObjID); |
|
child.gameObject.SetActive(false); |
|
} |
|
} |
|
} |
|
|
|
StartCoroutine(Close()); |
|
} |
|
} |
|
} |
|
} |
|
private void PoliceCallCancelOnClick() |
|
{ |
|
gameObject.SetActive(false); |
|
} |
|
private IEnumerator Close() |
|
{ |
|
yield return new WaitForSeconds(1f); |
|
gameObject.SetActive(false); |
|
} |
|
/// <summary> |
|
/// 灾情库进来报警信息绑定 |
|
/// </summary> |
|
private void DataBind() |
|
{ |
|
CallMan.GetComponent<InputField>().text = GameSettings.othersSettings.disaster.PoliceCallData.Name; |
|
Phone.GetComponent<InputField>().text = GameSettings.othersSettings.disaster.PoliceCallData.Phone; |
|
FirePlace.GetComponent<InputField>().text = GameSettings.othersSettings.disaster.PoliceCallData.FirePlace; |
|
FireArea.GetComponent<InputField>().text = GameSettings.othersSettings.disaster.PoliceCallData.FireArea; |
|
FireReason.GetComponent<InputField>().text = GameSettings.othersSettings.disaster.PoliceCallData.FireReason; |
|
Trapped.GetComponent<Text>().text = GameSettings.othersSettings.disaster.PoliceCallData.HasTrapped; |
|
Dropdown drop = FireLeave.GetComponent<Dropdown>(); |
|
for (int i = 0; i < drop.options.Count; i++) |
|
{ |
|
if (drop.options[i].text == GameSettings.othersSettings.disaster.PoliceCallData.FireLevel) |
|
{ |
|
drop.value = i; |
|
} |
|
} |
|
Dangerous.GetComponent<InputField>().text = GameSettings.othersSettings.disaster.PoliceCallData.HasDangerous; |
|
callname = GameSettings.othersSettings.disaster.PoliceCallData.Name; |
|
phone = GameSettings.othersSettings.disaster.PoliceCallData.Phone; |
|
firePlace = GameSettings.othersSettings.disaster.PoliceCallData.FirePlace; |
|
fireArea = GameSettings.othersSettings.disaster.PoliceCallData.FireArea; ; |
|
fireReason = GameSettings.othersSettings.disaster.PoliceCallData.FireReason; |
|
hasTrapped = GameSettings.othersSettings.disaster.PoliceCallData.HasTrapped; |
|
fireLevel = GameSettings.othersSettings.disaster.PoliceCallData.FireLevel; |
|
hasDangerous = GameSettings.othersSettings.disaster.PoliceCallData.HasDangerous; ; |
|
} |
|
/// <summary> |
|
/// 自定义练习模式下设置灾情设置按钮不可用 |
|
/// </summary> |
|
private void SetDisableInCustomPractice() |
|
{ |
|
if (!GameSettings.othersSettings.isSelectedDisaster) |
|
{ |
|
if (GameSettings.othersSettings.mode == Mode.Practice) |
|
{ |
|
Transform SettingPanel = transform.parent.Find("SettingPanel"); |
|
SettingPanel.GetComponent<ToggleGroup>().SetAllTogglesOff(); |
|
ScrollRect[] scrollrect = SettingPanel.GetComponentsInChildren<ScrollRect>(true); |
|
for (int i = 0; i < scrollrect.Length; i++) |
|
{ |
|
Toggle[] alltoggle = scrollrect[i].GetComponentsInChildren<Toggle>(true); |
|
Dropdown[] alldrop = scrollrect[i].GetComponentsInChildren<Dropdown>(true); |
|
InputField[] allinput = scrollrect[i].GetComponentsInChildren<InputField>(true); |
|
if (alltoggle.Length > 0) |
|
{ |
|
for (int toggle = 0; toggle < alltoggle.Length; toggle++) |
|
{ |
|
alltoggle[toggle].interactable = false; |
|
} |
|
} |
|
if (alldrop.Length > 0) |
|
{ |
|
for (int drop = 0; drop < alldrop.Length; drop++) |
|
{ |
|
alldrop[drop].interactable = false; |
|
} |
|
} |
|
if (allinput.Length > 0) |
|
{ |
|
for (int input = 0; input < allinput.Length; input++) |
|
{ |
|
allinput[input].interactable = false; |
|
} |
|
} |
|
} |
|
Transform OilTankSet = transform.parent.Find("OilTankSet"); |
|
OilTankSet.GetComponent<OilSetManager>().SetInteractable(); |
|
|
|
} |
|
} |
|
} |
|
}
|
|
|