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.
187 lines
6.3 KiB
187 lines
6.3 KiB
using AX.InputSystem; |
|
using AX.MessageSystem; |
|
using System.Collections; |
|
using System.Collections.Generic; |
|
using UnityEngine; |
|
using System; |
|
|
|
public class ParentLinesMessage : MonoBehaviour |
|
{ |
|
public string EquipId = "82"; |
|
|
|
private float DefultHoseLenght = 20; |
|
/// <summary> |
|
/// 开始点的物体 |
|
/// </summary> |
|
public GameObject StartHitGameObj; |
|
|
|
/// <summary> |
|
/// 结束点的位置 |
|
/// </summary> |
|
public GameObject EndHitGameObj; |
|
/// <summary> |
|
/// 开始克隆点 |
|
/// </summary> |
|
public Vector3 StartPoint; |
|
/// <summary> |
|
/// 结束克隆点 |
|
/// </summary> |
|
public Vector3 EndPoint; |
|
/// <summary> |
|
/// 此次克隆线的长度 |
|
/// </summary> |
|
public float LineLenght; |
|
/// <summary> |
|
/// 结束绘制时剩余长度 |
|
/// </summary> |
|
public float RemainLenght; |
|
|
|
public bool HasWaterConnent = false; |
|
public GameObject WaterSource; |
|
|
|
public long CreatFiremanID; |
|
|
|
/// <summary> |
|
/// 记录水带在给那些物体供水,没有出水出水时,list长度为0. |
|
/// 监听出水,物体出水时其所有水源连接的管线都要添加该物体 |
|
/// </summary> |
|
// public List<long> SprayInfo = new List<long>(); |
|
|
|
|
|
/// <summary> |
|
/// 该水带是否已经计算过消耗,用来防止结束点连接消防员、消防车、水源计算了消耗关闭连接管线按钮时再次计算消耗 |
|
/// </summary> |
|
public bool hascalculate; |
|
|
|
/// <summary> |
|
/// 记录这条管线所连接的管线信息,用做捡起管线,捡起管线时如果起点不是车辆则水源信息则为消防设施 |
|
/// 获取到管线的起点实际就能获取到水源信息 |
|
/// </summary> |
|
//public List<List<long>> WaterSourceConnect = new List<List<long>>(); |
|
|
|
/// <summary> |
|
/// 该管线是否有水通过,用以判断该管线是否可删除, |
|
/// </summary> |
|
// public bool HasWaterCross; |
|
|
|
public void OnEnable() |
|
{ |
|
//MessageDispatcher.AddListener("Delect_WaterHose", DeletedWaterHose); |
|
MessageDispatcher.AddListener("WATERHOSEEXPEND", HoseExpend); |
|
UsedHoseValue.getAllUsedHose += addMyLinesNumber; |
|
} |
|
public void OnDisable() |
|
{ |
|
// MessageDispatcher.RemoveListener("Delect_WaterHose", DeletedWaterHose); |
|
MessageDispatcher.RemoveListener("WATERHOSEEXPEND", HoseExpend); |
|
UsedHoseValue.getAllUsedHose -= addMyLinesNumber; |
|
} |
|
public void OnDestroy() |
|
{ |
|
//MessageDispatcher.RemoveListener("Delect_WaterHose", DeletedWaterHose); |
|
MessageDispatcher.RemoveListener("WATERHOSEEXPEND", HoseExpend); |
|
UsedHoseValue.getAllUsedHose -= addMyLinesNumber; |
|
} |
|
|
|
private void DeletedWaterHose(IMessage obj) |
|
{ |
|
if (SelectedObjs.selectedObj == gameObject) |
|
{ |
|
//删除的管线 连接的 消防员信息修改 |
|
if (StartHitGameObj.GetComponent<FireManControl>()) |
|
{ |
|
StartHitGameObj.GetComponent<FireManWaterHoseManager>().Resert(); |
|
} |
|
if (EndHitGameObj.GetComponent<FireManControl>()) |
|
{ |
|
EndHitGameObj.GetComponent<FireManWaterHoseManager>().Resert(); |
|
} |
|
|
|
//删除的管线 连接的 水炮信息修改 |
|
if (StartHitGameObj.GetComponent<WaterConnonController>()) |
|
{ |
|
StartHitGameObj.GetComponent<WaterConnonController>().Resert(); |
|
} |
|
if (EndHitGameObj.GetComponent<WaterConnonController>()) |
|
{ |
|
EndHitGameObj.GetComponent<WaterConnonController>().Resert(); |
|
} |
|
//删除管线连接的暴风雪炮信息修改 |
|
if (StartHitGameObj.GetComponent<SnowConnonController>()) |
|
{ |
|
StartHitGameObj.GetComponent<SnowConnonController>().Resert(); |
|
} |
|
if (EndHitGameObj.GetComponent<SnowConnonController>()) |
|
{ |
|
EndHitGameObj.GetComponent<SnowConnonController>().Resert(); |
|
} |
|
//删除管线时连接的灭火机器人的信息修改 |
|
if (StartHitGameObj.GetComponent<FireRobotController>()) |
|
{ |
|
StartHitGameObj.GetComponent<FireRobotWaterHoseManage>().Resert(); |
|
} |
|
if (EndHitGameObj.GetComponent<FireRobotController>()) |
|
{ |
|
EndHitGameObj.GetComponent<FireRobotWaterHoseManage>().Resert(); |
|
} |
|
//删除的管线 连接的消防车信息修改 |
|
if (StartHitGameObj.GetComponent<TruckMessage>() || EndHitGameObj.GetComponent<TruckMessage>()) |
|
{ |
|
var arg = new WaterHoseDelectCmdArgs(); |
|
arg.StartObjId = StartHitGameObj.GetComponent<BaseGameObjInfo>().gameObjID; |
|
arg.EndObjId = EndHitGameObj.GetComponent<BaseGameObjInfo>().gameObjID; |
|
arg.SelectHoseWater = gameObject; |
|
MessageDispatcher.SendMessage("DelectWaterHose", arg); |
|
// WaterHoseDestoryCommand.Instance.Execute(GetComponent<BaseGameObjInfo>().gameObjID, arg); |
|
} |
|
} |
|
|
|
} |
|
private void HoseExpend(IMessage obj) |
|
{ |
|
var data = (WaterHoseExpend)obj.Data; |
|
if (data.WaterHoseDraw == gameObject) |
|
{ |
|
RemainLenght = data.ExpendNum * DefultHoseLenght - data.Distance; |
|
} |
|
} |
|
/// <summary> |
|
/// 获取管线另一端连接的物体 |
|
/// </summary> |
|
/// <param name="oneside"></param> |
|
/// <returns></returns> |
|
public GameObject GetAnotherGameObj(GameObject oneside) |
|
{ |
|
if (oneside == StartHitGameObj) |
|
{ |
|
return EndHitGameObj; |
|
} |
|
else |
|
{ |
|
return StartHitGameObj; |
|
} |
|
} |
|
public GameObject GetAnotherGameObj(long oneside) |
|
{ |
|
if (oneside == StartHitGameObj.GetComponent<BaseGameObjInfo>().gameObjID) |
|
{ |
|
return EndHitGameObj; |
|
} |
|
else if (oneside == EndHitGameObj.GetComponent<BaseGameObjInfo>().gameObjID) |
|
{ |
|
return StartHitGameObj; |
|
} |
|
else |
|
{ |
|
Debug.LogError("同步Id有问题?"); |
|
return null; |
|
} |
|
|
|
} |
|
private IntData addMyLinesNumber(IntData data) |
|
{ |
|
int num = (int)((LineLenght + RemainLenght) / 20); |
|
data.value += num; |
|
return data; |
|
} |
|
}
|
|
|