|
|
|
using AX.MessageSystem;
|
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using UnityEngine;
|
|
|
|
using System;
|
|
|
|
using AX.InputSystem;
|
|
|
|
using UnityEngine.UI;
|
|
|
|
using UnityEngine.AI;
|
|
|
|
using AX.NetworkSystem;
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 消防员的水带已经水源信息
|
|
|
|
/// </summary>
|
|
|
|
public class FireManWaterHoseManager : MonoBehaviour
|
|
|
|
{
|
|
|
|
[SerializeField]
|
|
|
|
public List<List<long>> WaterSourceLine = new List<List<long>>();//进水口线路
|
|
|
|
|
|
|
|
|
|
|
|
public string WaterHoseID = "82";
|
|
|
|
[Header("一盘水带默认长度")]
|
|
|
|
public float OneDefaultHoseLenght = 20f;
|
|
|
|
[Header("是否装备水带")]
|
|
|
|
public bool HasWaterHose;
|
|
|
|
/// <summary>
|
|
|
|
/// 剩余水带长度
|
|
|
|
/// </summary>
|
|
|
|
[Header("水带剩余长度")]
|
|
|
|
public float WaterHoseLenghtRemain;
|
|
|
|
//[Header("水带初始携带数")]
|
|
|
|
// public int BeginCarryWaterHose = 5;
|
|
|
|
/// <summary>
|
|
|
|
/// 当前剩下盘数
|
|
|
|
/// </summary>
|
|
|
|
[Header("当前还剩的盘数")]
|
|
|
|
public int NowRemainWaterHose = 5;
|
|
|
|
|
|
|
|
// public int NowRemainWaterHose { get; set;}
|
|
|
|
/// <summary>
|
|
|
|
/// 当前消防员是否连接水带
|
|
|
|
/// </summary>
|
|
|
|
public bool IsConnentWaterLine;
|
|
|
|
/// <summary>
|
|
|
|
/// 连接的水带
|
|
|
|
/// </summary>
|
|
|
|
public GameObject WaterLineConnent;
|
|
|
|
/// <summary>
|
|
|
|
/// 是否连接水源
|
|
|
|
/// </summary>
|
|
|
|
public bool IsConnentWaterSource;
|
|
|
|
/// <summary>
|
|
|
|
/// 连接的直接水源
|
|
|
|
/// </summary>
|
|
|
|
public GameObject ConnentSource;
|
|
|
|
public bool hasWaterConnect;
|
|
|
|
public bool hasFoamConnect;
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 是否是收起或者拿起状态
|
|
|
|
/// </summary>
|
|
|
|
private bool PickOrTack;
|
|
|
|
/// <summary>
|
|
|
|
/// 点击的管线,如果是捡起捡起后则为捡起水带
|
|
|
|
/// </summary>
|
|
|
|
private GameObject hose;
|
|
|
|
//捡起长度
|
|
|
|
//public float OverLenght;
|
|
|
|
//可以用的水带数
|
|
|
|
//public int CanUseHoseNum;
|
|
|
|
//是否在捡起范围内可以使用的
|
|
|
|
//public bool InBundary;
|
|
|
|
|
|
|
|
List<Equip> all;
|
|
|
|
|
|
|
|
private long gameobjid;
|
|
|
|
private FireManControl firemancontrol;
|
|
|
|
private Bags bagdata;
|
|
|
|
void Start()
|
|
|
|
{
|
|
|
|
GetComponent<Bags>().OnAddEquip += AddEquip;
|
|
|
|
WaterHoseLenghtRemain = OneDefaultHoseLenght * NowRemainWaterHose;
|
|
|
|
all = GetComponent<Bags>().EquipData;
|
|
|
|
gameobjid = GetComponent<BaseGameObjInfo>().gameObjID;
|
|
|
|
firemancontrol = GetComponent<FireManControl>();
|
|
|
|
bagdata = GetComponent<Bags>();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public void Awake()
|
|
|
|
{
|
|
|
|
MessageDispatcher.AddListener("WATERHOSEEXPEND", HoseExpend);
|
|
|
|
MessageDispatcher.AddListener("PACK_OR_TACK_HOSE_COMMAND", PackOrTackHose);
|
|
|
|
MessageDispatcher.AddListener("HOSE_CONNECT_OR_DELECT", ConnectOrDelectControl);
|
|
|
|
//MessageDispatcher.AddListener("PACK_OR_TACK_HOSE_COMMAND", PackOrTackHose);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void OnDisable()
|
|
|
|
{
|
|
|
|
MessageDispatcher.RemoveListener("WATERHOSEEXPEND", HoseExpend);
|
|
|
|
MessageDispatcher.RemoveListener("PACK_OR_TACK_HOSE_COMMAND", PackOrTackHose);
|
|
|
|
MessageDispatcher.RemoveListener("HOSE_CONNECT_OR_DELECT", ConnectOrDelectControl);
|
|
|
|
//MessageDispatcher.RemoveListener("PACK_OR_TACK_HOSE_COMMAND", PackOrTackHose);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void OnDestroy()
|
|
|
|
{
|
|
|
|
MessageDispatcher.RemoveListener("WATERHOSEEXPEND", HoseExpend);
|
|
|
|
MessageDispatcher.RemoveListener("PACK_OR_TACK_HOSE_COMMAND", PackOrTackHose);
|
|
|
|
MessageDispatcher.RemoveListener("HOSE_CONNECT_OR_DELECT", ConnectOrDelectControl);
|
|
|
|
//MessageDispatcher.RemoveListener("PACK_OR_TACK_HOSE_COMMAND", PackOrTackHose);
|
|
|
|
}
|
|
|
|
//当有同步的管线连接到该消防员或同步删除连接该消防员的管线时,该消防员的可移动控制,水源信息处理
|
|
|
|
private void ConnectOrDelectControl(IMessage obj)
|
|
|
|
{
|
|
|
|
HoseConnectOrDelectData data = (HoseConnectOrDelectData)obj.Data;
|
|
|
|
if (data.StartId == gameobjid ||
|
|
|
|
data.EndId == gameobjid)
|
|
|
|
{
|
|
|
|
//移动处理
|
|
|
|
if (data.Isconnect)
|
|
|
|
{
|
|
|
|
GetComponent<AgentController>().pathFindEnable = false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
GetComponent<AgentController>().pathFindEnable = true;
|
|
|
|
}
|
|
|
|
//水源信息处理
|
|
|
|
GameObject connectHose = EntitiesManager.Instance.GetEntityByID(data.HoseId);
|
|
|
|
|
|
|
|
GameObject anther = connectHose.GetComponent<ParentLinesMessage>().GetAnotherGameObj(gameobjid);
|
|
|
|
if (data.Isconnect)
|
|
|
|
{
|
|
|
|
if (anther.GetComponent<WaterSource>())
|
|
|
|
{//另一端是水源
|
|
|
|
IsConnentWaterSource = true;
|
|
|
|
ConnentSource = anther;
|
|
|
|
hasWaterConnect = anther.GetComponent<WaterSource>().water;
|
|
|
|
hasFoamConnect = anther.GetComponent<WaterSource>().foam;
|
|
|
|
IsConnentWaterLine = true;
|
|
|
|
WaterLineConnent = connectHose;
|
|
|
|
GetComponent<FireManControl>().ChangeWaterSourceLineInfo(data.StartId, 0);
|
|
|
|
if(GetComponent<LayWaterHose>().ParentLayHose!=null)
|
|
|
|
{
|
|
|
|
GetComponent<LayWaterHose>().ParentLayHose.GetComponent<ParentLayWaterHoseMsg>().BindWaterSource(hasWaterConnect, hasFoamConnect, ConnentSource, WaterLineConnent);
|
|
|
|
}
|
|
|
|
//如果连接了一个没有水的水源
|
|
|
|
//if (anther.GetComponent<WaterSource>().hasover)
|
|
|
|
// {
|
|
|
|
// GetComponent<FireManControl>().waterrunoutof = true;
|
|
|
|
//}
|
|
|
|
}
|
|
|
|
//因为另一点(即起点)肯定是水源
|
|
|
|
//if (anther.GetComponent<TruckBindWaterSource>() && !anther.GetComponent<WaterSource>())
|
|
|
|
//{//另一端是非水源出水车辆
|
|
|
|
// ConnentSource = anther.GetComponent<TruckBindWaterSource>().ConnentWaterSource;
|
|
|
|
// if (ConnentSource != null)
|
|
|
|
// {
|
|
|
|
// IsConnentWaterSource = true;
|
|
|
|
// hasWaterConnect = anther.GetComponent<TruckBindWaterSource>().ConnectWater;
|
|
|
|
// hasFoamConnect = anther.GetComponent<TruckBindWaterSource>().ConnectFoam;
|
|
|
|
|
|
|
|
// if (ConnentSource.GetComponent<WaterSource>())
|
|
|
|
// {
|
|
|
|
// if (ConnentSource.GetComponent<WaterSource>().hasover)
|
|
|
|
// {
|
|
|
|
// GetComponent<FireManControl>().waterrunoutof = true;
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
if (FireManSkillPanelController.Instance)
|
|
|
|
{
|
|
|
|
if (FireManSkillPanelController.Instance.SelectFireMan == gameObject)
|
|
|
|
{
|
|
|
|
FireManSkillPanelController.Instance.SprayWater.GetComponent<Toggle>().interactable = IsConnentWaterSource;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Resert();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public void AddEquip()
|
|
|
|
{
|
|
|
|
all = bagdata.EquipData;
|
|
|
|
if (bagdata.HasEquip("消防高压水带"))
|
|
|
|
{
|
|
|
|
for (int i = 0; i < all.Count; i++)
|
|
|
|
{
|
|
|
|
if (all[i].ID == WaterHoseID)
|
|
|
|
{
|
|
|
|
NowRemainWaterHose = all[i].Number;
|
|
|
|
WaterHoseLenghtRemain = NowRemainWaterHose * OneDefaultHoseLenght;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
NowRemainWaterHose = 0;
|
|
|
|
WaterHoseLenghtRemain = NowRemainWaterHose * OneDefaultHoseLenght;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 收起或者拿起管线
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="obj"></param>
|
|
|
|
private void PackOrTackHose(IMessage obj)
|
|
|
|
{
|
|
|
|
var data = (PackOrTakeHoseCmdArgs)obj.Data;
|
|
|
|
long firemanId = data.fireManID;
|
|
|
|
if (hose != null && firemancontrol.workType == FireManSkills.TakeUpWaterLine)
|
|
|
|
{
|
|
|
|
if (hose == data.gameObj)
|
|
|
|
{
|
|
|
|
LoadPromptWin.Instance.LoadTextPromptWindow("该水带已被捡起", 1f);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
hose = data.gameObj;
|
|
|
|
if (firemanId == gameobjid)
|
|
|
|
{
|
|
|
|
//该水带有人在铺设
|
|
|
|
if (hose.GetComponent<ParentLayWaterHoseMsg>().ConnectFireman != null)
|
|
|
|
{
|
|
|
|
LoadPromptWin.Instance.LoadTextPromptWindow("该水带尚未被放下", 1f);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (firemancontrol.workType == FireManSkills.LayLifeSavingFlarePath ||
|
|
|
|
firemancontrol.workType == FireManSkills.LayWaterHose ||
|
|
|
|
firemancontrol.workType == FireManSkills.SprayWater)
|
|
|
|
{
|
|
|
|
LoadPromptWin.Instance.LoadTextPromptWindow("请先停止当前操作", 1f);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (firemancontrol.workType == FireManSkills.PackUpLine)
|
|
|
|
{
|
|
|
|
//不能收起非当前客户端铺设的水带
|
|
|
|
if (GetComponent<BaseGameObjInfo>().UserID != hose.GetComponent<ParentLayWaterHoseMsg>().CreatFireman.GetComponent<BaseGameObjInfo>().UserID)
|
|
|
|
{
|
|
|
|
LoadPromptWin.Instance.LoadTextPromptWindow("不能操作该水带", 1f);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
int hosenum = hose.GetComponent<ParentLayWaterHoseMsg>().UseNum;
|
|
|
|
if (bagdata.HasEquip("消防高压水带"))
|
|
|
|
{
|
|
|
|
if ((bagdata.GetEquip("消防高压水带").Number + hosenum) > 10)
|
|
|
|
{
|
|
|
|
LoadPromptWin.Instance.LoadTextPromptWindow("超过携带上限", 1f);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//寻路到管线尾端
|
|
|
|
// GetComponent<NavMeshAgent>().SetDestination(hose.GetComponent<ParentLayWaterHoseMsg>().EndPoint);
|
|
|
|
var arg = new PathFindingCmdArgs();
|
|
|
|
arg.hitPoint = hose.GetComponent<ParentLayWaterHoseMsg>().EndPoint;
|
|
|
|
//arg.gameObjID = hit.transform.GetComponent<BaseGameObjInfo>().GameObjID;
|
|
|
|
PathFindingCommand.Instance.Execute(gameobjid, arg);
|
|
|
|
PickOrTack = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Update()
|
|
|
|
{
|
|
|
|
if (PickOrTack)
|
|
|
|
{
|
|
|
|
if (Vector3.Distance(transform.position, hose.GetComponent<ParentLayWaterHoseMsg>().EndPoint) < 0.5f)
|
|
|
|
{
|
|
|
|
if (firemancontrol.workType == FireManSkills.PackUpLine)
|
|
|
|
{
|
|
|
|
//收起管线
|
|
|
|
PickUpWaterHose(hose.GetComponent<ParentLayWaterHoseMsg>().UseNum);
|
|
|
|
//NowRemainWaterHose += hose.GetComponent<ParentLayWaterHoseMsg>().UseNum;
|
|
|
|
// WaterHoseLenghtRemain = NowRemainWaterHose * 20;
|
|
|
|
|
|
|
|
//收起管线同步
|
|
|
|
DestroyLayWaterHoseSyncData arg = new DestroyLayWaterHoseSyncData();
|
|
|
|
arg.SendUserID = CurrentUserInfo.mySelf.Id;
|
|
|
|
arg.gameObjID = GetComponent<BaseGameObjInfo>().gameObjID;
|
|
|
|
arg.hosename = hose.transform.parent.name + "/" + hose.name;
|
|
|
|
NetworkManager.Default.SendAsync("DESTROY_LAY_WATER_HOSE_SYNC", arg);
|
|
|
|
hose.GetComponent<ParentLayWaterHoseMsg>().CreatFireman.GetComponent<LayWaterHose>().ResertEndPoint();
|
|
|
|
Destroy(hose);
|
|
|
|
LoadPromptWin.Instance.LoadTextPromptWindow("收起成功", 1f);
|
|
|
|
PickOrTack = false;
|
|
|
|
Resert();
|
|
|
|
if (FireManSkillPanelController.Instance)
|
|
|
|
{
|
|
|
|
if (FireManSkillPanelController.Instance.SelectFireMan == gameObject)
|
|
|
|
{
|
|
|
|
FireManSkillPanelController.Instance.SprayWater.GetComponent<Toggle>().interactable = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (firemancontrol.workType == FireManSkills.TakeUpWaterLine)
|
|
|
|
{
|
|
|
|
//赋值信息
|
|
|
|
ParentLayWaterHoseMsg hosemsg = hose.GetComponent<ParentLayWaterHoseMsg>();
|
|
|
|
if (hosemsg.WaterSource != null)
|
|
|
|
{
|
|
|
|
/*gameObject.GetComponent<FireManWaterHoseManager>().*/
|
|
|
|
ResetWaterSourceConnectInfo
|
|
|
|
(true, hosemsg.ConnectWater, hosemsg.ConnectFoam, hosemsg.WaterSource, hosemsg.ConnectWaterHose);
|
|
|
|
|
|
|
|
//直接水源
|
|
|
|
GameObject dirwatersource = hosemsg.ConnectWaterHose.GetComponent<ParentLinesMessage>().StartHitGameObj;
|
|
|
|
//赋值水源信息
|
|
|
|
GetComponent<FireManControl>().ChangeWaterSourceLineInfo(dirwatersource.GetComponent<BaseGameObjInfo>().gameObjID, 0);
|
|
|
|
if (FireManSkillPanelController.Instance)
|
|
|
|
{
|
|
|
|
FireManSkillPanelController.Instance.LayWaterHoseToggle.GetComponent<Toggle>().isOn = true;
|
|
|
|
FireManSkillPanelController.Instance.SprayWater.GetComponent<Toggle>().interactable = true;
|
|
|
|
}
|
|
|
|
//var arg = new HoseConnectOrDelectData();
|
|
|
|
//arg.StartId = hosemsg.WaterSource.GetComponent<BaseGameObjInfo>().gameObjID;
|
|
|
|
//arg.EndId = GetComponent<BaseGameObjInfo>().gameObjID;
|
|
|
|
//arg.HoseId = hosemsg.ConnectWaterHose.GetComponent<BaseGameObjInfo>().gameObjID;
|
|
|
|
//arg.Isconnect = true;
|
|
|
|
//MessageDispatcher.SendMessage("HOSE_CONNECT_OR_DELECT", arg);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gameObject.GetComponent<FireManWaterHoseManager>().ResetWaterSourceConnectInfo(false, false, false, null, null);
|
|
|
|
}
|
|
|
|
|
|
|
|
// OverLenght = hosemsg.RemainLenght;
|
|
|
|
LoadPromptWin.Instance.LoadTextPromptWindow("拿起水带成功", 1f);
|
|
|
|
//if (FindObjectOfType<FireManSkillPanelController>())
|
|
|
|
//{
|
|
|
|
// FireManSkillPanelController.Instance.LayWaterHoseToggle.GetComponent<Toggle>().isOn = true;
|
|
|
|
//}
|
|
|
|
PickOrTack = false;
|
|
|
|
// GetComponent<LayWaterHose>().IsTackUp = true;
|
|
|
|
// GetComponent<LayWaterHose>().TackHose = hose;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
///连接管线 结束绘制时计算长度
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="obj"></param>
|
|
|
|
private void HoseExpend(IMessage obj)
|
|
|
|
{
|
|
|
|
var data = (WaterHoseExpend)obj.Data;
|
|
|
|
if (data.Fireman == gameObject)
|
|
|
|
{
|
|
|
|
bagdata.UseEquip("消防高压水带", data.ExpendNum);
|
|
|
|
if (bagdata.HasEquip("消防高压水带"))
|
|
|
|
{
|
|
|
|
NowRemainWaterHose = bagdata.GetEquip("消防高压水带").Number;
|
|
|
|
//Debug.Log(NowRemainWaterHose + "剩余水带数");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
NowRemainWaterHose = 0;
|
|
|
|
}
|
|
|
|
//NowRemainWaterHose -= data.ExpendNum;
|
|
|
|
WaterHoseLenghtRemain = NowRemainWaterHose * OneDefaultHoseLenght;
|
|
|
|
|
|
|
|
//消耗同步
|
|
|
|
EquipManager.Instance.BagDataSync(bagdata);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//继续上次水带铺设前计算可用管线,这里不做管线同步,因为铺设管线的同步是调用的StartLay(),所以各个客户端可能回来发
|
|
|
|
public void CalculateBeforelay(float remain, int usenum)
|
|
|
|
{
|
|
|
|
|
|
|
|
WaterHoseLenghtRemain = NowRemainWaterHose * OneDefaultHoseLenght + remain;
|
|
|
|
//NowRemainWaterHose += usenum;
|
|
|
|
|
|
|
|
Equip hose = EquipManager.Instance.GetEquipByID(WaterHoseID);
|
|
|
|
hose.Number = usenum;
|
|
|
|
bagdata.AddEquip(hose);
|
|
|
|
NowRemainWaterHose = bagdata.GetEquip("消防高压水带").Number;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 结束水带铺设时更新剩余水带信息,铺设管线消耗,这里不做管线同步,因为铺设管线的同步是调用的EndtLay(),所以各个客户端可能回来发
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="ExpendHoseNum">本次铺设的水带的长度</param>
|
|
|
|
public void UpdateRemain(float expendlenght)
|
|
|
|
{
|
|
|
|
//NowRemainWaterHose -= Mathf.CeilToInt(expendlenght / 20);
|
|
|
|
GetComponent<Bags>().UseEquip("消防高压水带", Mathf.CeilToInt(expendlenght / 20));
|
|
|
|
if (bagdata.HasEquip("消防高压水带"))
|
|
|
|
{
|
|
|
|
NowRemainWaterHose = bagdata.GetEquip("消防高压水带").Number;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
NowRemainWaterHose = 0;
|
|
|
|
}
|
|
|
|
WaterHoseLenghtRemain = NowRemainWaterHose * OneDefaultHoseLenght; //+ OverLenght;
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
public void ContinuteLay()
|
|
|
|
{
|
|
|
|
//if (OverLenght > 0)
|
|
|
|
//{
|
|
|
|
// //CanUseHoseNum = NowRemainWaterHose + 1;
|
|
|
|
// WaterHoseLenghtRemain = NowRemainWaterHose * OneDefaultHoseLenght + OverLenght;
|
|
|
|
//}
|
|
|
|
//else
|
|
|
|
//{
|
|
|
|
// WaterHoseLenghtRemain = NowRemainWaterHose * OneDefaultHoseLenght;
|
|
|
|
//}
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
|
|
/// 连接管线消耗水带
|
|
|
|
/// </summary>
|
|
|
|
public void ExpendHose(float distance, float alldistance)
|
|
|
|
{
|
|
|
|
if (distance > WaterHoseLenghtRemain)
|
|
|
|
{
|
|
|
|
LoadPromptWin.Instance.LoadTextPromptWindow("没有足够的水带", 1f);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
WaterHoseLenghtRemain -= distance;
|
|
|
|
// NowRemainWaterHose
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
|
|
/// 是否有足够的水带
|
|
|
|
/// </summary>
|
|
|
|
public bool CheckHoseIsEnough(float distance)
|
|
|
|
{
|
|
|
|
if (WaterHoseLenghtRemain < distance)
|
|
|
|
{
|
|
|
|
// pathPoints.Remove(endPoint);
|
|
|
|
LoadPromptWin.Instance.LoadTextPromptWindow("没有足够水带", 1f);
|
|
|
|
//Destroy(parentgameobj.transform.GetChild(parentgameobj.transform.childCount-1).gameObject);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
|
|
/// 收起管线
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="addhose"></param>
|
|
|
|
public void PickUpWaterHose(int addhose)
|
|
|
|
{
|
|
|
|
//WaterHoseLenghtRemain += OneDefaultHoseLenght * addhose;
|
|
|
|
//NowRemainWaterHose += addhose;
|
|
|
|
Equip hose = EquipManager.Instance.GetEquipByID(WaterHoseID);
|
|
|
|
hose.Number = addhose;
|
|
|
|
bagdata.AddEquip(hose);
|
|
|
|
WaterHoseLenghtRemain += OneDefaultHoseLenght * addhose;
|
|
|
|
NowRemainWaterHose = bagdata.GetEquip("消防高压水带").Number;
|
|
|
|
//同步管线
|
|
|
|
|
|
|
|
EquipManager.Instance.BagDataSync(bagdata);
|
|
|
|
}
|
|
|
|
///// <summary>
|
|
|
|
///// 回收水带
|
|
|
|
///// </summary>
|
|
|
|
///// <param name="recycle"></param>
|
|
|
|
//public void RecycleWaterHose(int recycle)
|
|
|
|
//{
|
|
|
|
// NowRemainWaterHose += recycle;
|
|
|
|
// WaterHoseLenghtRemain += OneDefaultHoseLenght * recycle;
|
|
|
|
//}
|
|
|
|
|
|
|
|
//获取连接的水带连接的水源
|
|
|
|
public void GetWaterSourceType()
|
|
|
|
{
|
|
|
|
if (IsConnentWaterLine)
|
|
|
|
{
|
|
|
|
LoadPromptWin.Instance.LoadTextPromptWindow("尚未连接水带", 1f);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (WaterLineConnent == null)
|
|
|
|
{
|
|
|
|
LoadPromptWin.Instance.LoadTextPromptWindow("无法获取水带信息", 1f);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (WaterLineConnent != null)
|
|
|
|
{
|
|
|
|
GameObject otherside = WaterLineConnent.GetComponent<ParentLinesMessage>().GetAnotherGameObj(gameObject);
|
|
|
|
if (!otherside.GetComponent<WaterSource>() || !otherside.GetComponent<TruckBindWaterSource>())
|
|
|
|
{
|
|
|
|
LoadPromptWin.Instance.LoadTextPromptWindow("未连接水源", 1f);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (otherside.GetComponent<WaterSource>())
|
|
|
|
{
|
|
|
|
hasWaterConnect = otherside.GetComponent<WaterSource>().water;
|
|
|
|
hasFoamConnect = otherside.GetComponent<WaterSource>().foam;
|
|
|
|
}
|
|
|
|
if (otherside.GetComponent<TruckBindWaterSource>() && !otherside.GetComponent<WaterSource>())
|
|
|
|
{
|
|
|
|
hasWaterConnect = otherside.GetComponent<TruckBindWaterSource>().ConnectWater;
|
|
|
|
hasFoamConnect = otherside.GetComponent<TruckBindWaterSource>().ConnectFoam;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
|
|
/// 重设连接的水源信息,已经连接了消防车
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="water">是否连接水</param>
|
|
|
|
/// <param name="foam">是否连接泡沫</param>
|
|
|
|
public void ResetWaterSourceConnectInfo(bool water, bool foam)
|
|
|
|
{
|
|
|
|
IsConnentWaterSource = true;
|
|
|
|
hasWaterConnect = water;
|
|
|
|
hasFoamConnect = foam;
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
|
|
/// 重设水源信息,不确定连接是否连接了水源,比如捡起一段水带
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="connectsource">是否有水源</param>
|
|
|
|
/// <param name="water"></param>
|
|
|
|
/// <param name="foam"></param>
|
|
|
|
public void ResetWaterSourceConnectInfo(bool connectsource, bool water, bool foam, GameObject watersource, GameObject connecthose,bool issync=false)
|
|
|
|
{
|
|
|
|
if (issync==false)
|
|
|
|
{
|
|
|
|
IsConnentWaterSource = connectsource;
|
|
|
|
hasWaterConnect = water;
|
|
|
|
hasFoamConnect = foam;
|
|
|
|
ConnentSource = watersource;
|
|
|
|
WaterLineConnent = connecthose;
|
|
|
|
if (connecthose != null)
|
|
|
|
{
|
|
|
|
IsConnentWaterLine = true;
|
|
|
|
}
|
|
|
|
if (connectsource)
|
|
|
|
{
|
|
|
|
if (FireManSkillPanelController.Instance)
|
|
|
|
{
|
|
|
|
if (SelectedObjs.selectedObj == gameObject)
|
|
|
|
{
|
|
|
|
FireManSkillPanelController.Instance.SprayWater.GetComponent<Toggle>().interactable = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
|
|
/// 重置连接水带信息
|
|
|
|
/// </summary>
|
|
|
|
public void Resert()
|
|
|
|
{
|
|
|
|
if ((GetComponent<FireManControl>().workType == FireManSkills.SprayFoam ||
|
|
|
|
GetComponent<FireManControl>().workType == FireManSkills.SprayWater))
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (GetComponent<FireManControl>().workType == FireManSkills.LayWaterHose)
|
|
|
|
{
|
|
|
|
if (!IsConnentWaterSource)
|
|
|
|
{
|
|
|
|
if (FireManSkillPanelController.Instance)
|
|
|
|
{
|
|
|
|
FireManSkillPanelController.Instance.SprayWater.GetComponent<Toggle>().isOn = false;
|
|
|
|
FireManSkillPanelController.Instance.SprayWater.GetComponent<Toggle>().interactable = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
IsConnentWaterLine = false;
|
|
|
|
WaterLineConnent = null;
|
|
|
|
IsConnentWaterSource = false;
|
|
|
|
ConnentSource = null;
|
|
|
|
hasFoamConnect = false;
|
|
|
|
hasWaterConnect = false;
|
|
|
|
//清空水源信息
|
|
|
|
// WaterSourceLine = new List<List<long>>();
|
|
|
|
if (!GetComponent<AgentController>().pathFindEnable)
|
|
|
|
{
|
|
|
|
GetComponent<AgentController>().pathFindEnable = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (GetComponentInChildren<ParticleControlOfType>())
|
|
|
|
{
|
|
|
|
// if (SelectedObjs.selectedObj==gameObject)
|
|
|
|
{
|
|
|
|
//停止出水
|
|
|
|
GetComponent<FireManControl>().DestoryPartical();
|
|
|
|
//SpraySyncData spraysync = new SpraySyncData();
|
|
|
|
//spraysync.SendUserID = CurrentUserInfo.mySelf.Id;
|
|
|
|
//spraysync.IsOn = false;
|
|
|
|
//spraysync.gameObjID = gameobjid;
|
|
|
|
//NetworkManager.Default.SendAsync("SPRAY_WATER_SYNC", spraysync);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|