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.
1141 lines
49 KiB
1141 lines
49 KiB
4 years ago
|
using System;
|
||
|
using System.Collections;
|
||
|
using System.Collections.Generic;
|
||
|
using AX.MessageSystem;
|
||
|
using UnityEngine;
|
||
|
using AX.InputSystem;
|
||
|
using UnityEngine.UI;
|
||
|
using AX.NetworkSystem;
|
||
|
|
||
|
public class WaterHoseExpend
|
||
|
{
|
||
|
public GameObject WaterHoseDraw;//当前操作的水带
|
||
|
public float Distance;//本次长度
|
||
|
public GameObject Fireman;//创建(消耗)的消防员
|
||
|
public int ExpendNum;//消耗盘数
|
||
|
}
|
||
|
//public class WaterHoseConnect
|
||
|
//{
|
||
|
// public long StartObjId;
|
||
|
// public long EndObjId;
|
||
|
// public GameObject SelectHoseWater;
|
||
|
//}
|
||
|
public class CloneWaterHoseLines : CloneBase
|
||
|
{
|
||
|
|
||
|
[SerializeField]
|
||
|
[Tooltip("距离地面距离")]
|
||
|
protected float Height = 0;
|
||
|
private Vector3 startPoint;
|
||
|
private Vector3 endPoint;
|
||
|
// private IMessage imessageobj;
|
||
|
private float DefultHoseLenght = 20;
|
||
|
private Vector3 beginLinePoint;
|
||
|
//public string PrefabPath;
|
||
|
//private Vector3 endLinePoint;
|
||
|
private List<Vector3> pathPoints = new List<Vector3>();
|
||
|
/// <summary>
|
||
|
/// 克隆出的线的父物体预设
|
||
|
/// </summary>
|
||
|
private GameObject parent;
|
||
|
|
||
|
/// <summary>
|
||
|
/// 画线是否超过俩个点
|
||
|
/// </summary>
|
||
|
public bool PointOverTwo;
|
||
|
|
||
|
private GameObject startHitGameobj;
|
||
|
private GameObject endHitGameobj;
|
||
|
|
||
|
/// <summary>
|
||
|
///是否是水带
|
||
|
/// </summary>
|
||
|
// public bool IsWaterHose;
|
||
|
/// <summary>
|
||
|
/// 当前选中的消防员
|
||
|
/// </summary>
|
||
|
public GameObject SelectFireMan;
|
||
|
/// <summary>
|
||
|
/// 线的父物体
|
||
|
/// </summary>
|
||
|
private GameObject parentgameobj;
|
||
|
public Vector3 SizeVec;
|
||
|
/// <summary>
|
||
|
/// 画线起点是否为水源
|
||
|
/// </summary>
|
||
|
private bool StartObjIsWaterSource = false;
|
||
|
|
||
|
private long gameObjID = 0;
|
||
|
void Start()
|
||
|
{
|
||
|
if (parent == null)
|
||
|
{
|
||
|
parent = Resources.Load("LineParent/ParentWaterHoseLine") as GameObject;
|
||
|
}
|
||
|
//if (SelectedObjs.selectedCharacters.Count>0)
|
||
|
//{
|
||
|
// SelectFireMan=SelectedObjs.selectedCharacters[0];
|
||
|
//}
|
||
|
|
||
|
}
|
||
|
public override void OnEnable()
|
||
|
{
|
||
|
base.OnEnable();
|
||
|
MessageDispatcher.AddListener("CANCEL_CLONEBTN_SELECTED_COMMAND", CancelSelected);
|
||
|
MessageDispatcher.AddListener("RESERTLINT", Resert);
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
private void CancelSelected(IMessage obj)
|
||
|
{
|
||
|
if (InputManager.cloneObjType == cloneObjType)
|
||
|
{
|
||
|
if (parentgameobj != null)
|
||
|
{
|
||
|
if (parentgameobj.GetComponent<ParentLinesMessage>())
|
||
|
{
|
||
|
if (parentgameobj.GetComponent<ParentLinesMessage>().LineLenght <= 0.1f)
|
||
|
{
|
||
|
EntitiesManager.Instance.DeleteObj(parentgameobj);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
ResertLine();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public override void OnDisable()
|
||
|
{
|
||
|
base.OnDisable();
|
||
|
|
||
|
MessageDispatcher.RemoveListener("CANCEL_CLONEBTN_SELECTED_COMMAND", CancelSelected);
|
||
|
MessageDispatcher.RemoveListener("RESERTLINT", Resert);
|
||
|
}
|
||
|
|
||
|
public override void OnDestroy()
|
||
|
{
|
||
|
base.OnDestroy();
|
||
|
|
||
|
MessageDispatcher.RemoveListener("CANCEL_CLONEBTN_SELECTED_COMMAND", CancelSelected);
|
||
|
MessageDispatcher.RemoveListener("RESERTLINT", Resert);
|
||
|
}
|
||
|
private void Resert(IMessage obj)
|
||
|
{
|
||
|
ResertLine();
|
||
|
}
|
||
|
public override void Execute(IMessage obj)
|
||
|
{
|
||
|
|
||
|
|
||
|
var data = ((CloneCmdArgs)obj.Data);
|
||
|
gameObjID = (long)obj.Sender;
|
||
|
//if(data.cloneObjType != cloneObjType)
|
||
|
//{
|
||
|
// return;
|
||
|
//}
|
||
|
|
||
|
|
||
|
|
||
|
//Debug.Log(gameObjID);
|
||
|
|
||
|
if (data.cloneObjType == cloneObjType)
|
||
|
{
|
||
|
if (FireManSkillPanelController.Instance)
|
||
|
{
|
||
|
SelectFireMan = FireManSkillPanelController.Instance.SelectFireMan;
|
||
|
}
|
||
|
if (SelectFireMan == null)
|
||
|
{
|
||
|
return;
|
||
|
}
|
||
|
if (!HasEquipWaterHose())
|
||
|
{
|
||
|
return;
|
||
|
}
|
||
|
TwoOrMore(obj);
|
||
|
var hitPoint = data.hitPos;
|
||
|
if (startPoint == Vector3.zero)
|
||
|
{
|
||
|
if (EntitiesManager.Instance.GetEntityByID(data.gameObjID))
|
||
|
{
|
||
|
startHitGameobj = EntitiesManager.Instance.GetEntityByID(data.gameObjID);
|
||
|
bool canconnect = checkCanConnetOrNo(startHitGameobj);
|
||
|
if (!canconnect)
|
||
|
{
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
Vector3 corstart = correctPoint(startHitGameobj);
|
||
|
|
||
|
if (corstart != Vector3.zero)
|
||
|
{
|
||
|
hitPoint = corstart;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
startPoint = hitPoint;
|
||
|
//if (changeStartPointWhileHitHose(startHitGameobj, hitPoint) != Vector3.zero)
|
||
|
//{
|
||
|
// startPoint = changeStartPointWhileHitHose(startHitGameobj, hitPoint);
|
||
|
//}
|
||
|
|
||
|
beginLinePoint = startPoint;
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
endPoint = hitPoint;
|
||
|
if (EntitiesManager.Instance.GetEntityByID(data.gameObjID))
|
||
|
{
|
||
|
endHitGameobj = EntitiesManager.Instance.GetEntityByID(data.gameObjID);
|
||
|
bool canconnect = checkCanConnetOrNo(endHitGameobj);
|
||
|
if (!canconnect)
|
||
|
{
|
||
|
return;
|
||
|
}
|
||
|
//if (!JugeConnent())
|
||
|
//{
|
||
|
// return;
|
||
|
//}
|
||
|
Vector3 corend = correctPoint(endHitGameobj);
|
||
|
|
||
|
//Debug.Log(endHitGameobj.name);
|
||
|
if (corend != Vector3.zero)
|
||
|
{
|
||
|
endPoint = corend;
|
||
|
|
||
|
}
|
||
|
|
||
|
|
||
|
}
|
||
|
|
||
|
pathPoints.Add(endPoint);
|
||
|
|
||
|
float distance = Vector3.Distance(startPoint, endPoint);//计算两点的距离
|
||
|
if (distance < 2)
|
||
|
{
|
||
|
pathPoints.Remove(endPoint);
|
||
|
LoadPromptWin.Instance.LoadTextPromptWindow("两点重合", 1f);
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
if (!WaterHoseAndOverLenght(distance))
|
||
|
{
|
||
|
// Destroy(parentgameobj);
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
Vector3 clonedObjPos = (startPoint + endPoint) / 2;
|
||
|
// Debug.Log(gameObjID);
|
||
|
//EntitiesManager.Instance.AddEntity(gameObjID, parentgameobj);
|
||
|
clonedObjPos = new Vector3(clonedObjPos.x, clonedObjPos.y + Height, clonedObjPos.z);
|
||
|
GameObject line = Instantiate(clonePrefab, parentgameobj.transform);
|
||
|
//帧数据记录使用 line.AddComponent<UIdsystem>()
|
||
|
//是否要每段都记录楼层信息
|
||
|
line.name = "line";
|
||
|
line.transform.position = clonedObjPos;
|
||
|
line.transform.forward = (-(endPoint - startPoint)).normalized;//改变线条的朝向
|
||
|
line.transform.localScale = new Vector3(SizeVec.x, SizeVec.y, distance * SizeVec.z);//延长线条,连接两点。
|
||
|
line.AddComponent<BoxCollider>();
|
||
|
line.GetComponent<CloneGameObjInfo>().gameObjID = parentgameobj.GetComponent<BaseGameObjInfo>().gameObjID;
|
||
|
|
||
|
parentgameobj.GetComponent<ParentLinesMessage>().LineLenght += distance;
|
||
|
|
||
|
parentgameobj.GetComponent<ParentLinesMessage>().StartHitGameObj = startHitGameobj;
|
||
|
parentgameobj.GetComponent<ParentLinesMessage>().EndHitGameObj = endHitGameobj;
|
||
|
|
||
|
parentgameobj.GetComponent<ParentLinesMessage>().StartPoint = beginLinePoint;
|
||
|
parentgameobj.GetComponent<ParentLinesMessage>().EndPoint = endPoint;
|
||
|
parentgameobj.GetComponent<ParentLinesMessage>().CreatFiremanID = SelectFireMan.GetComponent<BaseGameObjInfo>().gameObjID;
|
||
|
parentgameobj.name = CloneObjNameTool.Instance().GetCloneObjectName(cloneObjType);
|
||
|
ExpendHose(distance, parentgameobj.GetComponent<ParentLinesMessage>().LineLenght);
|
||
|
|
||
|
SelectedObjs.gameObjs.Add(line);
|
||
|
// SelectedObjs.gameObjs.Add(parentgameobj);
|
||
|
startPoint = endPoint;
|
||
|
//设置楼层属性
|
||
|
Setattribute(data.gameObjID, parentgameobj);
|
||
|
|
||
|
|
||
|
|
||
|
//connentFireMan();
|
||
|
//connentWaterCannon();
|
||
|
//connectSnowCannon();
|
||
|
//connentWaterSource();
|
||
|
//connentFireCar();
|
||
|
//OneFiremanAnotherWaterSource();
|
||
|
//OneWaterCannonAnotherWaterSource();
|
||
|
//OneSnowCannonAnotherWaterSource();
|
||
|
//OneFireRobotAnotherWaterSource();
|
||
|
//如果连接到车上,给车刷新绑定水源信息
|
||
|
//if (startHitGameobj.GetComponent<TruckMessage>()
|
||
|
// )
|
||
|
//{
|
||
|
// var arg = new HoseConnectOrDelectData();
|
||
|
// arg.StartId = startHitGameobj.GetComponent<BaseGameObjInfo>().gameObjID;
|
||
|
// arg.EndId = endHitGameobj.GetComponent<BaseGameObjInfo>().gameObjID;
|
||
|
// arg.HoseId = parentgameobj.GetComponent<BaseGameObjInfo>().gameObjID;
|
||
|
// arg.Isconnect = true;
|
||
|
// MessageDispatcher.SendMessage("HOSE_CONNECT_OR_DELECT", arg);
|
||
|
// //MessageDispatcher.SendMessage("WATERHOSECONNECT", arg);
|
||
|
//}
|
||
|
//如果长度小于0.5,认为只有初始点,为无用管线,删除
|
||
|
if (parentgameobj.GetComponent<ParentLinesMessage>().LineLenght < 0.5)
|
||
|
{
|
||
|
EntitiesManager.Instance.DeleteObj(parentgameobj);
|
||
|
}
|
||
|
|
||
|
|
||
|
//同步
|
||
|
CloneInfoSync(endPoint);
|
||
|
if (endHitGameobj.GetComponent<FireManControl>() ||
|
||
|
endHitGameobj.GetComponent<WaterConnonController>() ||
|
||
|
endHitGameobj.GetComponent<SnowConnonController>() ||
|
||
|
endHitGameobj.GetComponent<FireRobotController>() ||
|
||
|
endHitGameobj.GetComponent<TruckMessage>() ||
|
||
|
startHitGameobj.GetComponent<WaterSource>())
|
||
|
|
||
|
{
|
||
|
if (endHitGameobj.GetComponent<FireManControl>() ||
|
||
|
endHitGameobj.GetComponent<WaterConnonController>() ||
|
||
|
endHitGameobj.GetComponent<SnowConnonController>() ||
|
||
|
endHitGameobj.GetComponent<FireRobotController>() ||
|
||
|
endHitGameobj.GetComponent<TruckMessage>())
|
||
|
{
|
||
|
LoadPromptWin.Instance.LoadTextPromptWindow("连接成功", 1f);
|
||
|
}
|
||
|
var arg = new HoseConnectOrDelectData();
|
||
|
arg.StartId = startHitGameobj.GetComponent<BaseGameObjInfo>().gameObjID;
|
||
|
arg.EndId = endHitGameobj.GetComponent<BaseGameObjInfo>().gameObjID;
|
||
|
arg.HoseId = parentgameobj.GetComponent<BaseGameObjInfo>().gameObjID;
|
||
|
arg.Isconnect = true;
|
||
|
MessageDispatcher.SendMessage("HOSE_CONNECT_OR_DELECT", arg);
|
||
|
}
|
||
|
//如果连接到消防车、消防员或者水源上,重置信息,准备另画一条水带
|
||
|
if (endHitGameobj.GetComponent<WaterSource>() ||
|
||
|
endHitGameobj.GetComponent<FireManControl>() ||
|
||
|
endHitGameobj.GetComponent<TruckMessage>() ||
|
||
|
endHitGameobj.GetComponent<WaterConnonController>() ||
|
||
|
endHitGameobj.GetComponent<SnowConnonController>() ||
|
||
|
endHitGameobj.GetComponent<FireRobotController>())
|
||
|
{
|
||
|
WaterHoseExpend expend = new WaterHoseExpend
|
||
|
{
|
||
|
WaterHoseDraw = parentgameobj,
|
||
|
Distance = parentgameobj.GetComponent<ParentLinesMessage>().LineLenght,
|
||
|
Fireman = SelectFireMan,
|
||
|
ExpendNum = Mathf.CeilToInt(parentgameobj.GetComponent<ParentLinesMessage>().LineLenght / DefultHoseLenght),
|
||
|
};
|
||
|
MessageDispatcher.SendMessage("WATERHOSEEXPEND", expend);
|
||
|
parentgameobj.GetComponent<ParentLinesMessage>().hascalculate = true;
|
||
|
|
||
|
////重画(相当于)关闭克隆按钮再重新打开
|
||
|
//var argresertsync = new AssociatedLineSyncDate();
|
||
|
//argresertsync.IsResert = true;
|
||
|
//NetworkManager.Default.SendAsync(CurrentUserInfo.mySelf.Id, "ASSOCIATED_LINE_SYNC", argresertsync);
|
||
|
|
||
|
ResertLine();
|
||
|
}
|
||
|
SelectFireMan = null;
|
||
|
|
||
|
// NetworkManager.Default.SendAsync("POLICE_CALL_SYNC", policedata);
|
||
|
}
|
||
|
}
|
||
|
public GameObject CreatLine(Vector3 startPoint, Vector3 endPoint)
|
||
|
{
|
||
|
float distance = Vector3.Distance(startPoint, endPoint);//计算两点的距离
|
||
|
if (distance < 2)
|
||
|
{
|
||
|
pathPoints.Remove(endPoint);
|
||
|
LoadPromptWin.Instance.LoadTextPromptWindow("两点重合", 1f);
|
||
|
return null;
|
||
|
}
|
||
|
//parentgameobj.GetComponent<ParentLinesMessage>().LineLenght += distance;
|
||
|
Vector3 clonedObjPos = (startPoint + endPoint) / 2;
|
||
|
clonedObjPos = new Vector3(clonedObjPos.x, clonedObjPos.y + Height, clonedObjPos.z);
|
||
|
return Instantiate(clonePrefab);
|
||
|
}
|
||
|
//设置克隆物体所在楼层等基本属性,属性从点击的对象上获取
|
||
|
public void Setattribute(long HitID, GameObject Clone)
|
||
|
{
|
||
|
var hitObj = EntitiesManager.Instance.GetEntityByID(HitID);
|
||
|
CloneGameObjInfo hitObjInfo = hitObj.GetComponent<CloneGameObjInfo>();
|
||
|
CloneGameObjInfo cloneObjInfo = Clone.GetComponent<CloneGameObjInfo>();
|
||
|
cloneObjInfo.gameObjType = cloneObjType;
|
||
|
cloneObjInfo.UserID = CurrentUserInfo.mySelf.Id;
|
||
|
cloneObjInfo.buildNum = hitObjInfo.buildNum;
|
||
|
cloneObjInfo.floorNum = hitObjInfo.floorNum;
|
||
|
cloneObjInfo.interlayerNum = hitObjInfo.interlayerNum;
|
||
|
}
|
||
|
/// <summary>
|
||
|
/// 当前物体时候是否还能再连接管线,连接两辆水原车时
|
||
|
/// </summary>
|
||
|
/// <param name="Hitobj"></param>
|
||
|
/// <returns></returns>
|
||
|
private bool checkCanConnetOrNo(GameObject Hitobj)
|
||
|
{
|
||
|
bool can = true;
|
||
|
if (Hitobj == startHitGameobj)
|
||
|
{//连接起点
|
||
|
if (!Hitobj.GetComponent<WaterSource>())
|
||
|
{
|
||
|
LoadPromptWin.Instance.LoadTextPromptWindow("该物体不能供水,不能作为连接起点,请选择水源作为连接起点", 2f);
|
||
|
can = false;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
// 地上消火栓 / 泡沫栓
|
||
|
if (Hitobj.GetComponent<XFSS>())
|
||
|
{
|
||
|
if (Hitobj.GetComponent<WaterSource>().ConnectGameObj != null)
|
||
|
{
|
||
|
LoadPromptWin.Instance.LoadTextPromptWindow("当前消防设施不能连接更多管线", 2f);
|
||
|
can = false;
|
||
|
}
|
||
|
}
|
||
|
else if (Hitobj.GetComponent<TruckMessage>())
|
||
|
{//水源车
|
||
|
TruckBindWaterSource truckbind = Hitobj.GetComponent<TruckBindWaterSource>();
|
||
|
//起点为水源车
|
||
|
if (truckbind.DirectConnectObj1.Key != null && truckbind.DirectConnectObj2.Key != null)
|
||
|
{
|
||
|
LoadPromptWin.Instance.LoadTextPromptWindow("当前水源车没有更多出水口", 1f);
|
||
|
can = false;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|
||
|
else
|
||
|
{//终点
|
||
|
if (Hitobj.GetComponent<WaterSource>() && Hitobj.GetComponent<XFSS>())
|
||
|
{//消防设施
|
||
|
LoadPromptWin.Instance.LoadTextPromptWindow("消防设施不能作为连接终点", 1f);
|
||
|
can = false;
|
||
|
}
|
||
|
//消防员
|
||
|
if (Hitobj.GetComponent<FireManControl>())
|
||
|
{
|
||
|
if (Hitobj.GetComponent<FireManWaterHoseManager>().IsConnentWaterLine)
|
||
|
{
|
||
|
LoadPromptWin.Instance.LoadTextPromptWindow("当前消防员已连接管线", 1f);
|
||
|
can = false;
|
||
|
}
|
||
|
}
|
||
|
//水炮
|
||
|
else if (Hitobj.GetComponent<WaterConnonController>())
|
||
|
{
|
||
|
if (Hitobj.GetComponent<WaterConnonController>().IsConnentWaterLine)
|
||
|
{
|
||
|
LoadPromptWin.Instance.LoadTextPromptWindow("当前水泡已连接管线", 1f);
|
||
|
can = false;
|
||
|
}
|
||
|
}
|
||
|
//雪炮
|
||
|
else if (Hitobj.GetComponent<BaseGameObjInfo>().gameObjType == CloneObjType.SnowCannon)
|
||
|
{
|
||
|
if (Hitobj.GetComponent<SnowConnonController>().IsConnentWaterLine)
|
||
|
{
|
||
|
LoadPromptWin.Instance.LoadTextPromptWindow("当前暴风雪炮已连接管线", 1f);
|
||
|
can = false;
|
||
|
}
|
||
|
}
|
||
|
//机器人
|
||
|
else if (Hitobj.GetComponent<BaseGameObjInfo>().gameObjType == CloneObjType.FirefightingRobot)
|
||
|
{
|
||
|
if (Hitobj.GetComponent<FireRobotWaterHoseManage>().IsConnentWaterLine)
|
||
|
{
|
||
|
LoadPromptWin.Instance.LoadTextPromptWindow("当前灭火机器人已连接管线", 1f);
|
||
|
can = false;
|
||
|
}
|
||
|
}
|
||
|
//车辆
|
||
|
if (Hitobj.GetComponent<TruckMessage>())
|
||
|
{
|
||
|
TruckBindWaterSource truckbind = Hitobj.GetComponent<TruckBindWaterSource>();
|
||
|
if (truckbind.WaterSourceLine1.Count > 0 && truckbind.WaterSourceLine2.Count > 0)
|
||
|
{
|
||
|
LoadPromptWin.Instance.LoadTextPromptWindow("当前车辆没有更多进水口", 1f);
|
||
|
can = false;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
if (Hitobj.GetComponent<WaterSource>() && startHitGameobj.GetComponent<TruckMessage>())
|
||
|
{ //起点、终点都是水源车,判断是都形成循环闭路
|
||
|
can = !checkCloseLoop(startHitGameobj, Hitobj);
|
||
|
if (!can)
|
||
|
{
|
||
|
LoadPromptWin.Instance.LoadTextPromptWindow("组成闭合回路", 1f);
|
||
|
}
|
||
|
//if (close==false)
|
||
|
//{//判断两端所属的供水网络是否都在出水
|
||
|
|
||
|
//}
|
||
|
}
|
||
|
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
return can;
|
||
|
}
|
||
|
/// <summary>
|
||
|
/// 连接时检查车是否构成闭环
|
||
|
/// </summary>
|
||
|
/// <returns></returns>
|
||
|
bool checkCloseLoop(GameObject start, GameObject end)
|
||
|
{
|
||
|
bool close = false;
|
||
|
if (start.GetComponent<TruckBindWaterSource>())
|
||
|
{
|
||
|
long endid = end.GetComponent<BaseGameObjInfo>().gameObjID;
|
||
|
List<List<long>> startwatersourcelist = start.GetComponent<TruckBindWaterSource>().GetAllWaterSource();
|
||
|
for (int i = 0; i < startwatersourcelist.Count; i++)
|
||
|
{
|
||
|
for (int j = 0; j < startwatersourcelist[i].Count; j++)
|
||
|
{
|
||
|
if (startwatersourcelist[i][j] == endid)
|
||
|
{
|
||
|
close = true;
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
return close;
|
||
|
}
|
||
|
public void CreatParents()
|
||
|
{
|
||
|
parentgameobj = EntitiesManager.Instance.CreateObj(parent, transform.position, transform, gameObjID);// GameObject.Instantiate(parent, transform);
|
||
|
if (FireManSkillPanelController.Instance)
|
||
|
{
|
||
|
if (SelectFireMan.GetComponent<FireManControl>().workType == FireManSkills.AssociatedLine)
|
||
|
{
|
||
|
FireManSkillPanelController.Instance.FiremanAssociatedLine = parentgameobj;
|
||
|
}
|
||
|
}
|
||
|
parentgameobj.GetComponent<BaseGameObjInfo>().gameObjType = cloneObjType;
|
||
|
parentgameobj.transform.parent = transform;
|
||
|
parentgameobj.name = cloneObjType.ToString();
|
||
|
}
|
||
|
/// <summary>
|
||
|
/// 是多点创建一个父物体,不是多点,每2点创建一个父物体。
|
||
|
/// </summary>
|
||
|
/// <param name="imessageobj"></param>
|
||
|
public void TwoOrMore(IMessage imessageobj)
|
||
|
{
|
||
|
if (PointOverTwo)
|
||
|
{
|
||
|
if (parentgameobj != null)
|
||
|
{
|
||
|
return;
|
||
|
}
|
||
|
CreatParents();
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
if (endPoint == Vector3.zero && startPoint != Vector3.zero)
|
||
|
{
|
||
|
CreatParents();
|
||
|
}
|
||
|
|
||
|
if (pathPoints.Count > 0)
|
||
|
{
|
||
|
pathPoints.Clear();
|
||
|
startPoint = Vector3.zero;
|
||
|
endPoint = Vector3.zero;
|
||
|
return;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public void ResertLine()
|
||
|
{
|
||
|
beginLinePoint = Vector3.zero;
|
||
|
startPoint = Vector3.zero;
|
||
|
endPoint = Vector3.zero;
|
||
|
parentgameobj = null;
|
||
|
//startHitGameobj = null;
|
||
|
//endHitGameobj = null;
|
||
|
StartObjIsWaterSource = false;
|
||
|
gameObjID = 0;
|
||
|
//cloneObjType = CloneObjType.None;
|
||
|
}
|
||
|
/// <summary>
|
||
|
/// 检查是否有足够水带
|
||
|
/// </summary>
|
||
|
/// <param name="distance"></param>
|
||
|
private bool WaterHoseAndOverLenght(float distance)
|
||
|
{
|
||
|
bool can = false;
|
||
|
|
||
|
if (SelectFireMan.GetComponent<FireManWaterHoseManager>().CheckHoseIsEnough(distance))
|
||
|
{
|
||
|
can = true;
|
||
|
}
|
||
|
return can;
|
||
|
}
|
||
|
/// <summary>
|
||
|
/// 检查是否携带水带
|
||
|
/// </summary>
|
||
|
private bool HasEquipWaterHose()
|
||
|
{
|
||
|
|
||
|
if (SelectedObjs.selectedCharacters.Count > 0)
|
||
|
SelectFireMan = SelectedObjs.selectedCharacters[0];
|
||
|
if (SelectFireMan != null)
|
||
|
{
|
||
|
if (!SelectFireMan.GetComponent<FireManWaterHoseManager>().HasWaterHose)
|
||
|
{
|
||
|
LoadPromptWin.Instance.LoadTextPromptWindow("未携带水带", 1f);
|
||
|
|
||
|
return false;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
return true;
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
return false;
|
||
|
}
|
||
|
}
|
||
|
/// <summary>
|
||
|
/// 消耗水带
|
||
|
/// </summary>
|
||
|
/// <param name="distance"></param>
|
||
|
private void ExpendHose(float distance, float alldistance)
|
||
|
{
|
||
|
SelectFireMan.GetComponent<FireManWaterHoseManager>().ExpendHose(distance, alldistance);//.WaterHoseLenghtRemain -= distance;
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// 连接管线判断起点跟终点物体是否可连接(因为改为起点必须为水源,所以没用了)
|
||
|
/// </summary>
|
||
|
private bool JugeConnent()
|
||
|
{
|
||
|
bool can = true;
|
||
|
//如果首尾是同一物体
|
||
|
if (startHitGameobj == endHitGameobj)
|
||
|
{
|
||
|
LoadPromptWin.Instance.LoadTextPromptWindow("不能连在同一物体上", 1f);
|
||
|
can = false;
|
||
|
}
|
||
|
|
||
|
//两端都是非消防车的水源
|
||
|
if (startHitGameobj.GetComponent<WaterSource>() && endHitGameobj.GetComponent<WaterSource>())
|
||
|
{
|
||
|
if ((!startHitGameobj.GetComponent<TruckMessage>()) && (!endHitGameobj.GetComponent<TruckMessage>()))
|
||
|
{
|
||
|
LoadPromptWin.Instance.LoadTextPromptWindow("不能两端都是消防栓", 1f);
|
||
|
can = false;
|
||
|
}
|
||
|
}
|
||
|
//一端为非水源车、人、水炮、雪炮、机器人
|
||
|
if (startHitGameobj.GetComponent<FireManControl>() ||
|
||
|
startHitGameobj.GetComponent<WaterConnonController>() ||
|
||
|
startHitGameobj.GetComponent<SnowConnonController>() ||
|
||
|
startHitGameobj.GetComponent<FireRobotController>() ||
|
||
|
(startHitGameobj.GetComponent<TruckBindWaterSource>() && !startHitGameobj.GetComponent<WaterSource>()))
|
||
|
{
|
||
|
if (endHitGameobj.GetComponent<FireManControl>() ||
|
||
|
endHitGameobj.GetComponent<WaterConnonController>() ||
|
||
|
endHitGameobj.GetComponent<SnowConnonController>() ||
|
||
|
endHitGameobj.GetComponent<FireRobotController>() ||
|
||
|
(endHitGameobj.GetComponent<TruckBindWaterSource>() && !endHitGameobj.GetComponent<WaterSource>()))
|
||
|
{
|
||
|
LoadPromptWin.Instance.LoadTextPromptWindow("连接两端至少有一端为水源", 2f);
|
||
|
can = false;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return can;
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// 连接消防员判断
|
||
|
/// </summary>
|
||
|
private void connentFireMan()
|
||
|
{
|
||
|
if (startHitGameobj.GetComponent<FireManControl>())
|
||
|
{
|
||
|
if (!startHitGameobj.GetComponent<FireManWaterHoseManager>().IsConnentWaterLine)
|
||
|
{
|
||
|
LoadPromptWin.Instance.LoadTextPromptWindow("连接一名消防员", 1f);
|
||
|
}
|
||
|
startHitGameobj.GetComponent<FireManWaterHoseManager>().IsConnentWaterLine = true;
|
||
|
startHitGameobj.GetComponent<FireManWaterHoseManager>().WaterLineConnent = parentgameobj;
|
||
|
startHitGameobj.GetComponent<AgentController>().pathFindEnable = false;
|
||
|
var another = parentgameobj.GetComponent<ParentLinesMessage>().GetAnotherGameObj(startHitGameobj);
|
||
|
if (another.GetComponent<WaterSource>())
|
||
|
{
|
||
|
startHitGameobj.GetComponent<FireManWaterHoseManager>().hasWaterConnect = another.GetComponent<WaterSource>().water;
|
||
|
startHitGameobj.GetComponent<FireManWaterHoseManager>().hasFoamConnect = another.GetComponent<WaterSource>().foam;
|
||
|
startHitGameobj.GetComponent<LayWaterHose>().SetInitPoint();
|
||
|
// LoadPromptWin.Instance.LoadTextPromptWindow("连接成功", 1f);
|
||
|
}
|
||
|
if (another.GetComponent<TruckBindWaterSource>())
|
||
|
{
|
||
|
startHitGameobj.GetComponent<FireManWaterHoseManager>().hasWaterConnect = another.GetComponent<TruckBindWaterSource>().ConnectWater;
|
||
|
startHitGameobj.GetComponent<FireManWaterHoseManager>().hasFoamConnect = another.GetComponent<TruckBindWaterSource>().ConnectFoam;
|
||
|
startHitGameobj.GetComponent<LayWaterHose>().SetInitPoint();
|
||
|
//LoadPromptWin.Instance.LoadTextPromptWindow("连接成功", 1f);
|
||
|
}
|
||
|
|
||
|
}
|
||
|
if (endHitGameobj.GetComponent<FireManControl>())
|
||
|
{
|
||
|
LoadPromptWin.Instance.LoadTextPromptWindow("连接一名消防员", 1f);
|
||
|
endHitGameobj.GetComponent<FireManWaterHoseManager>().IsConnentWaterLine = true;
|
||
|
endHitGameobj.GetComponent<AgentController>().pathFindEnable = false;
|
||
|
endHitGameobj.GetComponent<FireManWaterHoseManager>().WaterLineConnent = parentgameobj;
|
||
|
var another = parentgameobj.GetComponent<ParentLinesMessage>().GetAnotherGameObj(endHitGameobj);
|
||
|
if (another.GetComponent<WaterSource>())
|
||
|
{
|
||
|
endHitGameobj.GetComponent<FireManWaterHoseManager>().hasWaterConnect = another.GetComponent<WaterSource>().water;
|
||
|
endHitGameobj.GetComponent<FireManWaterHoseManager>().hasFoamConnect = another.GetComponent<WaterSource>().foam;
|
||
|
endHitGameobj.GetComponent<LayWaterHose>().SetInitPoint();
|
||
|
// LoadPromptWin.Instance.LoadTextPromptWindow("连接一名消防员", 1f);
|
||
|
}
|
||
|
if (another.GetComponent<TruckBindWaterSource>())
|
||
|
{
|
||
|
endHitGameobj.GetComponent<FireManWaterHoseManager>().hasWaterConnect = another.GetComponent<TruckBindWaterSource>().ConnectWater;
|
||
|
endHitGameobj.GetComponent<FireManWaterHoseManager>().hasFoamConnect = another.GetComponent<TruckBindWaterSource>().ConnectFoam;
|
||
|
endHitGameobj.GetComponent<LayWaterHose>().SetInitPoint();
|
||
|
//LoadPromptWin.Instance.LoadTextPromptWindow("连接一名消防员", 1f);
|
||
|
}
|
||
|
// ResertLine();
|
||
|
|
||
|
}
|
||
|
|
||
|
}
|
||
|
/// <summary>
|
||
|
/// 连接水炮判断
|
||
|
/// </summary>
|
||
|
private void connentWaterCannon()
|
||
|
{
|
||
|
if (startHitGameobj.GetComponent<WaterConnonController>())
|
||
|
{
|
||
|
if (!startHitGameobj.GetComponent<WaterConnonController>().IsConnentWaterLine)
|
||
|
{
|
||
|
LoadPromptWin.Instance.LoadTextPromptWindow("连接一台水炮", 1f);
|
||
|
}
|
||
|
startHitGameobj.GetComponent<WaterConnonController>().IsConnentWaterLine = true;
|
||
|
startHitGameobj.GetComponent<WaterConnonController>().WaterLineConnent = parentgameobj;
|
||
|
// startHitGameobj.GetComponent<AgentController>().pathFindEnable = false;
|
||
|
startHitGameobj.GetComponent<ObjDrag>().enabled = false;
|
||
|
var another = parentgameobj.GetComponent<ParentLinesMessage>().GetAnotherGameObj(startHitGameobj);
|
||
|
if (another.GetComponent<WaterSource>())
|
||
|
{
|
||
|
startHitGameobj.GetComponent<WaterConnonController>().hasWaterConnect = another.GetComponent<WaterSource>().water;
|
||
|
startHitGameobj.GetComponent<WaterConnonController>().hasFoamConnect = another.GetComponent<WaterSource>().foam;
|
||
|
// LoadPromptWin.Instance.LoadTextPromptWindow("连接成功", 1f);
|
||
|
//startHitGameobj.GetComponent<LayWaterHose>().SetInitPoint();
|
||
|
}
|
||
|
if (another.GetComponent<TruckBindWaterSource>())
|
||
|
{
|
||
|
startHitGameobj.GetComponent<WaterConnonController>().hasWaterConnect = another.GetComponent<TruckBindWaterSource>().ConnectWater;
|
||
|
startHitGameobj.GetComponent<WaterConnonController>().hasFoamConnect = another.GetComponent<TruckBindWaterSource>().ConnectFoam;
|
||
|
// LoadPromptWin.Instance.LoadTextPromptWindow("连接成功", 1f);
|
||
|
//startHitGameobj.GetComponent<LayWaterHose>().SetInitPoint();
|
||
|
}
|
||
|
|
||
|
}
|
||
|
if (endHitGameobj.GetComponent<WaterConnonController>())
|
||
|
{
|
||
|
LoadPromptWin.Instance.LoadTextPromptWindow("连接一台水炮", 1f);
|
||
|
endHitGameobj.GetComponent<WaterConnonController>().IsConnentWaterLine = true;
|
||
|
endHitGameobj.GetComponent<ObjDrag>().enabled = false;
|
||
|
//endHitGameobj.GetComponent<AgentController>().pathFindEnable = false;
|
||
|
endHitGameobj.GetComponent<WaterConnonController>().WaterLineConnent = parentgameobj;
|
||
|
var another = parentgameobj.GetComponent<ParentLinesMessage>().GetAnotherGameObj(endHitGameobj);
|
||
|
if (another.GetComponent<WaterSource>())
|
||
|
{
|
||
|
endHitGameobj.GetComponent<WaterConnonController>().hasWaterConnect = another.GetComponent<WaterSource>().water;
|
||
|
endHitGameobj.GetComponent<WaterConnonController>().hasFoamConnect = another.GetComponent<WaterSource>().foam;
|
||
|
//LoadPromptWin.Instance.LoadTextPromptWindow("连接成功", 1f);
|
||
|
// endHitGameobj.GetComponent<LayWaterHose>().SetInitPoint();
|
||
|
}
|
||
|
if (another.GetComponent<TruckBindWaterSource>())
|
||
|
{
|
||
|
endHitGameobj.GetComponent<WaterConnonController>().hasWaterConnect = another.GetComponent<TruckBindWaterSource>().ConnectWater;
|
||
|
endHitGameobj.GetComponent<WaterConnonController>().hasFoamConnect = another.GetComponent<TruckBindWaterSource>().ConnectFoam;
|
||
|
//LoadPromptWin.Instance.LoadTextPromptWindow("连接成功", 1f);
|
||
|
//endHitGameobj.GetComponent<LayWaterHose>().SetInitPoint();
|
||
|
}
|
||
|
// ResertLine();
|
||
|
|
||
|
}
|
||
|
|
||
|
}
|
||
|
private void connectSnowCannon()
|
||
|
{
|
||
|
if (startHitGameobj.GetComponent<SnowConnonController>())
|
||
|
{
|
||
|
if (!startHitGameobj.GetComponent<SnowConnonController>().IsConnentWaterLine)
|
||
|
{
|
||
|
LoadPromptWin.Instance.LoadTextPromptWindow("连接一台暴风雪炮", 1f);
|
||
|
}
|
||
|
startHitGameobj.GetComponent<SnowConnonController>().IsConnentWaterLine = true;
|
||
|
startHitGameobj.GetComponent<SnowConnonController>().WaterLineConnent = parentgameobj;
|
||
|
startHitGameobj.GetComponent<ObjDrag>().enabled = false;
|
||
|
startHitGameobj.GetComponent<ObjRotate>().enabled = false;
|
||
|
var another = parentgameobj.GetComponent<ParentLinesMessage>().GetAnotherGameObj(startHitGameobj);
|
||
|
if (another.GetComponent<WaterSource>())
|
||
|
{
|
||
|
startHitGameobj.GetComponent<SnowConnonController>().hasWaterConnect = another.GetComponent<WaterSource>().water;
|
||
|
startHitGameobj.GetComponent<SnowConnonController>().hasFoamConnect = another.GetComponent<WaterSource>().foam;
|
||
|
}
|
||
|
if (another.GetComponent<TruckBindWaterSource>())
|
||
|
{
|
||
|
startHitGameobj.GetComponent<SnowConnonController>().hasWaterConnect = another.GetComponent<TruckBindWaterSource>().ConnectWater;
|
||
|
startHitGameobj.GetComponent<SnowConnonController>().hasFoamConnect = another.GetComponent<TruckBindWaterSource>().ConnectFoam;
|
||
|
}
|
||
|
|
||
|
}
|
||
|
if (endHitGameobj.GetComponent<SnowConnonController>())
|
||
|
{
|
||
|
LoadPromptWin.Instance.LoadTextPromptWindow("连接一台暴风雪炮", 1f);
|
||
|
endHitGameobj.GetComponent<SnowConnonController>().IsConnentWaterLine = true;
|
||
|
endHitGameobj.GetComponent<ObjDrag>().enabled = false;
|
||
|
endHitGameobj.GetComponent<ObjRotate>().enabled = false;
|
||
|
endHitGameobj.GetComponent<SnowConnonController>().WaterLineConnent = parentgameobj;
|
||
|
var another = parentgameobj.GetComponent<ParentLinesMessage>().GetAnotherGameObj(endHitGameobj);
|
||
|
if (another.GetComponent<WaterSource>())
|
||
|
{
|
||
|
endHitGameobj.GetComponent<SnowConnonController>().hasWaterConnect = another.GetComponent<WaterSource>().water;
|
||
|
endHitGameobj.GetComponent<SnowConnonController>().hasFoamConnect = another.GetComponent<WaterSource>().foam;
|
||
|
}
|
||
|
if (another.GetComponent<TruckBindWaterSource>())
|
||
|
{
|
||
|
endHitGameobj.GetComponent<SnowConnonController>().hasWaterConnect = another.GetComponent<TruckBindWaterSource>().ConnectWater;
|
||
|
endHitGameobj.GetComponent<SnowConnonController>().hasFoamConnect = another.GetComponent<TruckBindWaterSource>().ConnectFoam;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// 连接水源判断,若两端都是水源,这里水源信息赋值的是后点击水源
|
||
|
/// </summary>
|
||
|
private void connentWaterSource()
|
||
|
{
|
||
|
if (startHitGameobj.GetComponent<WaterSource>())
|
||
|
{
|
||
|
if (!StartObjIsWaterSource)
|
||
|
{
|
||
|
//LoadPromptWin.Instance.LoadTextPromptWindow("连接到水源", 1f);
|
||
|
parentgameobj.GetComponent<ParentLinesMessage>().HasWaterConnent = true;
|
||
|
parentgameobj.GetComponent<ParentLinesMessage>().WaterSource = startHitGameobj;
|
||
|
StartObjIsWaterSource = true;
|
||
|
}
|
||
|
}
|
||
|
if (endHitGameobj.GetComponent<WaterSource>())
|
||
|
{
|
||
|
//LoadPromptWin.Instance.LoadTextPromptWindow("连接到水源", 1f);
|
||
|
parentgameobj.GetComponent<ParentLinesMessage>().HasWaterConnent = true;
|
||
|
parentgameobj.GetComponent<ParentLinesMessage>().WaterSource = endHitGameobj;
|
||
|
//ResertLine();
|
||
|
}
|
||
|
if (startHitGameobj.GetComponent<WaterSource>() && endHitGameobj.GetComponent<WaterSource>())
|
||
|
{
|
||
|
LoadPromptWin.Instance.LoadTextPromptWindow("连接成功", 1f);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private void connentFireCar()
|
||
|
{
|
||
|
if (startHitGameobj.GetComponent<TruckBindWaterSource>() && !startHitGameobj.GetComponent<WaterSource>())
|
||
|
{
|
||
|
if (endHitGameobj.GetComponent<WaterSource>())
|
||
|
{
|
||
|
LoadPromptWin.Instance.LoadTextPromptWindow("连接成功", 1f);
|
||
|
}
|
||
|
}
|
||
|
if (endHitGameobj.GetComponent<TruckBindWaterSource>() && !endHitGameobj.GetComponent<WaterSource>())
|
||
|
{
|
||
|
if (startHitGameobj.GetComponent<WaterSource>())
|
||
|
{
|
||
|
LoadPromptWin.Instance.LoadTextPromptWindow("连接成功", 1f);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private void OneFiremanAnotherWaterSource()
|
||
|
{
|
||
|
if (startHitGameobj.GetComponent<WaterSource>() && endHitGameobj.GetComponent<FireManControl>())
|
||
|
{
|
||
|
endHitGameobj.GetComponent<FireManWaterHoseManager>().IsConnentWaterSource = true;
|
||
|
endHitGameobj.GetComponent<FireManWaterHoseManager>().ConnentSource = startHitGameobj;
|
||
|
if (SelectFireMan.GetComponent<BaseGameObjInfo>().gameObjID ==
|
||
|
FireManSkillPanelController.Instance.SelectFireMan.GetComponent<BaseGameObjInfo>().gameObjID)
|
||
|
{
|
||
|
FireManSkillPanelController.Instance.SprayWater.GetComponent<Toggle>().interactable = true;
|
||
|
}
|
||
|
LoadPromptWin.Instance.LoadTextPromptWindow("连接成功", 1f);
|
||
|
}
|
||
|
if (startHitGameobj.GetComponent<FireManControl>() && endHitGameobj.GetComponent<WaterSource>())
|
||
|
{
|
||
|
startHitGameobj.GetComponent<FireManWaterHoseManager>().IsConnentWaterSource = true;
|
||
|
startHitGameobj.GetComponent<FireManWaterHoseManager>().ConnentSource = endHitGameobj;
|
||
|
if (SelectFireMan.GetComponent<BaseGameObjInfo>().gameObjID ==
|
||
|
FireManSkillPanelController.Instance.SelectFireMan.GetComponent<BaseGameObjInfo>().gameObjID)
|
||
|
{
|
||
|
FireManSkillPanelController.Instance.SprayWater.GetComponent<Toggle>().interactable = true;
|
||
|
}
|
||
|
LoadPromptWin.Instance.LoadTextPromptWindow("连接成功", 1f);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private void OneWaterCannonAnotherWaterSource()
|
||
|
{
|
||
|
if (startHitGameobj.GetComponent<WaterSource>() && endHitGameobj.GetComponent<WaterConnonController>())
|
||
|
{
|
||
|
endHitGameobj.GetComponent<WaterConnonController>().IsConnentWaterSource = true;
|
||
|
endHitGameobj.GetComponent<WaterConnonController>().ConnentSource = startHitGameobj;
|
||
|
//if (SelectFireMan.GetComponent<BaseGameObjInfo>().gameObjID ==
|
||
|
// FireManSkillPanelController.Instance.SelectFireMan.GetComponent<BaseGameObjInfo>().gameObjID)
|
||
|
//{
|
||
|
//MoveWaterConnonSkillPanelController.Instance.SprayWater.GetComponent<Toggle>().interactable = true;
|
||
|
//}
|
||
|
LoadPromptWin.Instance.LoadTextPromptWindow("连接成功", 1f);
|
||
|
}
|
||
|
if (startHitGameobj.GetComponent<WaterConnonController>() && endHitGameobj.GetComponent<WaterSource>())
|
||
|
{
|
||
|
startHitGameobj.GetComponent<WaterConnonController>().IsConnentWaterSource = true;
|
||
|
startHitGameobj.GetComponent<WaterConnonController>().ConnentSource = endHitGameobj;
|
||
|
//if (SelectFireMan.GetComponent<BaseGameObjInfo>().gameObjID ==
|
||
|
// FireManSkillPanelController.Instance.SelectFireMan.GetComponent<BaseGameObjInfo>().gameObjID)
|
||
|
//{
|
||
|
// MoveWaterConnonSkillPanelController.Instance.SprayWater.GetComponent<Toggle>().interactable = true;
|
||
|
//}
|
||
|
LoadPromptWin.Instance.LoadTextPromptWindow("连接成功", 1f);
|
||
|
}
|
||
|
}
|
||
|
private void OneSnowCannonAnotherWaterSource()
|
||
|
{
|
||
|
if (startHitGameobj.GetComponent<WaterSource>() && endHitGameobj.GetComponent<SnowConnonController>())
|
||
|
{
|
||
|
endHitGameobj.GetComponent<SnowConnonController>().IsConnentWaterSource = true;
|
||
|
endHitGameobj.GetComponent<SnowConnonController>().ConnentSource = startHitGameobj;
|
||
|
//if (SelectFireMan.GetComponent<BaseGameObjInfo>().gameObjID ==
|
||
|
// FireManSkillPanelController.Instance.SelectFireMan.GetComponent<BaseGameObjInfo>().gameObjID)
|
||
|
//{
|
||
|
//MoveWaterConnonSkillPanelController.Instance.SprayWater.GetComponent<Toggle>().interactable = true;
|
||
|
//}
|
||
|
LoadPromptWin.Instance.LoadTextPromptWindow("连接成功", 1f);
|
||
|
}
|
||
|
if (startHitGameobj.GetComponent<SnowConnonController>() && endHitGameobj.GetComponent<WaterSource>())
|
||
|
{
|
||
|
startHitGameobj.GetComponent<SnowConnonController>().IsConnentWaterSource = true;
|
||
|
startHitGameobj.GetComponent<SnowConnonController>().ConnentSource = endHitGameobj;
|
||
|
//if (SelectFireMan.GetComponent<BaseGameObjInfo>().gameObjID ==
|
||
|
// FireManSkillPanelController.Instance.SelectFireMan.GetComponent<BaseGameObjInfo>().gameObjID)
|
||
|
//{
|
||
|
// MoveWaterConnonSkillPanelController.Instance.SprayWater.GetComponent<Toggle>().interactable = true;
|
||
|
//}
|
||
|
LoadPromptWin.Instance.LoadTextPromptWindow("连接成功", 1f);
|
||
|
}
|
||
|
}
|
||
|
private void OneFireRobotAnotherWaterSource()
|
||
|
{
|
||
|
if (startHitGameobj.GetComponent<WaterSource>() && endHitGameobj.GetComponent<FireRobotController>())
|
||
|
{
|
||
|
endHitGameobj.GetComponent<FireRobotWaterHoseManage>().IsConnentWaterSource = true;
|
||
|
endHitGameobj.GetComponent<FireRobotWaterHoseManage>().ConnentSource = startHitGameobj;
|
||
|
endHitGameobj.GetComponent<FireRobotWaterHoseManage>().IsConnentWaterLine = true;
|
||
|
endHitGameobj.GetComponent<FireRobotWaterHoseManage>().WaterLineConnent = parentgameobj;
|
||
|
endHitGameobj.GetComponent<AgentController>().pathFindEnable = false;
|
||
|
//var another = parentgameobj.GetComponent<ParentLinesMessage>().GetAnotherGameObj(startHitGameobj);
|
||
|
//if (startHitGameobj.GetComponent<WaterSource>())
|
||
|
{
|
||
|
endHitGameobj.GetComponent<FireRobotWaterHoseManage>().hasWaterConnect = startHitGameobj.GetComponent<WaterSource>().water;
|
||
|
endHitGameobj.GetComponent<FireRobotWaterHoseManage>().hasFoamConnect = startHitGameobj.GetComponent<WaterSource>().foam;
|
||
|
//endHitGameobj.GetComponent<LayWaterHose>().SetInitPoint();
|
||
|
|
||
|
}
|
||
|
//if (SelectFireMan.GetComponent<BaseGameObjInfo>().gameObjID ==
|
||
|
// FireManSkillPanelController.Instance.SelectFireMan.GetComponent<BaseGameObjInfo>().gameObjID)
|
||
|
//{
|
||
|
// FireManSkillPanelController.Instance.SprayWater.GetComponent<Toggle>().interactable = true;
|
||
|
//}
|
||
|
LoadPromptWin.Instance.LoadTextPromptWindow("连接成功", 1f);
|
||
|
}
|
||
|
if (endHitGameobj.GetComponent<WaterSource>() && startHitGameobj.GetComponent<FireRobotController>())
|
||
|
{
|
||
|
startHitGameobj.GetComponent<FireRobotWaterHoseManage>().IsConnentWaterSource = true;
|
||
|
startHitGameobj.GetComponent<FireRobotWaterHoseManage>().ConnentSource = endHitGameobj;
|
||
|
startHitGameobj.GetComponent<FireRobotWaterHoseManage>().IsConnentWaterLine = true;
|
||
|
startHitGameobj.GetComponent<FireRobotWaterHoseManage>().WaterLineConnent = parentgameobj;
|
||
|
startHitGameobj.GetComponent<AgentController>().pathFindEnable = false;
|
||
|
//var another = parentgameobj.GetComponent<ParentLinesMessage>().GetAnotherGameObj(startHitGameobj);
|
||
|
//if (startHitGameobj.GetComponent<WaterSource>())
|
||
|
{
|
||
|
startHitGameobj.GetComponent<FireRobotWaterHoseManage>().hasWaterConnect = endHitGameobj.GetComponent<WaterSource>().water;
|
||
|
startHitGameobj.GetComponent<FireRobotWaterHoseManage>().hasFoamConnect = endHitGameobj.GetComponent<WaterSource>().foam;
|
||
|
//endHitGameobj.GetComponent<LayWaterHose>().SetInitPoint();
|
||
|
|
||
|
}
|
||
|
//if (SelectFireMan.GetComponent<BaseGameObjInfo>().gameObjID ==
|
||
|
// FireManSkillPanelController.Instance.SelectFireMan.GetComponent<BaseGameObjInfo>().gameObjID)
|
||
|
//{
|
||
|
// FireManSkillPanelController.Instance.SprayWater.GetComponent<Toggle>().interactable = true;
|
||
|
//}
|
||
|
LoadPromptWin.Instance.LoadTextPromptWindow("连接成功", 1f);
|
||
|
}
|
||
|
}
|
||
|
/// <summary>
|
||
|
/// 连线时,若为车、人,水炮,雪炮,机器人调整起点或终点位置
|
||
|
/// </summary>
|
||
|
/// <param name="hitobj"></param>
|
||
|
/// <returns></returns>
|
||
|
private Vector3 correctPoint(GameObject hitobj)
|
||
|
{
|
||
|
Vector3 corr = Vector3.zero;
|
||
|
if (hitobj.GetComponent<TruckMessage>())
|
||
|
{
|
||
|
//corr = hitobj.transform.position + Vector3.up * 0.7f;
|
||
|
|
||
|
if (hitobj.GetComponent<TruckBindWaterSource>())
|
||
|
{
|
||
|
TruckBindWaterSource tbws = hitobj.GetComponent<TruckBindWaterSource>();
|
||
|
if (hitobj == startHitGameobj)
|
||
|
{
|
||
|
if (tbws.DirectConnectObj1.Key == null)
|
||
|
{
|
||
|
corr = hitobj.transform.position + new Vector3(0.5f, 0.7f, 0.75f);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
if (tbws.DirectConnectObj2.Key == null)
|
||
|
{
|
||
|
corr = hitobj.transform.position + new Vector3(-0.5f, 0.7f, -0.75f);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
if (tbws.WaterSourceLine1.Count <= 0)
|
||
|
{
|
||
|
corr = hitobj.transform.position + new Vector3(0.5f, 0.7f, 0.75f);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
corr = hitobj.transform.position + new Vector3(-0.5f, 0.7f, -0.75f);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
}
|
||
|
else if (hitobj.GetComponent<FireManControl>())
|
||
|
{
|
||
|
corr = hitobj.transform.position - Vector3.up * 0.2f;
|
||
|
}
|
||
|
else if (hitobj.GetComponent<WaterSource>() && !hitobj.GetComponent<FireManControl>())
|
||
|
{
|
||
|
corr = hitobj.transform.position;
|
||
|
}
|
||
|
else if (hitobj.GetComponent<WaterConnonController>())
|
||
|
{
|
||
|
corr = hitobj.transform.position + Vector3.up * 0.5f;
|
||
|
}
|
||
|
else if (hitobj.GetComponent<SnowConnonController>())
|
||
|
{
|
||
|
corr = hitobj.transform.Find("ConnectPos").position;
|
||
|
}
|
||
|
else if (hitobj.GetComponent<FireRobotController>())
|
||
|
{
|
||
|
corr = hitobj.transform.position;
|
||
|
}
|
||
|
return corr;
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// 如果起点连在一条水带上,改变水带的起点,这方法没用
|
||
|
/// </summary>
|
||
|
/// <param name="gameobj"></param>
|
||
|
private Vector3 changeStartPointWhileHitHose(GameObject gameobj, Vector3 hitpoint)
|
||
|
{
|
||
|
Vector3 startpointpart = Vector3.zero;
|
||
|
|
||
|
if (gameobj.GetComponent<BaseGameObjInfo>().gameObjType == CloneObjType.OrdinaryHose)
|
||
|
{
|
||
|
//水带一端连接了水源
|
||
|
//bool? connent = gameobj.GetComponent<ParentLinesMessage>().IsConnentWaterSource();
|
||
|
//if (connent != null)
|
||
|
//{
|
||
|
// if ((bool)connent)
|
||
|
// {
|
||
|
// var keyvalue = gameobj.GetComponent<ParentLinesMessage>().GetConnentWaterSourceObjAndAntherPoint();
|
||
|
// startpointpart = keyvalue.Value - Vector3.up / 2;
|
||
|
// Debug.Log(startpointpart);
|
||
|
// }
|
||
|
// else
|
||
|
// {
|
||
|
// startpointpart = Vector3.zero;
|
||
|
// }
|
||
|
|
||
|
//}
|
||
|
//else
|
||
|
//{
|
||
|
// startpointpart = Vector3.zero;
|
||
|
// LoadPromptWin.Instance.LoadTextPromptWindow("不能在此连接", 1f);
|
||
|
//}
|
||
|
//水带一端连接了水带
|
||
|
// if (gameobj.GetComponent<ParentLinesMessage>().IsConnentWaterHose()) //sif()
|
||
|
//{
|
||
|
//var keyvalue = gameobj.GetComponent<ParentLinesMessage>().GetConnentWaterHoseAndAntherPoint();
|
||
|
//startpointpart = keyvalue.Value - Vector3.up / 2;
|
||
|
float start = Vector3.Distance(hitpoint, gameobj.GetComponent<ParentLinesMessage>().StartPoint);
|
||
|
float end = Vector3.Distance(hitpoint, gameobj.GetComponent<ParentLinesMessage>().EndPoint);
|
||
|
if (start > end)
|
||
|
{
|
||
|
startpointpart = gameobj.GetComponent<ParentLinesMessage>().EndPoint;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
startpointpart = gameobj.GetComponent<ParentLinesMessage>().StartPoint;
|
||
|
}
|
||
|
//}
|
||
|
}
|
||
|
|
||
|
return startpointpart;
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// 信息同步
|
||
|
/// </summary>
|
||
|
private void CloneInfoSync(Vector3 hitPoint)
|
||
|
{
|
||
|
|
||
|
///////////////////同步信息//////////////////////
|
||
|
var argsync = new AssociatedLineSyncDate();
|
||
|
// argsync.parentUID = GetComponent<UIdSystem>().Id;
|
||
|
argsync.SendUserID = CurrentUserInfo.mySelf.Id;
|
||
|
argsync.Height = Height;
|
||
|
argsync.SizeVec = SizeVec;
|
||
|
//argsync.PrefabsPath = PrefabPath;
|
||
|
argsync.lenght = parentgameobj.GetComponent<ParentLinesMessage>().LineLenght;
|
||
|
argsync.LineBeginPoint = beginLinePoint;
|
||
|
argsync.hitpoint = hitPoint;
|
||
|
argsync.startHitGameObjId = startHitGameobj.GetComponent<BaseGameObjInfo>().gameObjID;
|
||
|
argsync.endHitGameObjId = endHitGameobj.GetComponent<BaseGameObjInfo>().gameObjID;
|
||
|
argsync.CreatFiremanId = SelectFireMan.GetComponent<BaseGameObjInfo>().gameObjID;
|
||
|
//argsync.LineEndPoint = endPoint;
|
||
|
argsync.name = parentgameobj.name;
|
||
|
argsync.gameObjID = parentgameobj.GetComponent<BaseGameObjInfo>().gameObjID;
|
||
|
argsync.gameObjType = parentgameobj.GetComponent<BaseGameObjInfo>().gameObjType;
|
||
|
argsync.UserID = parentgameobj.GetComponent<BaseGameObjInfo>().UserID;
|
||
|
argsync.buildNum = parentgameobj.GetComponent<CloneGameObjInfo>().buildNum;
|
||
|
argsync.floorNum = parentgameobj.GetComponent<CloneGameObjInfo>().floorNum;
|
||
|
argsync.interlayerNum = parentgameobj.GetComponent<CloneGameObjInfo>().interlayerNum;
|
||
|
NetworkManager.Default.SendAsync(/*CurrentUserInfo.mySelf.Id,*/ "ASSOCIATED_LINE_SYNC", argsync);
|
||
|
///////////////////同步信息//////////////////////
|
||
|
|
||
|
|
||
|
|
||
|
}
|
||
|
}
|