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.
1122 lines
52 KiB
1122 lines
52 KiB
using UnityEngine; |
|
using System.Collections; |
|
using System; |
|
using UnityEngine.UI; |
|
using UnityEngine.EventSystems; |
|
using AX.MessageSystem; |
|
using AX.TrackRecord; |
|
using System.Collections.Generic; |
|
/// <summary> |
|
/// 1、鼠标通过射线点击对应的UI,实现实例化工具栏物体 |
|
/// 2、挂载在Canvas下DomeView下ToolButtonPicture; |
|
/// 3、核心方法:GetObj(); |
|
/// </summary> |
|
|
|
public class InstantiationTool : MonoBehaviour |
|
{ |
|
public static InstantiationTool Instance; |
|
|
|
//[HideInInspector] |
|
public Vector3 placementPos2;//第二碰撞点 |
|
//[HideInInspector] |
|
public Vector3 placementPos;//第一碰撞点 |
|
[HideInInspector] |
|
public Vector3 Pos1_late = new Vector3(0, 0, 0);//第一碰撞点原来的位置 |
|
[HideInInspector] |
|
public Vector3 Pos2_late = new Vector3(0, 0, 0);//第二碰撞点原来的位置 |
|
[HideInInspector] |
|
public bool Pos2Controller = false; |
|
GameObject prlineObj; |
|
GameObject pPaiYanGuanObj; |
|
private LayerMask ground_layerMask = -1; |
|
private LayerMask Tr_layerMask = -1; |
|
public string ToolName; |
|
private RaycastHit hit;//射线 |
|
DateTime t1, t2; |
|
private bool kongzhi = false; |
|
private bool lol = false; |
|
private int delta_millisecond = 400; |
|
//public Toggle JGToggle; //进攻复选框 |
|
//public Toggle RSDToggle; //软水带复选框 |
|
|
|
//public Toggle CTToggle; //撤退复选框 |
|
[HideInInspector] |
|
public bool lineFlag = false; |
|
[HideInInspector] |
|
public bool lineFiagchetui = false; |
|
[HideInInspector] |
|
public bool JG; |
|
//public GameObject nullobject; |
|
private GameObject ToolGrid; |
|
private BaseClass JG_CT; |
|
private BaseClass RSD; |
|
private GameObject CTuiOBj; |
|
private GameObject RSDObj; |
|
private GameObject SSRSDObj; |
|
private int RSDIndex = 0; |
|
private GameObject PaiYanGuanObj; |
|
private int PaiYanGuanIndex = 0; |
|
private bool chetuilol = false; |
|
private bool chetuikongzhi = false; |
|
private GameObject JGongOBj; |
|
private GameObject FGeOBJ; |
|
private GameObject DJieOBJ; |
|
[HideInInspector] |
|
public bool CT; |
|
[HideInInspector] |
|
public bool SD_one; |
|
[HideInInspector] |
|
public bool SD_two; |
|
[HideInInspector] |
|
public bool shuidai_one = false; |
|
[HideInInspector] |
|
public bool shuidai_two = false; |
|
private LayerMask RLinelayer = -1; |
|
[HideInInspector] |
|
public bool isRLineSelect = false; |
|
[HideInInspector] |
|
public LayerMask indoor_layerMask = -1;//室内层 |
|
public List<GameObject> LineSourceList = new List<GameObject>(); |
|
[HideInInspector] |
|
public List<GameObject> LineRecrdList = new List<GameObject>(); |
|
GameObject FirstGame; |
|
GameObject SecondGame; |
|
private GameObject LineRenderGameObject; |
|
private GameObject LineGameObject; |
|
//[HideInInspector] |
|
//public bool isToolSelect = false; |
|
private void SetPlacePos(Vector3 hitPoint, out Vector3 placePos, RaycastHit hit) |
|
{ |
|
//LineRecrdList.Add(hit.transform.gameObject); |
|
if (hit.transform.gameObject.name.IndexOf("xiaofangyuan") >= 0) |
|
{ |
|
placePos = hit.transform.position; |
|
//LineSourceList.Add(hit.transform.gameObject); |
|
placePos.y += 0.0f;//0.8f |
|
} |
|
else if (hit.transform.gameObject.name.IndexOf("xiaofangche") >= 0 |
|
|| hit.transform.gameObject.name.IndexOf("mb") >= 0) |
|
{ |
|
placePos = hit.transform.gameObject.transform.position; |
|
placePos = new Vector3(hit.transform.gameObject.transform.position.x, hit.transform.gameObject.transform.position.y + 0.5f, hit.point.z); |
|
//if(hit.transform.gameObject) |
|
//placePos = new Vector3 |
|
// (hit.transform.gameObject.transform.position.x, |
|
// hit.transform.gameObject.transform.position.y, |
|
// hit.transform.gameObject.transform.position.z); |
|
//LineSourceList.Add(hit.transform.gameObject); |
|
} |
|
else |
|
{ |
|
placePos = new Vector3(hit.point.x, hit.point.y + 0.3f, hit.point.z); |
|
} |
|
} |
|
void Awake() |
|
{ |
|
if (Instance == null) |
|
{ |
|
Instance = this; |
|
} |
|
Tr_layerMask = 1 << 25 | 1 << 26; |
|
RLinelayer = 1 << 25 | 1 << 26 | 1 << 27 | 1 << 30; |
|
ground_layerMask = 1 << 25 | 1 << 26; |
|
indoor_layerMask = 1 << 29 | 1 << 25 | 1 << 26; |
|
if (ExamInfoHelpClass.applicationMode == ExamInfoHelpClass.ApplicationMode.SANDTABLE) |
|
{ |
|
this.transform.Find("ScrollRect/ToolGrid/AnQuanShao").gameObject.SetActive(false); |
|
} |
|
#region |
|
ToolGrid = GameObject.Find("DomeView/BroweMenu").transform.Find("ToolButtonPicture/ScrollRect/ToolGrid").gameObject; |
|
MessageDispatcher.AddListener("ResettingButton", ResettingButton); |
|
MessageDispatcher.AddListener("InstantiateButton", GetObj); |
|
#endregion |
|
} |
|
|
|
|
|
void OnDestroy() |
|
{ |
|
MessageDispatcher.RemoveListener("ResettingButton", ResettingButton); |
|
MessageDispatcher.RemoveListener("InstantiateButton", GetObj); |
|
|
|
|
|
WaterKnockoutTrap.waterIndex = 0; |
|
StagingArea.stagingAreaIndex = 0; |
|
AQS.aqsIndex = 0; |
|
AttackArrow.arrowIndex = 0; |
|
DuJieArrow.arrowIndex = 0; |
|
SplitLine.SplitLineIndex = 0; |
|
CommandPost.commandIndex = 0; |
|
Ladder.ladderIndex = 0; |
|
StagingArea.stagingAreaIndex = 0; |
|
PoliceLine.lineIndex = 0; |
|
BaseNameText.baseNameText = 0; |
|
} |
|
//重置方法 |
|
void ResettingButton(IMessage message) |
|
{ |
|
|
|
foreach (Transform child in ToolGrid.transform) |
|
{ |
|
if (child.gameObject.GetComponent<Button>().interactable == true) |
|
{ |
|
child.Find("Image").gameObject.SetActive(false); |
|
} |
|
} |
|
if (RecordManager.Instance.IsRecording) |
|
{ |
|
switch (ToolName) |
|
{ |
|
case "JinGong": |
|
if (JGongOBj) |
|
{ |
|
MessageDispatcher.SendMessage("RecordInstantiateEvent", (object)JGongOBj.name); |
|
JGongOBj = null; |
|
} |
|
break; |
|
case "CheTui": |
|
if (CTuiOBj) |
|
{ |
|
MessageDispatcher.SendMessage("RecordInstantiateEvent", (object)CTuiOBj.name); |
|
CTuiOBj = null; |
|
} |
|
break; |
|
case "ShuiDai": |
|
if (RSDObj) |
|
{ |
|
MessageDispatcher.SendMessage("RecordInstantiateEvent", (object)RSDObj.name); |
|
RSDObj = null; |
|
} |
|
break; |
|
case "SSShuiDai": |
|
if (SSRSDObj) |
|
{ |
|
MessageDispatcher.SendMessage("RecordInstantiateEvent", (object)SSRSDObj.name); |
|
SSRSDObj = null; |
|
} |
|
break; |
|
case "FenGeXian": |
|
if (FGeOBJ) |
|
{ |
|
MessageDispatcher.SendMessage("RecordInstantiateEvent", (object)FGeOBJ.name); |
|
FGeOBJ = null; |
|
} |
|
break; |
|
case "DuJieXian": |
|
if (DJieOBJ) |
|
{ |
|
MessageDispatcher.SendMessage("RecordInstantiateEvent", (object)DJieOBJ.name); |
|
DJieOBJ = null; |
|
} |
|
break; |
|
case "PaiYanGuan": |
|
if (PaiYanGuanObj) |
|
{ |
|
MessageDispatcher.SendMessage("RecordInstantiateEvent", (object)PaiYanGuanObj.name); |
|
PaiYanGuanObj = null; |
|
} |
|
break; |
|
default: |
|
break; |
|
|
|
} |
|
} |
|
|
|
ToolName = ""; |
|
JiantouColorControl.ToolName = ToolName; |
|
} |
|
/* |
|
public void valueChangeJG( bool a) |
|
{ |
|
if (JGToggle.isOn) |
|
{ |
|
lineFlag = false; |
|
placementPos = Vector3.zero; |
|
ToolName = JingGongButton.name; |
|
//GetObj(JingGongButton); |
|
JG = true; |
|
|
|
|
|
JGongOBj = null; |
|
} |
|
else |
|
{ |
|
|
|
lineFlag = true; |
|
placementPos = Vector3.zero; |
|
|
|
//JingGongButton.transform.FindChild("Image").gameObject.SetActive(false); |
|
JG = false; |
|
if (JGongOBj) |
|
{ |
|
AttackArrow.arrowIndex++; |
|
if (RecordManager.Instance.IsRecording) |
|
{ |
|
MessageDispatcher.SendMessage("RecordInstantiateEvent", (object)JGongOBj.name); |
|
} |
|
} |
|
} |
|
|
|
} |
|
public void valueChangeCT(bool a) |
|
{ |
|
if (CTToggle.isOn) |
|
{ |
|
placementPos = Vector3.zero; |
|
lineFiagchetui = false; |
|
ToolName = CeTuiButton.name; |
|
//GetObj(CeTuiButton); |
|
CT = true; |
|
CTuiOBj = null; |
|
|
|
} |
|
else |
|
{ |
|
lineFiagchetui = true; |
|
placementPos = Vector3.zero; |
|
|
|
//CeTuiButton.transform.FindChild("Image").gameObject.SetActive(false); |
|
CT = false; |
|
if (CTuiOBj) |
|
{ |
|
RetreatArrow.arrowIndex++; |
|
if (RecordManager.Instance.IsRecording) |
|
{ |
|
MessageDispatcher.SendMessage("RecordInstantiateEvent", (object)CTuiOBj.name); |
|
} |
|
} |
|
} |
|
} |
|
public void valueCheckSD1(bool a) |
|
{ |
|
if (RSDToggle.isOn) |
|
{ |
|
|
|
LineamentEvemt.IsDrawLine = true; |
|
placementPos = Vector3.zero; |
|
shuidai_two = false; |
|
//RuanShuiDaiButton.transform.FindChild("Image").gameObject.SetActive(true); |
|
SD_two = true; |
|
ToolName = ""; |
|
RSDObj = null; |
|
} |
|
else |
|
{ |
|
LineamentEvemt.IsDrawLine = false; |
|
placementPos = Vector3.zero; |
|
shuidai_two = true; |
|
SD_two = false; |
|
//RuanShuiDaiButton.transform.FindChild("Image").gameObject.SetActive(false); |
|
if (RSDObj) |
|
{ |
|
RSDIndex++; |
|
if (RecordManager.Instance.IsRecording) |
|
{ |
|
MessageDispatcher.SendMessage("RecordInstantiateEvent", (object)RSDObj.name); |
|
} |
|
} |
|
} |
|
} |
|
*/ |
|
public void GetObj(IMessage message) |
|
{ |
|
if (gameObject.name.Contains(message.Sender.ToString())) |
|
{ |
|
var obj = (GameObject)message.Data; |
|
t2 = DateTime.Now; |
|
if (t2 - t1 < new TimeSpan(0, 0, 0, 0, delta_millisecond))//防止一次单击被检测到多次 |
|
return; |
|
MessageDispatcher.SendMessage("ResettingButton"); |
|
obj.transform.Find("Image").gameObject.SetActive(true); |
|
ToolName = obj.name; |
|
shuidai_two = false; |
|
lineFiagchetui = false; |
|
lineFlag = false; |
|
placementPos = Vector3.zero; |
|
JiantouColorControl.ToolName = ToolName; |
|
} |
|
} |
|
void Update() |
|
{ |
|
|
|
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); |
|
if (Physics.Raycast(ray, out hit, Mathf.Infinity, indoor_layerMask)) |
|
{ |
|
if (hit.collider.name.Equals("VoidWall")) |
|
{ |
|
return; |
|
} |
|
} |
|
|
|
if (Physics.Raycast(ray, out hit, Mathf.Infinity, RLinelayer) && Input.GetMouseButtonDown(0) && !EventSystem.current.IsPointerOverGameObject()) |
|
{ |
|
|
|
if (ToolName.Equals("ShuiDai")) |
|
{ |
|
if (isRLineSelect) |
|
{ |
|
return; |
|
} |
|
if (ToolName == null) |
|
{ |
|
return; |
|
} |
|
//isRLineSelect = true; |
|
GameObject parentsd = GameObject.Find("prguanxian"); |
|
string prline = "中队名" + "-" + "rguanxian" + "-" + "rline" + "-" + RSDIndex; |
|
if (!shuidai_two) |
|
{ |
|
if (placementPos.x == 0 && placementPos.y == 0 && placementPos.z == 0) |
|
{ |
|
FirstGame = null; |
|
FirstGame = hit.transform.gameObject; |
|
|
|
if (hit.transform.gameObject.name.IndexOf("xiaofang") >= 0) |
|
{ |
|
FirstGame = hit.transform.gameObject; |
|
} |
|
if (hit.transform.gameObject.name.IndexOf("xiaofangyuan") >= 0 || hit.transform.gameObject.name.Contains("mb")) |
|
{ |
|
if (hit.transform.gameObject.GetComponent<RLineControl>().LineList_GameObject.Count > 0) |
|
{ |
|
MessageDispatcher.SendMessage("Operatinghints", (object)"已经连接管线"); |
|
|
|
return; |
|
} |
|
} |
|
SetPlacePos(hit.point, out placementPos, hit); |
|
prlineObj = Instantiate(Resources.Load<GameObject>("Prefabs/ToolPrefab/NullPrefab")) as GameObject; |
|
//prlineObj.AddComponent<lineParentMessage>();//增加管线父对象信息,用于显示长度 |
|
prlineObj.name = prline; |
|
prlineObj.transform.parent = parentsd.transform; |
|
RSDObj = prlineObj; |
|
RSDIndex++; |
|
} |
|
shuidai_two = true; |
|
} |
|
else |
|
{ |
|
SetPlacePos(hit.point, out placementPos2, hit); |
|
if (placementPos.x != placementPos2.x) |
|
{ |
|
SecondGame = null; |
|
if (hit.transform.gameObject.name.Contains("xiaofangyuan") || hit.transform.gameObject.name.Contains("mb")) |
|
{ |
|
if (hit.transform.gameObject.GetComponent<RLineControl>().LineList_GameObject.Count > 0) |
|
{ |
|
MessageDispatcher.SendMessage("Operatinghints", (object)"已经连接管线"); |
|
MessageDispatcher.SendMessage("SelectControl", (object)""); |
|
LineamentEvent.gameobj = null; |
|
return; |
|
} |
|
|
|
//如果管线的另一头是消防员,要判断一下之前那一头是不是消防员 |
|
if (FirstGame&&FirstGame.name.Contains("xiaofangyuan")) |
|
{ |
|
return; |
|
} |
|
|
|
} |
|
|
|
|
|
SecondGame = hit.transform.gameObject; |
|
if (hit.transform.gameObject.name.IndexOf("xiaofang") >= 0 || hit.transform.gameObject.name.Contains("mb")) |
|
{ |
|
SecondGame = hit.transform.gameObject; |
|
} |
|
if (prlineObj.GetComponent<GuanXianIDScript>().GuanXianList.Contains(SecondGame)) //判断管线两头是否连接了相同的物体 |
|
{ |
|
if (SecondGame.name.Contains("xiaofang") || SecondGame.name.Contains("XHS") || SecondGame.name.Contains("mb")) |
|
{ |
|
MessageDispatcher.SendMessage("Operatinghints", (object)"已经连接此物体"); |
|
return; |
|
} |
|
} |
|
|
|
Vector3 tempPos = (placementPos + placementPos2) / 2;//计算两个点的中点坐标, |
|
LineRenderGameObject = Instantiate(Resources.Load<GameObject>("Prefabs/ToolPrefab/rline"), tempPos, Quaternion.identity) as GameObject; |
|
LineRenderGameObject.name = prlineObj.name; |
|
Destroy(LineRenderGameObject.GetComponent<RecordInstantiateEvent>()); |
|
LineGameObject = LineRenderGameObject; |
|
LineRenderGameObject.transform.parent = prlineObj.transform; |
|
LineRenderGameObject.GetComponent<BoxCollider>().isTrigger = true; |
|
LineRenderGameObject.transform.up = (-(placementPos2 - placementPos)).normalized;//改变线条的朝向 |
|
float distance = Vector3.Distance(placementPos, placementPos2);//计算两点的距离 |
|
prlineObj.GetComponent<lineParentMessage>().lineLength += distance; |
|
//prlineObj.GetComponent<lineParentMessage>().endPos = placementPos2; |
|
LineRenderGameObject.transform.localScale = new Vector3(5f, distance * 18, 5f);//延长线条,连接两点。 |
|
LineRenderGameObject.GetComponent<LineMessage>().SetPos(placementPos, placementPos2);//记录该节管线的首尾点坐标,用于后期管线位置矫正 |
|
placementPos = placementPos2; |
|
Pos2Controller = !Pos2Controller; |
|
prlineObj.GetComponent<GuanXianIDScript>().GetTheMessage(FirstGame, SecondGame); |
|
if (LineRenderGameObject.GetComponent<CengID>() && hit.transform.GetComponent<CengID>()) |
|
{ |
|
LineRenderGameObject.transform.GetComponent<CengID>().cengID = hit.transform.GetComponent<CengID>().cengID;//设置层ID,方便切层时隐藏管线 |
|
LineRenderGameObject.transform.GetComponent<CengID>().CengIDBuildType = hit.transform.GetComponent<CengID>().CengIDBuildType;//表示不同的楼 |
|
} |
|
|
|
if (FirstGame.name == SecondGame.name) |
|
{//防止消火栓被连续点中两次 |
|
SecondGame = null; |
|
return; |
|
} |
|
|
|
if (FirstGame != null && SecondGame != null) |
|
{ |
|
FangFa(FirstGame, SecondGame); |
|
StartCoroutine(DelaySet(FirstGame, SecondGame));//要在最后一帧设置。。防止跟RlineControl中的Update冲突 |
|
} |
|
} |
|
|
|
} |
|
} |
|
if (ToolName.Equals("SSShuiDai")) |
|
{ |
|
if (isRLineSelect) |
|
{ |
|
return; |
|
} |
|
if (ToolName == null) |
|
{ |
|
return; |
|
} |
|
//isRLineSelect = true; |
|
GameObject parentsd = GameObject.Find("prguanxian"); |
|
string prline = "中队名" + "-" + "rguanxian" + "-" + "ssrline" + "-" + RSDIndex; |
|
if (!shuidai_two) |
|
{ |
|
if (placementPos.x == 0 && placementPos.y == 0 && placementPos.z == 0) |
|
{ |
|
FirstGame = null; |
|
FirstGame = hit.transform.gameObject; |
|
|
|
if (hit.transform.gameObject.name.IndexOf("xiaofang") >= 0) |
|
{ |
|
FirstGame = hit.transform.gameObject; |
|
} |
|
if (hit.transform.gameObject.name.IndexOf("xiaofangyuan") >= 0 || hit.transform.gameObject.name.Contains("mb")) |
|
{ |
|
if (hit.transform.gameObject.GetComponent<RLineControl>().LineList_GameObject.Count > 0) |
|
{ |
|
MessageDispatcher.SendMessage("Operatinghints", (object)"已经连接管线"); |
|
|
|
return; |
|
} |
|
} |
|
SetPlacePos(hit.point, out placementPos, hit); |
|
prlineObj = Instantiate(Resources.Load<GameObject>("Prefabs/ToolPrefab/NullPrefab")) as GameObject; |
|
//prlineObj.AddComponent<lineParentMessage>();//增加管线父对象信息,用于显示长度 |
|
prlineObj.name = prline; |
|
prlineObj.transform.parent = parentsd.transform; |
|
SSRSDObj = prlineObj; |
|
RSDIndex++; |
|
} |
|
shuidai_two = true; |
|
} |
|
else |
|
{ |
|
SetPlacePos(hit.point, out placementPos2, hit); |
|
if (placementPos.x != placementPos2.x) |
|
{ |
|
SecondGame = null; |
|
if (hit.transform.gameObject.name.Contains("xiaofangyuan") || hit.transform.gameObject.name.Contains("mb")) |
|
{ |
|
if (hit.transform.gameObject.GetComponent<RLineControl>().LineList_GameObject.Count > 0) |
|
{ |
|
MessageDispatcher.SendMessage("Operatinghints", (object)"已经连接管线"); |
|
MessageDispatcher.SendMessage("SelectControl", (object)""); |
|
LineamentEvent.gameobj = null; |
|
return; |
|
} |
|
} |
|
SecondGame = hit.transform.gameObject; |
|
if (hit.transform.gameObject.name.IndexOf("xiaofang") >= 0 || hit.transform.gameObject.name.Contains("mb")) |
|
{ |
|
SecondGame = hit.transform.gameObject; |
|
} |
|
if (prlineObj.GetComponent<GuanXianIDScript>().GuanXianList.Contains(SecondGame)) //判断管线两头是否连接了相同的物体 |
|
{ |
|
if (SecondGame.name.Contains("xiaofang") || SecondGame.name.Contains("XHS") || SecondGame.name.Contains("mb")) |
|
{ |
|
MessageDispatcher.SendMessage("Operatinghints", (object)"已经连接此物体"); |
|
return; |
|
} |
|
} |
|
|
|
Vector3 tempPos = (placementPos + placementPos2) / 2;//计算两个点的中点坐标, |
|
LineRenderGameObject = Instantiate(Resources.Load<GameObject>("Prefabs/ToolPrefab/ssrline"), tempPos, Quaternion.identity) as GameObject; |
|
LineRenderGameObject.name = prlineObj.name; |
|
Destroy(LineRenderGameObject.GetComponent<RecordInstantiateEvent>()); |
|
LineGameObject = LineRenderGameObject; |
|
LineRenderGameObject.transform.parent = prlineObj.transform; |
|
LineRenderGameObject.GetComponent<BoxCollider>().isTrigger = true; |
|
LineRenderGameObject.transform.up = (-(placementPos2 - placementPos)).normalized;//改变线条的朝向 |
|
float distance = Vector3.Distance(placementPos, placementPos2);//计算两点的距离 |
|
prlineObj.GetComponent<lineParentMessage>().lineLength += distance; |
|
//prlineObj.GetComponent<lineParentMessage>().endPos = placementPos2; |
|
LineRenderGameObject.transform.localScale = new Vector3(5f, distance * 18, 5f);//延长线条,连接两点。 |
|
LineRenderGameObject.GetComponent<LineMessage>().SetPos(placementPos, placementPos2);//记录该节管线的首尾点坐标,用于后期管线位置矫正 |
|
placementPos = placementPos2; |
|
Pos2Controller = !Pos2Controller; |
|
prlineObj.GetComponent<GuanXianIDScript>().GetTheMessage(FirstGame, SecondGame); |
|
if (LineRenderGameObject.GetComponent<CengID>() && hit.transform.GetComponent<CengID>()) |
|
{ |
|
LineRenderGameObject.transform.GetComponent<CengID>().cengID = hit.transform.GetComponent<CengID>().cengID;//设置层ID,方便切层时隐藏管线 |
|
LineRenderGameObject.transform.GetComponent<CengID>().CengIDBuildType = hit.transform.GetComponent<CengID>().CengIDBuildType;//表示不同的楼 |
|
} |
|
|
|
if (FirstGame.name == SecondGame.name) |
|
{//防止消火栓被连续点中两次 |
|
SecondGame = null; |
|
return; |
|
} |
|
|
|
if (FirstGame != null && SecondGame != null) |
|
{ |
|
FangFa(FirstGame, SecondGame); |
|
StartCoroutine(DelaySet(FirstGame, SecondGame));//要在最后一帧设置。。防止跟RlineControl中的Update冲突 |
|
} |
|
} |
|
|
|
} |
|
} |
|
} |
|
if (Physics.Raycast(ray, out hit, Mathf.Infinity) && Input.GetMouseButtonDown(0) && !EventSystem.current.IsPointerOverGameObject()) |
|
{ |
|
if (ToolName == null) |
|
{ |
|
return; |
|
} |
|
if (ToolName.Equals("PaiYanGuan")) |
|
{ |
|
//isRLineSelect = true; |
|
GameObject parentPyg = GameObject.Find("ppaiyanguan"); |
|
string ppyg = "中队名" + "-" + "paiyanguan" + "-" + "PaiYanGuan" + "-" + PaiYanGuanIndex; |
|
if (!shuidai_two) |
|
{ |
|
if (placementPos.x == 0 && placementPos.y == 0 && placementPos.z == 0) |
|
{ |
|
// FirstGame = null; |
|
// FirstGame = hit.transform.gameObject; |
|
|
|
// if (hit.transform.gameObject.name.IndexOf("xiaofang") >= 0) |
|
// { |
|
// FirstGame = hit.transform.gameObject; |
|
// } |
|
// if (hit.transform.gameObject.name.IndexOf("xiaofangyuan") >= 0 || hit.transform.gameObject.name.Contains("mb")) |
|
// { |
|
// if (hit.transform.gameObject.GetComponent<RLineControl>().LineList_GameObject.Count > 0) |
|
// { |
|
// MessageDispatcher.SendMessage("Operatinghints", (object)"已经连接管线"); |
|
|
|
// return; |
|
// } |
|
// } |
|
// SetPlacePos(hit.point, out placementPos, hit); |
|
placementPos = new Vector3(hit.point.x, hit.point.y + 0.5f, hit.point.z); |
|
pPaiYanGuanObj = Instantiate(Resources.Load<GameObject>("Prefabs/ToolPrefab/NullPrefab")) as GameObject; |
|
//prlineObj.AddComponent<lineParentMessage>();//增加管线父对象信息,用于显示长度 |
|
pPaiYanGuanObj.name = ppyg; |
|
pPaiYanGuanObj.transform.parent = parentPyg.transform; |
|
PaiYanGuanObj = pPaiYanGuanObj; |
|
PaiYanGuanIndex++; |
|
} |
|
shuidai_two = true; |
|
} |
|
else |
|
{ |
|
//SetPlacePos(hit.point, out placementPos2, hit); |
|
placementPos2 = new Vector3(hit.point.x, hit.point.y + 0.5f, hit.point.z); |
|
if (placementPos.x != placementPos2.x) |
|
{ |
|
//SecondGame = null; |
|
//if (hit.transform.gameObject.name.Contains("xiaofangyuan") || hit.transform.gameObject.name.Contains("mb")) |
|
//{ |
|
// if (hit.transform.gameObject.GetComponent<RLineControl>().LineList_GameObject.Count > 0) |
|
// { |
|
// MessageDispatcher.SendMessage("Operatinghints", (object)"已经连接管线"); |
|
// MessageDispatcher.SendMessage("SelectControl", (object)""); |
|
// LineamentEvent.gameobj = null; |
|
// return; |
|
// } |
|
//} |
|
//SecondGame = hit.transform.gameObject; |
|
//if (hit.transform.gameObject.name.IndexOf("xiaofang") >= 0 || hit.transform.gameObject.name.Contains("mb")) |
|
//{ |
|
// SecondGame = hit.transform.gameObject; |
|
//} |
|
//if (prlineObj.GetComponent<GuanXianIDScript>().GuanXianList.Contains(SecondGame)) //判断管线两头是否连接了相同的物体 |
|
//{ |
|
// if (SecondGame.name.Contains("xiaofang") || SecondGame.name.Contains("XHS") || SecondGame.name.Contains("mb")) |
|
// { |
|
// MessageDispatcher.SendMessage("Operatinghints", (object)"已经连接此物体"); |
|
// return; |
|
// } |
|
//} |
|
|
|
Vector3 tempPos = (placementPos + placementPos2) / 2;//计算两个点的中点坐标, |
|
LineRenderGameObject = Instantiate(Resources.Load<GameObject>("Prefabs/ToolPrefab/PaiYanGuan"), tempPos, Quaternion.identity) as GameObject; |
|
LineRenderGameObject.name = pPaiYanGuanObj.name; |
|
Destroy(LineRenderGameObject.GetComponent<RecordInstantiateEvent>()); |
|
LineGameObject = LineRenderGameObject; |
|
LineRenderGameObject.transform.parent = pPaiYanGuanObj.transform; |
|
LineRenderGameObject.GetComponent<BoxCollider>().isTrigger = true; |
|
LineRenderGameObject.transform.up = (-(placementPos2 - placementPos)).normalized;//改变线条的朝向 |
|
float distance = Vector3.Distance(placementPos, placementPos2);//计算两点的距离 |
|
//prlineObj.GetComponent<lineParentMessage>().lineLength += distance; |
|
//prlineObj.GetComponent<lineParentMessage>().endPos = placementPos2; |
|
LineRenderGameObject.transform.localScale = new Vector3(0.5f, distance * 0.34f, 0.5f);//延长线条,连接两点。 |
|
//LineRenderGameObject.GetComponent<LineMessage>().SetPos(placementPos, placementPos2);//记录该节管线的首尾点坐标,用于后期管线位置矫正 |
|
placementPos = placementPos2; |
|
Pos2Controller = !Pos2Controller; |
|
//prlineObj.GetComponent<GuanXianIDScript>().GetTheMessage(FirstGame, SecondGame); |
|
if (LineRenderGameObject.GetComponent<CengID>() && hit.transform.GetComponent<CengID>()) |
|
{ |
|
LineRenderGameObject.transform.GetComponent<CengID>().cengID = hit.transform.GetComponent<CengID>().cengID;//设置层ID,方便切层时隐藏管线 |
|
LineRenderGameObject.transform.GetComponent<CengID>().CengIDBuildType = hit.transform.GetComponent<CengID>().CengIDBuildType;//表示不同的楼 |
|
} |
|
|
|
//if (FirstGame.name == SecondGame.name) |
|
//{//防止消火栓被连续点中两次 |
|
// SecondGame = null; |
|
// return; |
|
//} |
|
|
|
//if (FirstGame != null && SecondGame != null) |
|
//{ |
|
// FangFa(FirstGame, SecondGame); |
|
// StartCoroutine(DelaySet(FirstGame, SecondGame));//要在最后一帧设置。。防止跟RlineControl中的Update冲突 |
|
//} |
|
} |
|
} |
|
} |
|
} |
|
if (Physics.Raycast(ray, out hit, Mathf.Infinity, Tr_layerMask) && Input.GetMouseButtonDown(0) && !EventSystem.current.IsPointerOverGameObject()) |
|
{ |
|
if (InstantiationCar.Instance.isCarSelect) |
|
{ |
|
return; |
|
} |
|
if (ToolName == null) |
|
{ |
|
return; |
|
} |
|
if (ToolName.Equals("FenShuiQi")) |
|
{ |
|
WaterKnockoutTrap fsq = new WaterKnockoutTrap(Resources.Load<GameObject>("Prefabs/ToolPrefab/fsq"), GameObject.Find("pfenshuiqi"), ToolGrid, WaterKnockoutTrap.waterIndex, hit, 0.2f); |
|
fsq.InstatiateItem("中队名" + "-" + "fenshuiqi" + "-" + "fsq" + "-"); |
|
} |
|
else if (ToolName.Equals("ShuSanRenYuan")) |
|
{ |
|
ShuSanRenYuan ssry = new ShuSanRenYuan(Resources.Load<GameObject>("Prefabs/ToolPrefab/ssry"), GameObject.Find("pshusanrenyuan"), ToolGrid, ShuSanRenYuan.ssryIndex, hit, 1.0f); |
|
// topname = "观察哨-" + GuanChaShao.gcsIndex; |
|
string topname = ""; |
|
ssry.InstatiateItem("中队名" + "-" + "shusanrenyuan" + "-" + "ssry" + "-", topname); |
|
} |
|
else if (ToolName.Equals("SignalTower")) |
|
{ |
|
SignalTower st = new SignalTower(Resources.Load<GameObject>("Prefabs/ToolPrefab/st"), GameObject.Find("pst"), ToolGrid, SignalTower.SignalTowerIndex, hit, 0.6f); |
|
st.InstatiateItem("中队名" + "-" + "st" + "-" + "st" + "-"); |
|
} |
|
else if (ToolName.Equals("NGJJQ")) |
|
{ |
|
StagingArea jjq = new StagingArea(Resources.Load<GameObject>("Prefabs/ToolPrefab/ngjjq"), GameObject.Find("pjijiequ"), ToolGrid, StagingArea.stagingAreaIndex, hit, 0.2f); |
|
jjq.InstatiateItem("中队名" + "-" + "jijiequ" + "-" + "ngjjq" + "-"); |
|
} |
|
else if (ToolName.Equals("ChuQi")) |
|
{ |
|
//指挥部头顶用户名处理 |
|
ChuQi zwd = new ChuQi(Resources.Load<GameObject>("Prefabs/ToolPrefab/ChuQi"), GameObject.Find("pChuQi"), ToolGrid, ChuQi.zwdIndex, hit, 0.5f); |
|
zwd.InstatiateItem("中队名" + "-" + "ChuQi" + "-" + "ChuQi" + "-"); |
|
|
|
} |
|
else if (ToolName.Equals("AnQuanShao")) |
|
{ |
|
AQS aqs = new AQS(Resources.Load<GameObject>("Prefabs/ToolPrefab/aqs"), GameObject.Find("panquanshao"), ToolGrid, AQS.aqsIndex, hit, 0.2f); |
|
string topname = "安全哨-" + AQS.aqsIndex; |
|
aqs.InstatiateItem("中队名" + "-" + "anquanshao" + "-" + "aqs" + "-", topname); |
|
} //观察哨 |
|
else if (ToolName.Equals("Volunteer")) |
|
{ |
|
Volunteer v = new Volunteer(Resources.Load<GameObject>("Prefabs/ToolPrefab/volunteer"), GameObject.Find("pvolunteer"), ToolGrid, Volunteer.VolunteerIndex, hit, 0.2f); |
|
string topname = "义务消防员-" + Volunteer.VolunteerIndex; |
|
v.InstatiateItem("中队名" + "-" + "volunteer" + "-" + "volunteer" + "-", topname); |
|
} |
|
else if (ToolName.Equals("MobileBlisters"))//移动水炮 |
|
{ |
|
|
|
|
|
string TopName = "移动水炮" + "-" + MobileBlisters.MobileBlistersIndex; |
|
|
|
string Name = "中队名" + "-" + "mb" + "-" + "mb" + "-"; |
|
|
|
MobileBlisters mb = new MobileBlisters(Resources.Load<GameObject>("Prefabs/ToolPrefab/mb"), GameObject.Find("pmb"), ToolGrid, MobileBlisters.MobileBlistersIndex, hit, 0.3f); |
|
mb.InstatiateItem(Name, TopName); |
|
//mb.Obj.transform.localEulerAngles = new Vector3(-90, 0, 360); |
|
} |
|
|
|
else if (ToolName.Equals("JinGong")) |
|
{ |
|
////进攻箭头 |
|
GameObject parentjg = GameObject.Find("pjingong"); |
|
if (!lineFlag) |
|
{ |
|
print(ToolName); |
|
if (placementPos.x == 0 && placementPos.y == 0 && placementPos.z == 0) |
|
{ |
|
JG_CT = new AttackArrow(Resources.Load<GameObject>("Prefabs/ToolPrefab/NullPrefab"), parentjg, Resources.Load<GameObject>("Prefabs/ToolPrefab/jg"), "中队名" + "-" + "jingong" + "-" + "jg" + "-", ToolGrid, AttackArrow.arrowIndex++, hit, 0.15f); |
|
JGongOBj = JG_CT.Obj.transform.parent.gameObject; |
|
JGongOBj.GetComponent<lineParentMessage>().size = JG_CT.Obj.transform.localScale.x; |
|
} |
|
lineFlag = true; |
|
kongzhi = false; |
|
lol = false; |
|
} |
|
else |
|
{ |
|
//if (JGToggle.isOn == false) |
|
//{ |
|
// return; |
|
//} |
|
placementPos2 = new Vector3(hit.point.x, hit.point.y + 0.05f, hit.point.z); |
|
JG_CT.InstatiateItem(placementPos2, kongzhi, lol, hit); |
|
|
|
lol = true; |
|
kongzhi = true; ; |
|
} |
|
} |
|
else if (ToolName.Equals("DuJieXian")) |
|
{ |
|
////进攻堵截 |
|
GameObject parentjg = GameObject.Find("pdujiexian"); |
|
if (!lineFlag) |
|
{ |
|
print(ToolName); |
|
if (placementPos.x == 0 && placementPos.y == 0 && placementPos.z == 0) |
|
{ |
|
JG_CT = new DuJieArrow(Resources.Load<GameObject>("Prefabs/ToolPrefab/NullPrefab"), parentjg, Resources.Load<GameObject>("Prefabs/ToolPrefab/dj"), "中队名" + "-" + "dujiexian" + "-" + "dj" + "-", ToolGrid, DuJieArrow.arrowIndex++, hit, 0.15f); |
|
DJieOBJ = JG_CT.Obj.transform.parent.gameObject; |
|
DJieOBJ.GetComponent<lineParentMessage>().size = JG_CT.Obj.transform.localScale.x; |
|
} |
|
lineFlag = true; |
|
kongzhi = false; |
|
lol = false; |
|
} |
|
else |
|
{ |
|
//if (JGToggle.isOn == false) |
|
//{ |
|
// return; |
|
//} |
|
placementPos2 = new Vector3(hit.point.x, hit.point.y + 0.05f, hit.point.z); |
|
JG_CT.InstatiateItem_DuJie(placementPos2, kongzhi, lol, hit); |
|
|
|
lol = true; |
|
kongzhi = true; ; |
|
} |
|
} |
|
else if (ToolName.Equals("FenGeXian")) |
|
{ |
|
|
|
GameObject parentjg = GameObject.Find("pfengexian"); |
|
if (!lineFlag) |
|
{ |
|
print(ToolName); |
|
if (placementPos.x == 0 && placementPos.y == 0 && placementPos.z == 0) |
|
{ |
|
JG_CT = new SplitLine(Resources.Load<GameObject>("Prefabs/ToolPrefab/NullPrefab"), parentjg, Resources.Load<GameObject>("Prefabs/ToolPrefab/fg"), "中队名" + "-" + "fengexian" + "-" + "fg" + "-", ToolGrid, SplitLine.SplitLineIndex++, hit, 0.15f); |
|
FGeOBJ = JG_CT.Obj.transform.parent.gameObject; |
|
FGeOBJ.GetComponent<lineParentMessage>().size = JG_CT.Obj.transform.localScale.x; |
|
} |
|
lineFlag = true; |
|
kongzhi = false; |
|
lol = false; |
|
} |
|
else |
|
{ |
|
placementPos2 = new Vector3(hit.point.x, hit.point.y + 0.05f, hit.point.z); |
|
JG_CT.InstatiateItem_Fege(placementPos2, kongzhi, lol, hit); |
|
|
|
lol = true; |
|
kongzhi = true; ; |
|
} |
|
} |
|
else if (ToolName.Equals("CheTui")) |
|
{ |
|
//撤退箭头 |
|
GameObject parentct = GameObject.Find("pchetui"); |
|
|
|
if (!lineFiagchetui) |
|
{ |
|
print(ToolName); |
|
if (placementPos.x == 0 && placementPos.y == 0 && placementPos.z == 0) |
|
{ |
|
JG_CT = new RetreatArrow(Resources.Load<GameObject>("Prefabs/ToolPrefab/NullPrefab"), parentct, Resources.Load<GameObject>("Prefabs/ToolPrefab/ct"), "中队名" + "-" + "chetui" + "-" + "ct" + "-", ToolGrid, RetreatArrow.arrowIndex++, hit, 0.05f); |
|
CTuiOBj = JG_CT.Obj.transform.parent.gameObject; |
|
CTuiOBj.GetComponent<lineParentMessage>().size = JG_CT.Obj.transform.localScale.x; |
|
|
|
} |
|
lineFiagchetui = true; |
|
chetuikongzhi = false; |
|
chetuilol = false; |
|
} |
|
else |
|
{ |
|
|
|
//if (CTToggle.isOn == false) |
|
//{ |
|
// return; |
|
//} |
|
placementPos2 = new Vector3(hit.point.x, hit.point.y + 0.05f, hit.point.z); |
|
JG_CT.InstatiateItem(placementPos2, chetuikongzhi, chetuilol, hit); |
|
|
|
chetuilol = true; |
|
chetuikongzhi = true; |
|
} |
|
} |
|
else if (ToolName.Equals("ShiWuMi")) |
|
{ |
|
//拉梯9m头顶用户名处理 |
|
Ladder lati9m = new Ladder(Resources.Load<GameObject>("Prefabs/ToolPrefab/lati15m"), GameObject.Find("plati"), ToolGrid, Ladder.ladderIndex, hit, 0); |
|
string topname = "拉梯15米"; |
|
string zhbname = topname + "-" + "lati" + "-" + "lati15m" + "-"; |
|
lati9m.InstatiateItem(zhbname, topname); |
|
} |
|
else if (ToolName.Equals("LiuMi")) |
|
{ |
|
//拉梯6m头顶用户名处理 |
|
Ladder lati6m = new Ladder(Resources.Load<GameObject>("Prefabs/ToolPrefab/lati6m"), GameObject.Find("plati"), ToolGrid, Ladder.ladderIndex, hit, 0); |
|
string topname = "拉梯6米"; |
|
string zhbname = topname + "-" + "lati" + "-" + "lati6m" + "-"; |
|
lati6m.InstatiateItem(zhbname, topname); |
|
} |
|
else if (ToolName.Equals("JiJieQu")) |
|
{ |
|
StagingArea jjq = new StagingArea(Resources.Load<GameObject>("Prefabs/ToolPrefab/jjq"), GameObject.Find("pjijiequ"), ToolGrid, StagingArea.stagingAreaIndex, hit, 0.2f); |
|
jjq.InstatiateItem("中队名" + "-" + "jijiequ" + "-" + "jjq" + "-"); |
|
} |
|
else if (ToolName.Equals("ShouTaiBeng")) |
|
{ |
|
ShouTaiBeng stb = new ShouTaiBeng(Resources.Load<GameObject>("Prefabs/ToolPrefab/stb"), GameObject.Find("pshoutaibeng"), ToolGrid, ShouTaiBeng.ShouTaiBengIndex, hit, 0.2f); |
|
string topname = "手抬泵-" + ShouTaiBeng.ShouTaiBengIndex; |
|
|
|
stb.InstatiateItem("中队名" + "-" + "shoutaibeng" + "-" + "stb" + "-", topname); |
|
} |
|
else if (ToolName.Equals("QuyuSet")) |
|
{ |
|
|
|
MessageDispatcher.SendMessage("ControlPolygonFalse", (object)""); |
|
if (UIController.instance.PolygonPlane != null) |
|
{ |
|
UIController.instance.PolygonPlane.SetActive(true); |
|
UIController.instance.PolygonPlane.transform.position = new Vector3(hit.point.x, hit.point.y + 0.1f, hit.point.z); |
|
} |
|
|
|
|
|
GameObject game = Instantiate(Resources.Load<GameObject>("Prefabs/ToolPrefab/Polygon")) as GameObject; |
|
game.transform.parent = GameObject.Find("AllParent/pPolygon").transform; |
|
string Now = System.DateTime.Now.Year.ToString() + System.DateTime.Now.Month.ToString() + System.DateTime.Now.Day.ToString() + System.DateTime.Now.Hour.ToString() + System.DateTime.Now.Minute.ToString() + System.DateTime.Now.Second.ToString(); |
|
game.name = "Polygon" + Now; |
|
|
|
MessageDispatcher.SendMessage(3f, "NodeTreeHints", (object)"在此区域设定"); |
|
|
|
if (RecordManager.Instance.IsRecording) |
|
{ |
|
TrackRecordHelpClass.RECORDPolygon(game); |
|
} |
|
MessageDispatcher.SendMessage("ResettingButton"); |
|
} |
|
else |
|
if (ToolName.Equals("NameText")) |
|
{ |
|
//指挥部头顶用户名处理 |
|
BaseNameText zhb = new BaseNameText(Resources.Load<GameObject>("Prefabs/ToolPrefab/NameText"), GameObject.Find("pnametext"), ToolGrid, BaseNameText.baseNameText, hit, 0); |
|
string topname = "文字设置"; |
|
string zhbname = topname + "-" + "nametext" + "-" + "NameText" + "-"; |
|
zhb.InstatiateItem(zhbname, topname); |
|
} |
|
|
|
} |
|
//地面层 |
|
if (Physics.Raycast(ray, out hit, Mathf.Infinity, ground_layerMask) && Input.GetMouseButtonDown(0) && |
|
!EventSystem.current.IsPointerOverGameObject()) |
|
{ |
|
if (hit.collider.gameObject.layer == 26) |
|
return; |
|
if (InstantiationCar.Instance.isCarSelect) |
|
{ |
|
return; |
|
} |
|
if (ToolName == null) |
|
{ |
|
return; |
|
} |
|
if (ToolName.Equals("ZhiHuiBu")) |
|
{ |
|
//指挥部头顶用户名处理 |
|
CommandPost zhb = new CommandPost(Resources.Load<GameObject>("Prefabs/ToolPrefab/zhb"), GameObject.Find("pzhihuibu"), ToolGrid, CommandPost.commandIndex, hit, 0.13f); |
|
string topname = "指挥部"; |
|
string zhbname = topname + "-" + "zhihuibu" + "-" + "zhb" + "-"; |
|
zhb.InstatiateItem(zhbname, topname); |
|
} |
|
|
|
|
|
|
|
else if (ToolName.Equals("JingJie")) |
|
{ |
|
if ((placementPos.x == 0 && placementPos.y == 0 && placementPos.z == 0) || !Pos2Controller) |
|
{ |
|
placementPos = new Vector3(hit.point.x, hit.point.y, hit.point.z); |
|
Pos2Controller = !Pos2Controller; |
|
Debug.Log(placementPos); |
|
return; |
|
} |
|
//警戒线 |
|
placementPos2 = new Vector3(hit.point.x, hit.point.y, hit.point.z); |
|
Debug.Log(placementPos2); |
|
//判断第二次点击是否和第一次重合,同时避免因为每帧调用的误处理。 |
|
if ((placementPos.x != placementPos2.x) && (Pos2_late.x != placementPos2.x) && (Pos1_late.x != placementPos.x) && Pos2Controller) |
|
{ |
|
//警戒线 |
|
PoliceLine jjx = new PoliceLine(Resources.Load<GameObject>("Prefabs/ToolPrefab/jjx"), GameObject.Find("pjingjiexian"), ToolGrid, PoliceLine.lineIndex, hit, placementPos, placementPos2); |
|
jjx.InstatiateItem("中队名" + "-" + "jingjiexian" + "-" + "jjx" + "-", true); |
|
|
|
Pos1_late = placementPos; |
|
Pos2_late = placementPos2; |
|
Pos2Controller = !Pos2Controller; |
|
} |
|
} |
|
|
|
if (ToolName.Equals("GuanChaShao")) |
|
{ |
|
GuanChaShao gcs = new GuanChaShao(Resources.Load<GameObject>("Prefabs/ToolPrefab/gcs"), GameObject.Find("pguanchashao"), ToolGrid, GuanChaShao.gcsIndex, hit, 0.2f); |
|
string topname = "观察哨-" + GuanChaShao.gcsIndex; |
|
gcs.InstatiateItem("中队名" + "-" + "guanchashao" + "-" + "gcs" + "-", topname); |
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
IEnumerator DelaySet(GameObject FirstGame, GameObject SecondGame) |
|
{//哪边是消防车,哪边连着管线后就不能移动 |
|
yield return new WaitForEndOfFrame(); |
|
if (FirstGame.name.Contains("xiaofangche")) |
|
{ |
|
FirstGame.GetComponent<LineamentEvent>().isConnectCar = true; |
|
} |
|
if (SecondGame.name.Contains("xiaofangche")) |
|
{ |
|
SecondGame.GetComponent<LineamentEvent>().isConnectCar = true; |
|
} |
|
} |
|
|
|
/// <summary> |
|
/// 此方法限制消防车、消火栓、消防员可以设置几条消防水带 |
|
/// </summary> |
|
/// <param name="接水带时第一次点的物体"></param> |
|
/// <param name="接水带时第二次点的物体"></param> |
|
public void FangFa(GameObject FirstGame, GameObject SecondGame) |
|
{ |
|
#region 消防员身上只能连一根管线 |
|
if (FirstGame.name.IndexOf("xiaofangyuan") > 0 || FirstGame.name.IndexOf("mb") > 0) |
|
{ |
|
if (FirstGame.GetComponent<RLineControl>().LineList_GameObject.Count > 1) |
|
{ |
|
return; |
|
} |
|
} |
|
if (SecondGame.name.IndexOf("xiaofangyuan") > 0 || SecondGame.name.IndexOf("mb") > 0) |
|
{//消防员只能接一条水带 |
|
if (SecondGame.GetComponent<RLineControl>().LineList_GameObject.Count > 1) |
|
{ |
|
return; |
|
} |
|
} |
|
#endregion |
|
|
|
|
|
|
|
if ((FirstGame.name.Contains("xiaofang") || FirstGame.name.Contains("XHS") || FirstGame.name.Contains("mb") || FirstGame.name.Contains("xhs")) && |
|
(SecondGame.name.Contains("xiaofang") || SecondGame.name.Contains("XHS") || SecondGame.name.Contains("mb") || SecondGame.name.Contains("xhs"))) |
|
{ |
|
//MessageDispatcher.SendMessage("Operatinghints", (object)"连接管线成功"); |
|
} |
|
|
|
|
|
|
|
//if (SecondGame.GetComponent<RLineControl>() && SecondGame.gameObject.layer != LayerMask.GetMask("dimain")) |
|
//{ |
|
// SecondGame.GetComponent<RLineControl>().GetLianJieOb(prlineObj); |
|
// MessageDispatcher.SendMessage("Operatinghints", (object)"连接管线成功"); |
|
// return; |
|
//} |
|
//if (FirstGame.GetComponent<RLineControl>()) |
|
//{ |
|
// FirstGame.GetComponent<RLineControl>().GetLianJieOb(prlineObj); |
|
// MessageDispatcher.SendMessage("Operatinghints", (object)"连接管线成功"); |
|
//} |
|
if ((FirstGame.name.Contains("XHS") || FirstGame.name.Contains("xhs") || FirstGame.name.Contains("pmc") || FirstGame.name.Contains("sgc"))) |
|
{ |
|
if (SecondGame.name.Contains("xiaofang") || SecondGame.name.Contains("mb")) |
|
{ |
|
if (SecondGame.GetComponent<RLineControl>().LineList_GameObject.Contains(prlineObj)) |
|
{ |
|
return; |
|
} |
|
SecondGame.GetComponent<RLineControl>().GetLianJieOb(prlineObj); |
|
|
|
MessageDispatcher.SendMessage("Operatinghints", (object)"连接管线成功"); |
|
return; |
|
} |
|
} |
|
if ((SecondGame.name.Contains("XHS") || FirstGame.name.Contains("xhs") || SecondGame.name.Contains("pmc") || SecondGame.name.Contains("sgc"))) |
|
{ |
|
if (FirstGame.name.Contains("xiaofang") || FirstGame.name.Contains("mb")) |
|
{ |
|
if (FirstGame.GetComponent<RLineControl>().LineList_GameObject.Contains(prlineObj)) |
|
{ |
|
return; |
|
} |
|
FirstGame.GetComponent<RLineControl>().GetLianJieOb(prlineObj); |
|
MessageDispatcher.SendMessage("Operatinghints", (object)"连接管线成功"); |
|
return; |
|
} |
|
} |
|
if ((FirstGame.name.Contains("xiaofang") || FirstGame.name.Contains("XHS") || FirstGame.name.Contains("xhs") || FirstGame.name.Contains("pmc") || FirstGame.name.Contains("sgc"))) |
|
{ |
|
if (SecondGame.gameObject.layer==25|| SecondGame.gameObject.layer == 26) |
|
{ |
|
|
|
if (FirstGame.GetComponent<RLineControl>()) |
|
{ |
|
if (FirstGame.GetComponent<RLineControl>().LineList_GameObject.Contains(prlineObj)) |
|
{ |
|
return; |
|
} |
|
|
|
FirstGame.GetComponent<RLineControl>().GetLianJieOb_Layer(prlineObj); |
|
return; |
|
} |
|
} |
|
} |
|
|
|
if ((SecondGame.name.Contains("xiaofang") || SecondGame.name.Contains("XHS") || SecondGame.name.Contains("xhs") || SecondGame.name.Contains("pmc") || SecondGame.name.Contains("sgc"))) |
|
{ |
|
if (FirstGame.gameObject.layer == 25 || FirstGame.gameObject.layer == 26) |
|
{ |
|
if (SecondGame.GetComponent<RLineControl>()) |
|
{ |
|
if (SecondGame.GetComponent<RLineControl>().LineList_GameObject.Contains(prlineObj)) |
|
{ |
|
return; |
|
} |
|
SecondGame.GetComponent<RLineControl>().GetLianJieOb_Layer(prlineObj); |
|
return; |
|
} |
|
} |
|
} |
|
|
|
} |
|
}
|
|
|