|
|
|
using System;
|
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using UnityEngine;
|
|
|
|
using UnityEngine.UI;
|
|
|
|
using AX.MessageSystem;
|
|
|
|
using AX.NetworkSystem;
|
|
|
|
using UnityEngine.AI;
|
|
|
|
|
|
|
|
public class FireSpreadPanel : BaseAttributeSet {
|
|
|
|
|
|
|
|
private static FireSpreadPanel instance;
|
|
|
|
|
|
|
|
public static FireSpreadPanel Instance
|
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
|
|
|
if (instance == null)
|
|
|
|
{
|
|
|
|
GameObject obj = Resources.Load<GameObject>("Common/FireSpreadPanel");
|
|
|
|
GameObject clone = Instantiate(obj, GameObject.Find("Canvas").transform);
|
|
|
|
clone.transform.SetAsLastSibling();
|
|
|
|
clone.name = "FireSpreadPanel";
|
|
|
|
clone.transform.position = Vector3.zero;
|
|
|
|
instance = clone.GetComponent<FireSpreadPanel>();
|
|
|
|
instance.Init();
|
|
|
|
}
|
|
|
|
return instance;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
InputField combustibleInputField;//燃烧物输入框
|
|
|
|
Dropdown combustibleDropdown;//燃烧物选择下拉框
|
|
|
|
Toggle combustibleToggle;//燃烧物输入和选择之间的切换
|
|
|
|
|
|
|
|
Dropdown InitialSizeDropdown;//火源初始大小设置下来框
|
|
|
|
|
|
|
|
InputField firePostion;//位置
|
|
|
|
|
|
|
|
Toggle roadSpread;//路径蔓延
|
|
|
|
Toggle areSpread;//区域蔓延
|
|
|
|
public Toggle aroundSpread;//四周蔓延
|
|
|
|
Toggle aotoSpread;//自动蔓延
|
|
|
|
|
|
|
|
Dropdown spreadSpeedDropdown;//蔓延速度
|
|
|
|
|
|
|
|
public bool isLoad;//是否是加载而不是换选蔓延方式和重置
|
|
|
|
|
|
|
|
Button sure;
|
|
|
|
Button Reset;
|
|
|
|
|
|
|
|
void Init()
|
|
|
|
{
|
|
|
|
combustibleInputField = transform.Find("Comburent/InputField").GetComponent<InputField>();
|
|
|
|
combustibleDropdown = transform.Find("Comburent/Dropdown").GetComponent<Dropdown>();
|
|
|
|
combustibleToggle = transform.Find("Comburent/Toggle").GetComponent<Toggle>();
|
|
|
|
|
|
|
|
firePostion = transform.Find("Position/InputField").GetComponent<InputField>();
|
|
|
|
|
|
|
|
InitialSizeDropdown = transform.Find("InitialSize/Dropdown").GetComponent<Dropdown>();
|
|
|
|
InitialSizeDropdown.onValueChanged.AddListener(InitialSizeSet);
|
|
|
|
|
|
|
|
roadSpread = transform.Find("FireSpread/SpreadType/RoadSpread").GetComponent<Toggle>();
|
|
|
|
roadSpread.onValueChanged.AddListener(RoadSpreadSelected);
|
|
|
|
areSpread = transform.Find("FireSpread/SpreadType/AreSpread").GetComponent<Toggle>();
|
|
|
|
areSpread.onValueChanged.AddListener(AreSpreadSelected);
|
|
|
|
aroundSpread = transform.Find("FireSpread/SpreadType/AroundSpread").GetComponent<Toggle>();
|
|
|
|
aroundSpread.onValueChanged.AddListener(AroundSpreadSelected);
|
|
|
|
aotoSpread = transform.Find("FireSpread/SpreadType/AotoSpread").GetComponent<Toggle>();
|
|
|
|
aotoSpread.onValueChanged.AddListener(AotoSpreadSelected);
|
|
|
|
|
|
|
|
spreadSpeedDropdown = transform.Find("FireSpread/SpreadSpeed/Dropdown").GetComponent<Dropdown>();
|
|
|
|
|
|
|
|
sure = transform.Find("Sure").GetComponent<Button>();
|
|
|
|
Reset = transform.Find("Reset").GetComponent<Button>();
|
|
|
|
}
|
|
|
|
|
|
|
|
public override void OnDisable()
|
|
|
|
{
|
|
|
|
base.OnDisable();
|
|
|
|
Close();
|
|
|
|
}
|
|
|
|
|
|
|
|
public override void OnDestroy()
|
|
|
|
{
|
|
|
|
base.OnDestroy();
|
|
|
|
InitialSizeDropdown.onValueChanged.RemoveListener(InitialSizeSet);
|
|
|
|
|
|
|
|
roadSpread.onValueChanged.RemoveListener(RoadSpreadSelected);
|
|
|
|
areSpread.onValueChanged.RemoveListener(AreSpreadSelected);
|
|
|
|
aroundSpread.onValueChanged.RemoveListener(AroundSpreadSelected);
|
|
|
|
aotoSpread.onValueChanged.RemoveListener(AotoSpreadSelected);
|
|
|
|
}
|
|
|
|
|
|
|
|
private void LoadUIDisaster()
|
|
|
|
{
|
|
|
|
if (GameSettings.othersSettings.isSelectedDisaster)
|
|
|
|
{
|
|
|
|
if (GameSettings.othersSettings.mode != Mode.DisasterManagement)
|
|
|
|
{//若是练习或演习模式进入导调组界面,则不可以修改
|
|
|
|
//combustibleInputField.interactable = false;
|
|
|
|
//combustibleDropdown.interactable = false;
|
|
|
|
//combustibleToggle.interactable = false;
|
|
|
|
//firePostion.interactable = false;
|
|
|
|
//InitialSizeDropdown.interactable = false;
|
|
|
|
//roadSpread.interactable = false;
|
|
|
|
//areSpread.interactable = false;
|
|
|
|
//aroundSpread.interactable = false;
|
|
|
|
//aotoSpread.interactable = false;
|
|
|
|
//spreadSpeedDropdown.interactable = false;
|
|
|
|
//sure.interactable = false;
|
|
|
|
//Reset.interactable = false;
|
|
|
|
|
|
|
|
////控制不能画蔓延范围
|
|
|
|
//InputManager.skill = false;
|
|
|
|
//InputManager.cloneObjType = CloneObjType.None;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (!GameSettings.disasterSetting.isEdit)
|
|
|
|
{//若是灾情库设置模式的查看,则不可以修改
|
|
|
|
combustibleInputField.interactable = false;
|
|
|
|
combustibleDropdown.interactable = false;
|
|
|
|
combustibleToggle.interactable = false;
|
|
|
|
firePostion.interactable = false;
|
|
|
|
InitialSizeDropdown.interactable = false;
|
|
|
|
roadSpread.interactable = false;
|
|
|
|
areSpread.interactable = false;
|
|
|
|
aroundSpread.interactable = false;
|
|
|
|
aotoSpread.interactable = false;
|
|
|
|
spreadSpeedDropdown.interactable = false;
|
|
|
|
sure.interactable = false;
|
|
|
|
Reset.interactable = false;
|
|
|
|
|
|
|
|
//控制不能画蔓延范围
|
|
|
|
InputManager.skill = false;
|
|
|
|
InputManager.cloneObjType = CloneObjType.None;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
//若是灾情库设置模式的编辑,则可以修改
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void InitialSizeSet(int arg0)
|
|
|
|
{
|
|
|
|
int selectedFireScale = int.Parse(InitialSizeDropdown.options[arg0].text.ToString());
|
|
|
|
MessageDispatcher.SendMessage(chooseObj.GetComponent<BaseGameObjInfo>().gameObjID, "FIRE_INITIALSIZE_SET", selectedFireScale);
|
|
|
|
}
|
|
|
|
|
|
|
|
private void RoadSpreadSelected(bool arg0)
|
|
|
|
{
|
|
|
|
if (arg0)
|
|
|
|
{
|
|
|
|
ResetSpreadPath();
|
|
|
|
|
|
|
|
spreadSpeedDropdown.interactable = true;
|
|
|
|
|
|
|
|
MessageDispatcher.SendMessage("ROAD_SPREAD_SELECTED", arg0);
|
|
|
|
|
|
|
|
CloneFireSpreadLine.instance.spreadedFireGameObjID = chooseObj.GetComponent<BaseGameObjInfo>().gameObjID;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
spreadSpeedDropdown.interactable = false;
|
|
|
|
|
|
|
|
CloneFireSpreadLine.instance.startPoint = Vector3.zero;
|
|
|
|
|
|
|
|
MessageDispatcher.SendMessage("ROAD_SPREAD_SELECTED", arg0);
|
|
|
|
|
|
|
|
CloneFireSpreadLine.instance.spreadedFireGameObjID = -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void AreSpreadSelected(bool arg0)
|
|
|
|
{
|
|
|
|
if (arg0)
|
|
|
|
{
|
|
|
|
ResetSpreadPath();
|
|
|
|
|
|
|
|
spreadSpeedDropdown.interactable = true;
|
|
|
|
|
|
|
|
MessageDispatcher.SendMessage("ARE_SPREAD_SELECTED", arg0);
|
|
|
|
|
|
|
|
CloneFireSpreadLine.instance.spreadedFireGameObjID = chooseObj.GetComponent<BaseGameObjInfo>().gameObjID;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
spreadSpeedDropdown.interactable = false;
|
|
|
|
|
|
|
|
CloneFireSpreadLine.instance.startPoint = Vector3.zero;
|
|
|
|
|
|
|
|
MessageDispatcher.SendMessage("ARE_SPREAD_SELECTED", arg0);
|
|
|
|
|
|
|
|
CloneFireSpreadLine.instance.spreadedFireGameObjID = -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void AroundSpreadSelected(bool arg0)
|
|
|
|
{
|
|
|
|
if (arg0)
|
|
|
|
{
|
|
|
|
ResetSpreadPath();
|
|
|
|
|
|
|
|
spreadSpeedDropdown.interactable = true;
|
|
|
|
|
|
|
|
CloneFireSpreadLine.instance.startPoint = Vector3.zero;
|
|
|
|
|
|
|
|
MessageDispatcher.SendMessage("AROUND_SPREAD_SELECTED", arg0);
|
|
|
|
|
|
|
|
CloneFireSpreadLine.instance.spreadedFireGameObjID = chooseObj.GetComponent<BaseGameObjInfo>().gameObjID;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
spreadSpeedDropdown.interactable = false;
|
|
|
|
|
|
|
|
CloneFireSpreadLine.instance.startPoint = Vector3.zero;
|
|
|
|
|
|
|
|
MessageDispatcher.SendMessage("AROUND_SPREAD_SELECTED", arg0);
|
|
|
|
|
|
|
|
CloneFireSpreadLine.instance.spreadedFireGameObjID = -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void AotoSpreadSelected(bool arg0)
|
|
|
|
{
|
|
|
|
if (arg0)
|
|
|
|
{
|
|
|
|
ResetSpreadPath();
|
|
|
|
|
|
|
|
spreadSpeedDropdown.interactable = true;
|
|
|
|
|
|
|
|
MessageDispatcher.SendMessage("AOTO_SPREAD_SELECTED", arg0);
|
|
|
|
|
|
|
|
CloneFireSpreadLine.instance.spreadedFireGameObjID = chooseObj.GetComponent<BaseGameObjInfo>().gameObjID;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
spreadSpeedDropdown.interactable = false;
|
|
|
|
|
|
|
|
CloneFireSpreadLine.instance.startPoint = Vector3.zero;
|
|
|
|
|
|
|
|
MessageDispatcher.SendMessage("AOTO_SPREAD_SELECTED", arg0);
|
|
|
|
|
|
|
|
CloneFireSpreadLine.instance.spreadedFireGameObjID = -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public override void OpenPanel()
|
|
|
|
{
|
|
|
|
if (!GameSettings.othersSettings.isStartDrill)
|
|
|
|
{
|
|
|
|
if (chooseObj.GetComponent<FireSpreadCtrl>().isSpreading)
|
|
|
|
{
|
|
|
|
LoadPromptWin.Instance.LoadTextPromptWindow("蔓延过程中不能重新设置!", 1f);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//else
|
|
|
|
//{
|
|
|
|
// LoadPromptWin.Instance.LoadTextPromptWindow("开始演练后不能设置!", 1f);
|
|
|
|
// return;
|
|
|
|
//}
|
|
|
|
|
|
|
|
base.OpenPanel();
|
|
|
|
LoadUIDisaster();
|
|
|
|
gameObject.SetActive(true);
|
|
|
|
if (chooseObj.GetComponent<FireSpreadCtrl>())
|
|
|
|
{
|
|
|
|
if (chooseObj.GetComponent<NavMeshObstacle>())
|
|
|
|
{
|
|
|
|
chooseObj.GetComponent<NavMeshObstacle>().enabled = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 打开火属性设置窗口时,加载数据
|
|
|
|
/// </summary>
|
|
|
|
public override void LoadObjData()
|
|
|
|
{
|
|
|
|
var fireSpreadCtrl = chooseObj.GetComponent<FireSpreadCtrl>();
|
|
|
|
|
|
|
|
//isLoad = true;
|
|
|
|
|
|
|
|
InputManager.skill = true;
|
|
|
|
InputManager.cloneObjType = CloneObjType.FireSpreadLine;
|
|
|
|
CloneFireSpreadLine.instance.spreadedFireGameObjID = chooseObj.GetComponent<BaseGameObjInfo>().gameObjID;
|
|
|
|
|
|
|
|
RefreshFireAttribute(fireSpreadCtrl);
|
|
|
|
HideAllSpreadPath();
|
|
|
|
ShowSelectedFireSpreadPath();
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 刷新面板数据
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="fireSpreadCtrl"></param>
|
|
|
|
private void RefreshFireAttribute(FireSpreadCtrl fireSpreadCtrl)
|
|
|
|
{
|
|
|
|
combustibleToggle.isOn = fireSpreadCtrl.combustibleInputWay;//设置燃烧物的输入方式
|
|
|
|
|
|
|
|
var fireAttribute = fireSpreadCtrl.fireAttribute;
|
|
|
|
|
|
|
|
if (!combustibleToggle.isOn)
|
|
|
|
{
|
|
|
|
List<Dropdown.OptionData> options = combustibleDropdown.options;
|
|
|
|
if (fireAttribute.comburent == "")
|
|
|
|
{
|
|
|
|
combustibleDropdown.value = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for (int i = 0; i < options.Count; i++)
|
|
|
|
{
|
|
|
|
if (options[i].text == fireAttribute.comburent)
|
|
|
|
{
|
|
|
|
combustibleDropdown.value = i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
combustibleInputField.text = "";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
combustibleInputField.text = fireAttribute.comburent;
|
|
|
|
|
|
|
|
combustibleDropdown.value = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
firePostion.text = fireAttribute.position;
|
|
|
|
|
|
|
|
List<Dropdown.OptionData> InitialSizeOptions = InitialSizeDropdown.options;
|
|
|
|
if (fireAttribute.initialSize == 0)
|
|
|
|
{
|
|
|
|
InitialSizeDropdown.value = 2;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for (int i = 0; i < InitialSizeOptions.Count; i++)
|
|
|
|
{
|
|
|
|
if (InitialSizeOptions[i].text == fireAttribute.initialSize.ToString())
|
|
|
|
{
|
|
|
|
InitialSizeDropdown.value = i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!roadSpread.isOn && !areSpread.isOn && !aroundSpread.isOn && !aotoSpread.isOn)
|
|
|
|
{
|
|
|
|
isLoad = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (fireAttribute.spreadWay)
|
|
|
|
{
|
|
|
|
case SpreadWay.None:
|
|
|
|
roadSpread.isOn = false;
|
|
|
|
areSpread.isOn = false;
|
|
|
|
aroundSpread.isOn = false;
|
|
|
|
aotoSpread.isOn = false;
|
|
|
|
break;
|
|
|
|
case SpreadWay.Road:
|
|
|
|
roadSpread.isOn = true;
|
|
|
|
areSpread.isOn = false;
|
|
|
|
aroundSpread.isOn = false;
|
|
|
|
aotoSpread.isOn = false;
|
|
|
|
break;
|
|
|
|
case SpreadWay.Are:
|
|
|
|
roadSpread.isOn = false;
|
|
|
|
areSpread.isOn = true;
|
|
|
|
aroundSpread.isOn = false;
|
|
|
|
aotoSpread.isOn = false;
|
|
|
|
break;
|
|
|
|
case SpreadWay.Around:
|
|
|
|
roadSpread.isOn = false;
|
|
|
|
areSpread.isOn = false;
|
|
|
|
aroundSpread.isOn = true;
|
|
|
|
aotoSpread.isOn = false;
|
|
|
|
break;
|
|
|
|
case SpreadWay.Aoto:
|
|
|
|
roadSpread.isOn = false;
|
|
|
|
areSpread.isOn = false;
|
|
|
|
aroundSpread.isOn = false;
|
|
|
|
aotoSpread.isOn = true;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
List<Dropdown.OptionData> speedOptions = spreadSpeedDropdown.options;
|
|
|
|
if (fireAttribute.spreadSpeed == 0)
|
|
|
|
{
|
|
|
|
spreadSpeedDropdown.value = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for (int i = 0; i < speedOptions.Count; i++)
|
|
|
|
{
|
|
|
|
if (speedOptions[i].text == fireAttribute.spreadSpeed.ToString())
|
|
|
|
{
|
|
|
|
spreadSpeedDropdown.value = i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
CloneFireSpreadLine.instance.pathPoints.Clear();
|
|
|
|
foreach (Vector3 item in fireAttribute.pathPoints)
|
|
|
|
{
|
|
|
|
CloneFireSpreadLine.instance.pathPoints.Add(item);
|
|
|
|
}
|
|
|
|
CloneFireSpreadLine.instance.currentPathPointsCount = CloneFireSpreadLine.instance.pathPoints.Count;
|
|
|
|
|
|
|
|
if (CloneFireSpreadLine.instance.pathPoints.Count > 0)
|
|
|
|
{
|
|
|
|
CloneFireSpreadLine.instance.startPoint = CloneFireSpreadLine.instance.pathPoints[CloneFireSpreadLine.instance.pathPoints.Count - 1];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override void ResetData(GameObject dataObj)
|
|
|
|
{
|
|
|
|
Cancel();
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 点击确定按钮
|
|
|
|
/// </summary>
|
|
|
|
public void Confirm()
|
|
|
|
{
|
|
|
|
if (roadSpread.isOn || areSpread.isOn || aroundSpread.isOn || aotoSpread.isOn)
|
|
|
|
{
|
|
|
|
if (spreadSpeedDropdown.value == 0)
|
|
|
|
{
|
|
|
|
string textPromptContent = "请选择蔓延速度!";
|
|
|
|
float stayTime = 1f;
|
|
|
|
LoadPromptWin.Instance.LoadTextPromptWindow(textPromptContent, stayTime);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (CloneFireSpreadLine.instance.pathPoints.Count == 0 || CloneFireSpreadLine.instance.pathPoints.Count == 1)
|
|
|
|
{
|
|
|
|
string textPromptContent = "请设置蔓延路径或范围!";
|
|
|
|
float stayTime = 1f;
|
|
|
|
LoadPromptWin.Instance.LoadTextPromptWindow(textPromptContent, stayTime);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (areSpread.isOn || aroundSpread.isOn)
|
|
|
|
{
|
|
|
|
if (CloneFireSpreadLine.instance.pathPoints.Count < 3)
|
|
|
|
{
|
|
|
|
string textPromptContent = "没有形成多边形!";
|
|
|
|
float stayTime = 1f;
|
|
|
|
LoadPromptWin.Instance.LoadTextPromptWindow(textPromptContent, stayTime);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var fireSpreadCtrl = chooseObj.GetComponent<FireSpreadCtrl>();
|
|
|
|
var fireAttribute = fireSpreadCtrl.fireAttribute;
|
|
|
|
|
|
|
|
string comburent = "";
|
|
|
|
if (!combustibleToggle.isOn)
|
|
|
|
{
|
|
|
|
comburent = combustibleDropdown.options[combustibleDropdown.value].text.ToString();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
comburent = combustibleInputField.text;
|
|
|
|
}
|
|
|
|
|
|
|
|
fireAttribute.comburent = comburent;
|
|
|
|
fireAttribute.position = firePostion.text;
|
|
|
|
|
|
|
|
int selectedFireScale = int.Parse(InitialSizeDropdown.options[InitialSizeDropdown.value].text.ToString());
|
|
|
|
fireAttribute.initialSize = selectedFireScale;
|
|
|
|
|
|
|
|
if (roadSpread.isOn)
|
|
|
|
{
|
|
|
|
fireAttribute.spreadWay = SpreadWay.Road;
|
|
|
|
}
|
|
|
|
else if (areSpread.isOn)
|
|
|
|
{
|
|
|
|
fireAttribute.spreadWay = SpreadWay.Are;
|
|
|
|
}
|
|
|
|
else if (aroundSpread.isOn)
|
|
|
|
{
|
|
|
|
fireAttribute.spreadWay = SpreadWay.Around;
|
|
|
|
}
|
|
|
|
else if (aotoSpread.isOn)
|
|
|
|
{
|
|
|
|
fireAttribute.spreadWay = SpreadWay.Aoto;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (roadSpread.isOn || areSpread.isOn || aroundSpread.isOn || aotoSpread.isOn)
|
|
|
|
{
|
|
|
|
string spreadSpeed = spreadSpeedDropdown.options[spreadSpeedDropdown.value].text.ToString();
|
|
|
|
fireAttribute.spreadSpeed = int.Parse(spreadSpeed);
|
|
|
|
CloneFireSpreadLine.instance.SetPathPoints(fireAttribute.pathPoints);
|
|
|
|
|
|
|
|
CloneFireSpreadLine.instance.currentPathPointsCount = fireAttribute.pathPoints.Count;
|
|
|
|
|
|
|
|
fireSpreadCtrl.GetSpreadFirePositions();
|
|
|
|
}
|
|
|
|
|
|
|
|
//火初始状态同步
|
|
|
|
if (GameSettings.othersSettings.mode!=Mode.DisasterManagement)
|
|
|
|
{
|
|
|
|
FireOriginAttributeSyncData arg = new FireOriginAttributeSyncData();
|
|
|
|
arg.FireAttribute = fireAttribute;
|
|
|
|
arg.SendUserID = CurrentUserInfo.mySelf.Id;
|
|
|
|
arg.gameObjID = chooseObj.GetComponent<BaseGameObjInfo>().gameObjID;
|
|
|
|
NetworkManager.Default.SendAsync("FIRE_ORIGINAL_ATTRIBUTE", arg);
|
|
|
|
}
|
|
|
|
gameObject.SetActive(false);
|
|
|
|
if (chooseObj.GetComponent<FireSpreadCtrl>())
|
|
|
|
{
|
|
|
|
if (chooseObj.GetComponent<NavMeshObstacle>())
|
|
|
|
{
|
|
|
|
chooseObj.GetComponent<NavMeshObstacle>().enabled = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public void Close()
|
|
|
|
{
|
|
|
|
HideAllSpreadPath();
|
|
|
|
|
|
|
|
CloneFireSpreadLine.instance.pathPoints.Clear();
|
|
|
|
|
|
|
|
InputManager.skill = false;
|
|
|
|
InputManager.cloneObjType = CloneObjType.None;
|
|
|
|
|
|
|
|
isLoad = false;
|
|
|
|
|
|
|
|
gameObject.SetActive(false);
|
|
|
|
if (chooseObj.GetComponent<FireSpreadCtrl>())
|
|
|
|
{
|
|
|
|
if (chooseObj.GetComponent<NavMeshObstacle>())
|
|
|
|
{
|
|
|
|
chooseObj.GetComponent<NavMeshObstacle>().enabled = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void Cancel()
|
|
|
|
{
|
|
|
|
HideAllSpreadPath();
|
|
|
|
|
|
|
|
//点击取消时执行删除不保存的路径点和已克隆出来的边。因确定而隐藏窗口调了Close()方法,但不执行删除。所以点击取消时单独封装个方法
|
|
|
|
CloneFireSpreadLine.instance.Cancel();
|
|
|
|
|
|
|
|
CloneFireSpreadLine.instance.pathPoints.Clear();
|
|
|
|
|
|
|
|
InputManager.skill = false;
|
|
|
|
InputManager.cloneObjType = CloneObjType.None;
|
|
|
|
|
|
|
|
isLoad = false;
|
|
|
|
|
|
|
|
gameObject.SetActive(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 点击重置范围按钮
|
|
|
|
/// </summary>
|
|
|
|
public void ResetSpreadPath()
|
|
|
|
{
|
|
|
|
//重新初始化起始点
|
|
|
|
if (aroundSpread.isOn)
|
|
|
|
{
|
|
|
|
CloneFireSpreadLine.instance.startPoint = Vector3.zero;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
|
|
|
|
RaycastHit hitDown;
|
|
|
|
Physics.Raycast(chooseObj.transform.position, Vector3.down, out hitDown, Mathf.Infinity);
|
|
|
|
NavMeshHit hit = new NavMeshHit();
|
|
|
|
bool isFindedPath = NavMesh.SamplePosition(hitDown.point, out hit, 0.5f, NavMesh.AllAreas);
|
|
|
|
Debug.Log("isFindedPath---" + isFindedPath);
|
|
|
|
if (/*hitDown.transform.gameObject.layer == LayerMask.NameToLayer("CarRoad")
|
|
|
|
|| hitDown.transform.gameObject.layer == LayerMask.NameToLayer("SoldierRoad")*/
|
|
|
|
isFindedPath)
|
|
|
|
{
|
|
|
|
CloneFireSpreadLine.instance.startPoint = new Vector3(chooseObj.transform.position.x,
|
|
|
|
hitDown.transform.position.y,
|
|
|
|
chooseObj.transform.position.z);
|
|
|
|
CloneFireSpreadLine.instance.pathPoints.Add(CloneFireSpreadLine.instance.startPoint);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isLoad)
|
|
|
|
{
|
|
|
|
isLoad = false;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
CloneFireSpreadLine.instance.ResetSpreadPath(chooseObj.GetComponent<BaseGameObjInfo>().GameObjID);
|
|
|
|
|
|
|
|
chooseObj.GetComponent<FireSpreadCtrl>().ResetSpreadPathsAndPoints();
|
|
|
|
|
|
|
|
DeleteSpreadedFire(chooseObj.transform.parent);
|
|
|
|
|
|
|
|
//重置完后,初始化下一次蔓延范围的初始点
|
|
|
|
if (CloneFireSpreadLine.instance.pathPoints.Count == 0
|
|
|
|
&& !aroundSpread.isOn)
|
|
|
|
{
|
|
|
|
RaycastHit hitDown;
|
|
|
|
Physics.Raycast(chooseObj.transform.position, Vector3.down, out hitDown, Mathf.Infinity);
|
|
|
|
NavMeshHit hit = new NavMeshHit();
|
|
|
|
bool isFindedPath = NavMesh.SamplePosition(hitDown.point, out hit, 0.5f, NavMesh.AllAreas);
|
|
|
|
if (/*hitDown.transform.gameObject.layer == LayerMask.NameToLayer("CarRoad")
|
|
|
|
|| hitDown.transform.gameObject.layer == LayerMask.NameToLayer("SoldierRoad")*/
|
|
|
|
isFindedPath)
|
|
|
|
{
|
|
|
|
CloneFireSpreadLine.instance.startPoint = new Vector3(chooseObj.transform.position.x,
|
|
|
|
hitDown.transform.position.y,
|
|
|
|
chooseObj.transform.position.z);
|
|
|
|
CloneFireSpreadLine.instance.pathPoints.Add(CloneFireSpreadLine.instance.startPoint);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void DeleteSpreadedFire(Transform spreadedFireParent)
|
|
|
|
{
|
|
|
|
foreach (Transform child in spreadedFireParent)
|
|
|
|
{
|
|
|
|
if (child.GetComponent<SpreadedFireCtrl>()
|
|
|
|
&& child.GetComponent<SpreadedFireCtrl>().fireGameObjID == chooseObj.GetComponent<BaseGameObjInfo>().gameObjID)
|
|
|
|
{
|
|
|
|
EntitiesManager.Instance.DeleteObj(child.gameObject);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void FireSpreadPreview()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
private void HideAllSpreadPath()
|
|
|
|
{
|
|
|
|
MessageDispatcher.SendMessage("HIDE_ALL_SPREADPATH");
|
|
|
|
}
|
|
|
|
|
|
|
|
private void ShowSelectedFireSpreadPath()
|
|
|
|
{
|
|
|
|
MessageDispatcher.SendMessage("SHOW_SELECTEDFIRE_SPREADPATH", chooseObj.GetComponent<BaseGameObjInfo>().GameObjID);
|
|
|
|
}
|
|
|
|
}
|