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.
773 lines
30 KiB
773 lines
30 KiB
3 years ago
|
using UnityEngine;
|
||
|
using System.Collections;
|
||
|
using AX.TrackRecord;
|
||
|
using System.Collections.Generic;
|
||
|
using AX.MessageSystem;
|
||
|
using UnityEngine.UI;
|
||
|
using NavMeshExtension;
|
||
|
using UnityEngine.AI;
|
||
|
|
||
|
public class BaseClass : MonoBehaviour {
|
||
|
|
||
|
protected GameObject prefab;
|
||
|
protected RaycastHit hit;
|
||
|
protected GameObject parent;
|
||
|
protected GameObject TheUIFather;
|
||
|
protected int index = 0;
|
||
|
public GameObject Obj;
|
||
|
protected Vector3 placementPos;
|
||
|
protected Vector3 pos1;
|
||
|
protected Vector3 pos2;
|
||
|
|
||
|
public BaseClass()
|
||
|
{
|
||
|
|
||
|
}
|
||
|
/// <summary>
|
||
|
/// 物体统一实例化
|
||
|
/// </summary>
|
||
|
/// <param name="prefab"></param>
|
||
|
/// <param name="parent"></param>
|
||
|
/// <param name="objAttri"></param>
|
||
|
/// <param name="hasTopInfo"></param>
|
||
|
public virtual void InstantiateItem(GameObject prefab, GameObject parent, ObjAttribute objAttri, bool hasTopInfo, bool multi)
|
||
|
{
|
||
|
if (objAttri.ObjName.Contains("rline") || objAttri.ObjName.Contains("jg") || objAttri.ObjName.Contains("ct")|| objAttri.ObjName.Contains("dj")|| objAttri.ObjName.Contains("PaiYanGuan")) //PaiYanGuan
|
||
|
{
|
||
|
Obj = Instantiate(Resources.Load<GameObject>("Prefabs/ToolPrefab/NullPrefab"), placementPos, Quaternion.identity) as GameObject;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
Obj = Instantiate(prefab, placementPos, Quaternion.identity) as GameObject;
|
||
|
}
|
||
|
|
||
|
if (objAttri.ObjName.Contains("jijiequ"))
|
||
|
{
|
||
|
Obj.GetComponent<LoadJijie>().Jijie = objAttri.jijiequ;
|
||
|
}
|
||
|
if (objAttri.ObjName.Contains("chetui") || objAttri.ObjName.Contains("jingong") || objAttri.ObjName.Contains("fengexian")|| objAttri.ObjName.Contains("dujiexian"))
|
||
|
{
|
||
|
Obj.GetComponent<lineParentMessage>().size = objAttri.lineSize;
|
||
|
}
|
||
|
if (objAttri.ObjName.Contains("nametext"))
|
||
|
{
|
||
|
Obj.GetComponent<TextMesh>().text = objAttri.jijiequ.Name;
|
||
|
Obj.GetComponent<TextMesh>().color = objAttri.jijiequ.color;
|
||
|
Obj.transform.localScale = objAttri.trans.scale;
|
||
|
}
|
||
|
|
||
|
Obj.transform.parent = parent.transform;
|
||
|
if (objAttri.ObjName.Contains("GroundFire_LG"))
|
||
|
{
|
||
|
var spreadedFire = Obj.GetComponent<SpreadedFire>();
|
||
|
spreadedFire.fireSourceName = objAttri.ObjName.Split('+')[1];// + "(Node)"; 父火名字
|
||
|
}
|
||
|
if (objAttri.ObjName.Contains("GroundFire_OilTank"))
|
||
|
{
|
||
|
var oilTankName = objAttri.ObjName.Split('-')[3];//取得罐体名
|
||
|
Transform GrandParent = Obj.transform.parent.parent;
|
||
|
GameObject oilTankObj = Obj;
|
||
|
if (oilTankName.Contains("FuDingGuan"))
|
||
|
{
|
||
|
GrandParent = GameObject.Find("5/WaiFuDingGuan_GuanQu").transform;
|
||
|
}
|
||
|
else if (oilTankName.Contains("GongDingGuan"))
|
||
|
{
|
||
|
|
||
|
//GrandParent = GameObject.Find("5/GongDingGuan_GuanQu").transform;
|
||
|
//伏牛溪
|
||
|
GrandParent = GameObject.Find("GongDingGuan_GuanQu").transform;
|
||
|
}
|
||
|
else if (oilTankName.Contains("QiuGuan"))
|
||
|
{
|
||
|
GrandParent = GameObject.Find("5/QiuXingGuan_GuanQu").transform;
|
||
|
}
|
||
|
foreach(Transform child in GrandParent)
|
||
|
{
|
||
|
if(child.GetChild(0).name== oilTankName)
|
||
|
{
|
||
|
oilTankObj = child.GetChild(0).gameObject;
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
Obj.GetComponent<ExplodeFire>().youGuan = oilTankObj;
|
||
|
}
|
||
|
Obj.GetComponent<CengID>().cengID = objAttri.CengID;
|
||
|
Obj.GetComponent<CengID>().CengIDBuildType = objAttri.buildTpye;
|
||
|
Obj.GetComponent<CengID>().hitTag = objAttri.PictureFile;
|
||
|
TrackRecordHelpClass.Set_Pos_Rot_Sca_Load(Obj.transform, objAttri.trans);
|
||
|
Obj.name = objAttri.ObjName;
|
||
|
//加载地下建筑场景时,获取每层火身上的ID数据,显示有火源层烟雾
|
||
|
//if (MySceneManager.GetActiveScene().name.Equals("2") && Obj.name.Contains("fire"))
|
||
|
//{
|
||
|
// GameObject smokeParent = GameObject.Find("TianJinZhan").transform.FindChild("Smoke").gameObject;
|
||
|
// smokeParent.transform.FindChild("nei" + Obj.GetComponent<CengID>().cengID + "_smoke").gameObject.SetActive(true);
|
||
|
//}
|
||
|
//处理寻路模式下的实例化消防员:先赋值位置等,再添加寻路等控制脚本,否则报错
|
||
|
if (objAttri.ObjName.Contains("xfy_path") && !objAttri.ObjName.Contains("Zhaomingxian"))
|
||
|
{
|
||
|
Obj.transform.localPosition = new Vector3(Obj.transform.localPosition.x,
|
||
|
Obj.transform.localPosition.y + 0.05f, Obj.transform.localPosition.z);
|
||
|
TrackRecordHelpClass.AddNavAgentScripts(Obj);
|
||
|
InputManager.Instance_.characters.Add(Obj);
|
||
|
|
||
|
}
|
||
|
|
||
|
if (Obj.GetComponent<BaseGCS_SSRYCtrl>() )
|
||
|
{
|
||
|
BaseGCS_SSRYCtrl ctrl = null;
|
||
|
if (Obj.GetComponent<GuanChaShaoCtrl>())
|
||
|
{
|
||
|
ctrl = Obj.GetComponent<GuanChaShaoCtrl>();
|
||
|
}
|
||
|
else if (Obj.GetComponent<ShuSanRYCtrl>())
|
||
|
{
|
||
|
ctrl = Obj.GetComponent<ShuSanRYCtrl>();
|
||
|
}
|
||
|
//赋值速度和位置数组
|
||
|
if (ctrl != null)
|
||
|
{
|
||
|
ctrl.value = objAttri.AreaMask;
|
||
|
ctrl.PosList.Clear();
|
||
|
objAttri.AllPath.ForEach(p => ctrl.PosList.Add(p));
|
||
|
ctrl.flag = true;
|
||
|
}
|
||
|
|
||
|
|
||
|
}
|
||
|
|
||
|
if (objAttri.Lati_List.Count > 0)
|
||
|
{
|
||
|
Transform t_lati_parent = Obj.transform;
|
||
|
Transform t_lati_part1 = Obj.transform.Find("LadderDown");
|
||
|
Transform t_lati_part2 = t_lati_part1.Find("LadderUp");
|
||
|
TrackRecordHelpClass.Set_Pos_Rot_Sca_Load(t_lati_part1, objAttri.Lati_List[0]);
|
||
|
LaTi_Rise_Attribute CarAttribute = objAttri.LaTi_Rise_Attribute[0];
|
||
|
Obj.GetComponent<BaseLadder>().CarAttribute = CarAttribute;
|
||
|
TrackRecordHelpClass.Set_Pos_Rot_Sca_Load(t_lati_part2, objAttri.Lati_List[1]);
|
||
|
if (Obj.name.Contains("15m"))
|
||
|
{
|
||
|
Transform t_lati_part3 = t_lati_part2.Find("LadderUp2");
|
||
|
TrackRecordHelpClass.Set_Pos_Rot_Sca_Load(t_lati_part3, objAttri.Lati_List[2]);
|
||
|
}
|
||
|
}
|
||
|
if (objAttri.ObjName.Contains("xiaofangche"))
|
||
|
{
|
||
|
if (Obj.tag != "Carother")
|
||
|
{
|
||
|
Obj.GetComponent<CarMessage>().CarAttri = objAttri.carAttriList[0];
|
||
|
}
|
||
|
|
||
|
if (ExamInfoHelpClass.applicationMode == ExamInfoHelpClass.ApplicationMode.PATHFINDING)
|
||
|
{
|
||
|
TrackRecordHelpClass.AddNavAgentScripts(Obj);
|
||
|
}
|
||
|
}
|
||
|
if (hasTopInfo)
|
||
|
{
|
||
|
Obj.transform.Find("info").Find("Name").GetComponent<TextMesh>().text = objAttri.TopName;
|
||
|
if(Obj.transform.Find("info").Find("Function"))
|
||
|
Obj.transform.Find("info").Find("Function").GetComponent<TextMesh>().text = objAttri.TaskName;
|
||
|
}
|
||
|
if (multi)
|
||
|
{
|
||
|
foreach (ChildItem_Attribute child in objAttri.ChildList)
|
||
|
{
|
||
|
GameObject childobj = Instantiate(prefab, Vector3.zero, Quaternion.identity) as GameObject;
|
||
|
childobj.name = child.ObjName;
|
||
|
childobj.GetComponent<CengID>().cengID = child.CengID;
|
||
|
childobj.GetComponent<CengID>().CengIDBuildType = child.buildType;
|
||
|
childobj.transform.parent = Obj.transform;
|
||
|
if (childobj.GetComponent<LineMessage>())
|
||
|
{
|
||
|
childobj.GetComponent<LineMessage>().SetPos(child.beginP, child.endP);
|
||
|
childobj.transform.parent.GetComponent<lineParentMessage>().lineLength+= Vector3.Distance(child.beginP, child.endP);//计算两点
|
||
|
}
|
||
|
TrackRecordHelpClass.Set_Pos_Rot_Sca_Load(childobj.transform, child.trans);
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
}
|
||
|
public BaseClass(GameObject obj, GameObject parentObj, GameObject TheUI, int id, RaycastHit hit_, float delta_y)
|
||
|
{
|
||
|
prefab = obj;
|
||
|
parent = parentObj;
|
||
|
TheUIFather = TheUI;
|
||
|
index = id;
|
||
|
hit = hit_;
|
||
|
placementPos = new Vector3(hit.point.x, hit.point.y + delta_y, hit.point.z);
|
||
|
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// 移动指挥终端模块需要
|
||
|
/// </summary>
|
||
|
/// <param name="obj"></param>
|
||
|
/// <param name="parentObj"></param>
|
||
|
/// <param name="TheUI"></param>
|
||
|
/// <param name="id"></param>
|
||
|
/// <param name="pos"></param>
|
||
|
/// <param name="origin"></param>
|
||
|
/// <param name="delta_y"></param>
|
||
|
public BaseClass(GameObject obj, GameObject parentObj, GameObject TheUI, int id, MobileCFFSInfo.Vector2 pos, MobileCFFSInfo.Vector2 origin, float delta_y)
|
||
|
{
|
||
|
prefab = obj;
|
||
|
parent = parentObj;
|
||
|
TheUIFather = TheUI;
|
||
|
index = id;
|
||
|
|
||
|
Vector3 positionX_Z = Vector3.zero;
|
||
|
|
||
|
if (TO_3D_PLAN_SYNC.BuildingId == 2)
|
||
|
{//天津站场景
|
||
|
positionX_Z = PositionConversion.PosConvertOfScene2(pos, origin);
|
||
|
}
|
||
|
if (TO_3D_PLAN_SYNC.BuildingId == 1)
|
||
|
{//恒隆广场场景
|
||
|
positionX_Z = PositionConversion.PosConvertOfScene9(pos, origin);
|
||
|
}
|
||
|
if (TO_3D_PLAN_SYNC.BuildingId == 0)
|
||
|
{//津塔场景
|
||
|
positionX_Z = PositionConversion.PosConvertOfScene11(pos, origin);
|
||
|
}
|
||
|
|
||
|
|
||
|
placementPos = positionX_Z;
|
||
|
}
|
||
|
|
||
|
public BaseClass(GameObject obj, GameObject parentObj, GameObject TheUI, int id, RaycastHit hit_, Vector3 pos1_, Vector3 pos2_)
|
||
|
{
|
||
|
prefab = obj;
|
||
|
parent = parentObj;
|
||
|
TheUIFather = TheUI;
|
||
|
index = id;
|
||
|
hit = hit_;
|
||
|
pos1 = pos1_;
|
||
|
pos2 = pos2_;
|
||
|
placementPos = (pos1_ + pos2_) / 2;
|
||
|
}
|
||
|
public BaseClass(GameObject nullObj, GameObject parentObj, GameObject JG_CT_Prefab, string ObjName, GameObject TheUI, int id, RaycastHit hit_, float delta_y)
|
||
|
{
|
||
|
prefab = nullObj;
|
||
|
parent = parentObj;
|
||
|
TheUIFather = TheUI;
|
||
|
index = id;
|
||
|
hit = hit_;
|
||
|
placementPos = new Vector3(hit.point.x, hit.point.y + delta_y, hit.point.z);
|
||
|
ChildObj(ObjName);//Obj是生成的空物体
|
||
|
prefab = JG_CT_Prefab;
|
||
|
parent = Obj;
|
||
|
ChildObj(ObjName);//Obj是生成的第一个箭头物体
|
||
|
|
||
|
}
|
||
|
public BaseClass(GameObject nullObj, GameObject parentObj, GameObject JG_CT_Prefab, string ObjName, GameObject TheUI, int id, RaycastHit hit_, Vector3 pos1_, Vector3 pos2_)
|
||
|
{
|
||
|
prefab = nullObj;
|
||
|
parent = parentObj;
|
||
|
TheUIFather = TheUI;
|
||
|
index = id;
|
||
|
hit = hit_;
|
||
|
placementPos = new Vector3(hit.point.x, hit.point.y , hit.point.z);
|
||
|
|
||
|
ChildObj(ObjName);//Obj是生成的空物体
|
||
|
prefab = JG_CT_Prefab;
|
||
|
parent = Obj;
|
||
|
ChildObj(ObjName);//Obj是生成的第一个箭头物体
|
||
|
pos1 = pos1_;
|
||
|
pos2 = pos2_;
|
||
|
placementPos = (pos1_ + pos2_) / 2;
|
||
|
}
|
||
|
public void ChildObj(string objName)
|
||
|
{
|
||
|
Obj = Instantiate(prefab, placementPos, Quaternion.identity) as GameObject;
|
||
|
|
||
|
|
||
|
Obj.transform.parent = parent.transform;
|
||
|
if (Obj.transform.parent.name.Contains("fengexian")&& !Obj.transform.parent.name.Contains("pfengexian"))
|
||
|
{
|
||
|
Obj.transform.localScale = new Vector3(15, 15, 15);
|
||
|
}
|
||
|
//if (Obj.transform.parent.name.Contains("dujiexian") && !Obj.transform.parent.name.Contains("pdujiexian"))
|
||
|
//{
|
||
|
// Obj.transform.localEulerAngles = new Vector3(90, Obj.transform.localEulerAngles.y, Obj.transform.localEulerAngles.z);
|
||
|
//}
|
||
|
|
||
|
SetCengID(Obj);
|
||
|
Obj.name = objName + index;
|
||
|
}
|
||
|
public void InstObj(string objName)
|
||
|
{
|
||
|
Obj = Instantiate(prefab, placementPos, Quaternion.identity) as GameObject;
|
||
|
Obj.transform.parent = parent.transform;
|
||
|
SetCengID(Obj);
|
||
|
Obj.name = objName + index;
|
||
|
if (objName.Contains("fire"))
|
||
|
{
|
||
|
Obj.GetComponent<CengID>().hitTag = hit.transform.tag;
|
||
|
}
|
||
|
//RecordManager.Instance.objCount++;
|
||
|
if (Obj.GetComponent<SetFireDire>())
|
||
|
{
|
||
|
// Debug.Log(Obj.name+" "+ hit.normal);
|
||
|
Obj.GetComponent<SetFireDire>().SetDirec(hit);
|
||
|
// Debug.DrawLine(hit.collider.transform.position, hit.normal * 1000, Color.blue);
|
||
|
}
|
||
|
if (Obj.GetComponent<LoadJijie>())
|
||
|
{
|
||
|
JiJieQu ji = new JiJieQu();
|
||
|
Obj.GetComponent<LoadJijie>().Jijie = ji;
|
||
|
}
|
||
|
|
||
|
if (RecordManager.Instance.IsRecording)
|
||
|
{
|
||
|
MessageDispatcher.SendMessage("RecordInstantiateEvent", (object)Obj.name);
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
}
|
||
|
public void InstObj(string objName,float i)//油罐
|
||
|
{
|
||
|
Obj = Instantiate(prefab, placementPos, Quaternion.identity) as GameObject;
|
||
|
Obj.transform.parent = parent.transform;
|
||
|
SetCengID(Obj);
|
||
|
Obj.name = objName + index;
|
||
|
//RecordManager.Instance.objCount++;
|
||
|
if (RecordManager.Instance.IsRecording)
|
||
|
{
|
||
|
MessageDispatcher.SendMessage("RecordInstantiateEvent", (object)Obj.name);
|
||
|
}
|
||
|
}
|
||
|
public void InstObj(string objName, string topName)
|
||
|
{
|
||
|
int XFYcout = 0;
|
||
|
string TeamName = "";
|
||
|
if (objName.Contains("xiaofangche") && ExamInfoHelpClass.applicationMode == ExamInfoHelpClass.ApplicationMode.PATHFINDING &&
|
||
|
ExamInfoHelpClass.loadSceneMode == ExamInfoHelpClass.LoadSceneMode.ExamineMode)
|
||
|
{
|
||
|
for (int i = 0; i < SetPowerScript.Instance.TeamList.Count; i++)
|
||
|
{
|
||
|
TeamAttri team = SetPowerScript.Instance.TeamList[i] as TeamAttri;
|
||
|
if (team.TeamName.Equals(InstantiationCar.Instance.dropDown.captionText.text))
|
||
|
{
|
||
|
for (int j = 0; j < team.PowerAttriList.Count; j++)
|
||
|
{
|
||
|
if (topName.Contains(team.PowerAttriList[j].CarName))
|
||
|
{
|
||
|
GameObject Game = InstantiationCar.Instance.GetSelectGame();
|
||
|
if (int.Parse(Game.transform.Find("Text").GetComponent<Text>().text) == 0)
|
||
|
{
|
||
|
Game.GetComponent<Button>().enabled = false;
|
||
|
MessageDispatcher.SendMessage("ResettingButton");
|
||
|
return;
|
||
|
}
|
||
|
XFYcout = team.PowerAttriList[j].XFYCount;
|
||
|
TeamName = team.TeamName;
|
||
|
int Num = int.Parse(Game.transform.Find("Text").GetComponent<Text>().text);
|
||
|
Num--;
|
||
|
team.PowerAttriList[j].CarCount = Num;
|
||
|
Game.transform.Find("Text").GetComponent<Text>().text = Num.ToString();
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|
||
|
Obj = Instantiate(prefab, placementPos, Quaternion.identity) as GameObject;
|
||
|
Obj.transform.parent = parent.transform;
|
||
|
SetCengID(Obj);
|
||
|
Obj.name = objName + index;
|
||
|
//消防员能框选,消防车不能框选
|
||
|
if (/*objName.Contains("xiaofangche") || */objName.Contains("xiaofangyuan"))
|
||
|
{
|
||
|
InputManager.Instance_.characters.Add(Obj);
|
||
|
}
|
||
|
|
||
|
if (Obj.name.Contains("mb"))//针对移动水泡,设置下角度
|
||
|
{
|
||
|
Obj.transform.localEulerAngles = new Vector3(0, 0, 0);
|
||
|
}
|
||
|
if (Obj.GetComponent<Enemy>())
|
||
|
{
|
||
|
Enemy enemy = Obj.GetComponent<Enemy>();
|
||
|
enemy.InitName(topName);
|
||
|
}
|
||
|
Obj.GetComponent<LineamentEvent>().TeamName = topName;
|
||
|
string strname;
|
||
|
int count = objName.Length - 4;
|
||
|
strname = objName.Substring(count, 4);
|
||
|
string theSubName = strname.Substring(0, 3);
|
||
|
if (objName.Contains("xiaofangche") && Obj.tag!="Carother")
|
||
|
{
|
||
|
Obj.GetComponent<CarMessage>().CarAttri = CarAttributeControl.Instance.GetCarAttriFromCarName(theSubName);
|
||
|
}
|
||
|
if (objName.Contains("xiaofangche") && ExamInfoHelpClass.applicationMode == ExamInfoHelpClass.ApplicationMode.PATHFINDING &&
|
||
|
ExamInfoHelpClass.loadSceneMode == ExamInfoHelpClass.LoadSceneMode.ExamineMode && SetPowerScript.Instance.TeamList.Count>0)
|
||
|
{
|
||
|
Obj.GetComponent<CarMessage>().TeamName = TeamName;
|
||
|
Obj.GetComponent<CarMessage>().TheCarHavePeople = XFYcout;
|
||
|
}
|
||
|
if (ExamInfoHelpClass.applicationMode == ExamInfoHelpClass.ApplicationMode.PATHFINDING && objName.Contains("xiaofangche"))
|
||
|
{
|
||
|
TrackRecordHelpClass.AddNavAgentScripts(Obj);
|
||
|
}
|
||
|
if (UIController.instance.NameControl)
|
||
|
{
|
||
|
if(Obj.transform.Find("info"))
|
||
|
Obj.transform.Find("info").gameObject.SetActive(true);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
if (Obj.transform.Find("info"))
|
||
|
{
|
||
|
Obj.transform.Find("info").gameObject.SetActive(false);
|
||
|
}
|
||
|
}
|
||
|
if (Obj.name.Contains("nametext"))
|
||
|
{
|
||
|
Obj.transform.localEulerAngles = new Vector3(90, 90, 90);
|
||
|
}
|
||
|
if (RecordManager.Instance.IsRecording)
|
||
|
{
|
||
|
MessageDispatcher.SendMessage("RecordInstantiateEvent", (object)Obj.name);
|
||
|
}
|
||
|
if (objName.Contains("xiaofangche") && ExamInfoHelpClass.applicationMode == ExamInfoHelpClass.ApplicationMode.PATHFINDING &&
|
||
|
ExamInfoHelpClass.loadSceneMode == ExamInfoHelpClass.LoadSceneMode.ExamineMode)
|
||
|
{
|
||
|
|
||
|
}
|
||
|
|
||
|
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// 移动指挥终端实例化车辆
|
||
|
/// </summary>
|
||
|
/// <param name="objName">对象名</param>
|
||
|
/// <param name="topName">头顶名</param>
|
||
|
private void InstTruckObj(string objName, string topName, string type)
|
||
|
{
|
||
|
Transform pxiaofangche = GameObject.Find("AllParent").transform.Find("pxiaofangche").transform;
|
||
|
bool cloned = false;
|
||
|
foreach (Transform child in pxiaofangche)
|
||
|
{
|
||
|
if (objName == child.name)
|
||
|
{//已有该车辆,只更新位置
|
||
|
child.GetComponent<NavMeshAgent>().enabled = false;
|
||
|
child.localPosition = placementPos;
|
||
|
cloned = true;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if (cloned)
|
||
|
{//如果已有该名字(车牌号)的车辆,则return,不执行以下克隆逻辑
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
int XFYcout = 10;
|
||
|
string TeamName = topName.Split('-')[0];
|
||
|
|
||
|
Obj = Instantiate(prefab, placementPos, Quaternion.identity) as GameObject;
|
||
|
|
||
|
Obj.GetComponent<YinCangMingCheng>().enabled = false;
|
||
|
Obj.AddComponent<GetCarInfos>();
|
||
|
Obj.GetComponent<CarMessage>().Type = type;
|
||
|
|
||
|
Obj.transform.parent = parent.transform;
|
||
|
Obj.GetComponent<CengID>().cengID = 0;
|
||
|
Obj.GetComponent<CengID>().CengIDBuildType = BuildType.TypeA;
|
||
|
Obj.name = objName;
|
||
|
|
||
|
if (Obj.GetComponent<Enemy>())
|
||
|
{
|
||
|
Enemy enemy = Obj.GetComponent<Enemy>();
|
||
|
enemy.InitName(topName);
|
||
|
}
|
||
|
|
||
|
Obj.GetComponent<LineamentEvent>().TeamName = topName;
|
||
|
|
||
|
string theSubName = objName.Split('-')[2];
|
||
|
if (objName.Contains("xiaofangche") && Obj.tag != "Carother")
|
||
|
{
|
||
|
Obj.GetComponent<CarMessage>().CarAttri = CarAttributeControl.Instance.GetCarAttriFromCarName(theSubName);
|
||
|
}
|
||
|
|
||
|
if (objName.Contains("xiaofangche") && ExamInfoHelpClass.applicationMode == ExamInfoHelpClass.ApplicationMode.PATHFINDING &&
|
||
|
ExamInfoHelpClass.loadSceneMode == ExamInfoHelpClass.LoadSceneMode.ExamineMode && SetPowerScript.Instance.TeamList.Count > 0)
|
||
|
{
|
||
|
Obj.GetComponent<CarMessage>().TeamName = TeamName;
|
||
|
Obj.GetComponent<CarMessage>().TheCarHavePeople = XFYcout;
|
||
|
}
|
||
|
if (ExamInfoHelpClass.applicationMode == ExamInfoHelpClass.ApplicationMode.PATHFINDING && objName.Contains("xiaofangche"))
|
||
|
{
|
||
|
TrackRecordHelpClass.AddNavAgentScripts(Obj);
|
||
|
}
|
||
|
|
||
|
if (UIController.instance.NameControl)
|
||
|
{
|
||
|
if (Obj.transform.Find("info"))
|
||
|
Obj.transform.Find("info").gameObject.SetActive(true);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
if (Obj.transform.Find("info"))
|
||
|
{
|
||
|
Obj.transform.Find("info").gameObject.SetActive(false);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
public void InstObj(string objName, int flag)
|
||
|
{
|
||
|
Obj = Instantiate(prefab, placementPos, Quaternion.identity) as GameObject;
|
||
|
Obj.transform.parent = parent.transform;
|
||
|
SetCengID(Obj);
|
||
|
if (flag == 3)//flag==3,多点画管线使用,不加index序号了就
|
||
|
{
|
||
|
Obj.name = objName;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
Obj.name = objName + index;
|
||
|
}
|
||
|
|
||
|
}
|
||
|
public virtual void InstatiateItem(Vector3 placementPos2, RaycastHit hit_)//多点管线
|
||
|
{
|
||
|
placementPos = placementPos2;
|
||
|
}
|
||
|
public void AdjustPipeLine(GameObject Obj)
|
||
|
{
|
||
|
Obj.GetComponent<BoxCollider>().isTrigger = true;
|
||
|
Obj.transform.up = (Obj.transform.position - pos1).normalized;//改变线条的朝向
|
||
|
float distance = Vector3.Distance(pos1, pos2);//计算两点的距离
|
||
|
Obj.transform.localScale = new Vector3(5f, distance * 18, 5f);//延长线条,连接两点。
|
||
|
if (RecordManager.Instance.IsRecording)
|
||
|
{
|
||
|
MessageDispatcher.SendMessage("RecordInstantiateEvent", (object)Obj.name);
|
||
|
}
|
||
|
}
|
||
|
public virtual void InstatiateItem(string objName, int flag)//管线
|
||
|
{
|
||
|
InstObj(objName, flag);
|
||
|
AdjustPipeLine(Obj);
|
||
|
|
||
|
}
|
||
|
|
||
|
public virtual void InstatiateItem(string objName)
|
||
|
{
|
||
|
InstObj(objName);
|
||
|
}
|
||
|
public virtual void InstatiateItem(string objName, float i)//油罐
|
||
|
{
|
||
|
InstObj(objName,i);
|
||
|
}
|
||
|
public void AdjustPoliceLine(GameObject Obj)
|
||
|
{
|
||
|
float distance = Vector3.Distance(pos1, pos2);
|
||
|
var y = Obj.GetComponent<BoxCollider>().size.y / 2;
|
||
|
|
||
|
Obj.transform.Translate(0, y, 0);
|
||
|
Obj.transform.forward = (pos2 - pos1).normalized;
|
||
|
Obj.transform.localScale = new Vector3(20*5.0f,10*5.0f, distance * 80);
|
||
|
|
||
|
if (RecordManager.Instance.IsRecording)
|
||
|
{
|
||
|
MessageDispatcher.SendMessage("RecordInstantiateEvent", (object)Obj.name);
|
||
|
}
|
||
|
}
|
||
|
public virtual void InstatiateItem(string objName, bool flag)//警戒线
|
||
|
{
|
||
|
ChildObj(objName);
|
||
|
AdjustPoliceLine(Obj);
|
||
|
//Reset();
|
||
|
|
||
|
}
|
||
|
public virtual void InstatiateItem(string objName, string topname)
|
||
|
{
|
||
|
InstObj(objName, topname);
|
||
|
|
||
|
//Reset();
|
||
|
//头顶用户名处理
|
||
|
|
||
|
|
||
|
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// 移动指挥终端通信的实例化车辆方法
|
||
|
/// </summary>
|
||
|
/// <param name="objName">对象名</param>
|
||
|
/// <param name="topname">头顶名</param>
|
||
|
/// /// <param name="type">移动终端车辆名</param>
|
||
|
public virtual void InstatiateTruck(string objName, string topname, string type)
|
||
|
{
|
||
|
InstTruckObj(objName, topname, type);
|
||
|
}
|
||
|
|
||
|
public virtual void InstatiateItem(Vector3 placementPos2, bool kongzhi, bool lol, RaycastHit hit_)
|
||
|
{
|
||
|
hit = hit_;
|
||
|
Vector3 vertPos;
|
||
|
var ABdistance = Vector3.Distance(placementPos, placementPos2);
|
||
|
if (!kongzhi)
|
||
|
{
|
||
|
Obj.transform.forward = (-(placementPos2 - placementPos)).normalized;
|
||
|
}
|
||
|
float pos = Mathf.CeilToInt(ABdistance);
|
||
|
float count = Mathf.CeilToInt(pos / 3);
|
||
|
int dex=1;
|
||
|
if (count <1)
|
||
|
{
|
||
|
count = 1;
|
||
|
dex = 0;
|
||
|
}
|
||
|
|
||
|
for (int i = 0; i < count + dex; i++)
|
||
|
{
|
||
|
if (count > 1)
|
||
|
{
|
||
|
if (i != 0)
|
||
|
{
|
||
|
vertPos = new Vector3(placementPos.x + (i / (float)count) * (placementPos2.x - placementPos.x), placementPos.y + (i / (float)count) * (placementPos2.y - placementPos.y), placementPos.z + (i / (float)count) * (placementPos2.z - placementPos.z));
|
||
|
GameObject cloneObj = Instantiate(prefab, vertPos, Quaternion.identity) as GameObject;
|
||
|
cloneObj.transform.forward = (-(placementPos2 - placementPos)).normalized;
|
||
|
cloneObj.transform.parent = parent.transform;
|
||
|
cloneObj.name = parent.name;
|
||
|
SetCengID(cloneObj);
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
GameObject cloneObj = Instantiate(prefab, placementPos2, Quaternion.identity) as GameObject;
|
||
|
cloneObj.transform.forward = (-(placementPos2 - placementPos)).normalized;
|
||
|
cloneObj.transform.parent = parent.transform;
|
||
|
cloneObj.name = parent.name;
|
||
|
SetCengID(cloneObj);
|
||
|
|
||
|
}
|
||
|
|
||
|
}
|
||
|
lol = true;
|
||
|
kongzhi = true;
|
||
|
placementPos = placementPos2;
|
||
|
}
|
||
|
public virtual void InstatiateItem_Fege(Vector3 placementPos2, bool kongzhi, bool lol, RaycastHit hit_)
|
||
|
{
|
||
|
hit = hit_;
|
||
|
Vector3 vertPos;
|
||
|
var ABdistance = Vector3.Distance(placementPos, placementPos2);
|
||
|
if (!kongzhi)
|
||
|
{
|
||
|
Obj.transform.forward = (-(placementPos2 - placementPos)).normalized;
|
||
|
Obj.transform.localEulerAngles = new Vector3(90, Obj.transform.localEulerAngles.y, Obj.transform.localEulerAngles.z);
|
||
|
}
|
||
|
float pos = Mathf.CeilToInt(ABdistance);
|
||
|
float count = Mathf.CeilToInt(pos / 3);
|
||
|
int dex = 1;
|
||
|
if (count < 1)
|
||
|
{
|
||
|
count = 1;
|
||
|
dex = 0;
|
||
|
}
|
||
|
|
||
|
for (int i = 0; i < count + dex; i++)
|
||
|
{
|
||
|
if (count > 1)
|
||
|
{
|
||
|
if (i != 0)
|
||
|
{
|
||
|
vertPos = new Vector3(placementPos.x + (i / (float)count) * (placementPos2.x - placementPos.x), placementPos.y + (i / (float)count) * (placementPos2.y - placementPos.y), placementPos.z + (i / (float)count) * (placementPos2.z - placementPos.z));
|
||
|
GameObject cloneObj = Instantiate(prefab, vertPos, Quaternion.identity) as GameObject;
|
||
|
cloneObj.transform.parent = parent.transform;
|
||
|
cloneObj.transform.forward = (-(placementPos2 - placementPos)).normalized;
|
||
|
cloneObj.transform.localScale = new Vector3(15, 15, 15);
|
||
|
cloneObj.transform.localEulerAngles = new Vector3(90, cloneObj.transform.localEulerAngles.y, cloneObj.transform.localEulerAngles.z);
|
||
|
cloneObj.name = parent.name;
|
||
|
SetCengID(cloneObj);
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
GameObject cloneObj = Instantiate(prefab, placementPos2, Quaternion.identity) as GameObject;
|
||
|
cloneObj.transform.parent = parent.transform;
|
||
|
cloneObj.transform.forward = (-(placementPos2 - placementPos)).normalized;
|
||
|
cloneObj.transform.localScale = new Vector3(15, 15, 15);
|
||
|
cloneObj.transform.localEulerAngles = new Vector3(90, cloneObj.transform.localEulerAngles.y, cloneObj.transform.localEulerAngles.z);
|
||
|
cloneObj.name = parent.name;
|
||
|
SetCengID(cloneObj);
|
||
|
|
||
|
}
|
||
|
|
||
|
}
|
||
|
lol = true;
|
||
|
kongzhi = true;
|
||
|
placementPos = placementPos2;
|
||
|
}
|
||
|
public virtual void InstatiateItem_DuJie(Vector3 placementPos2, bool kongzhi, bool lol, RaycastHit hit_)
|
||
|
{
|
||
|
hit = hit_;
|
||
|
Vector3 vertPos;
|
||
|
var ABdistance = Vector3.Distance(placementPos, placementPos2);
|
||
|
if (!kongzhi)
|
||
|
{
|
||
|
Obj.transform.forward = ((placementPos2 - placementPos)).normalized;
|
||
|
//Obj.transform.localEulerAngles = new Vector3(90, Obj.transform.localEulerAngles.y, Obj.transform.localEulerAngles.z);
|
||
|
}
|
||
|
float pos = Mathf.CeilToInt(ABdistance);
|
||
|
float count = Mathf.CeilToInt(pos/1.5f);
|
||
|
int dex = 1;
|
||
|
if (count < 1)
|
||
|
{
|
||
|
count = 1;
|
||
|
dex = 0;
|
||
|
}
|
||
|
|
||
|
for (int i = 0; i < count + dex; i++)
|
||
|
{
|
||
|
if (count > 1)
|
||
|
{
|
||
|
if (i != 0)
|
||
|
{
|
||
|
vertPos = new Vector3(placementPos.x + (i / (float)count) * (placementPos2.x - placementPos.x), placementPos.y + (i / (float)count) * (placementPos2.y - placementPos.y), placementPos.z + (i / (float)count) * (placementPos2.z - placementPos.z));
|
||
|
GameObject cloneObj = Instantiate(prefab, vertPos, Quaternion.identity) as GameObject;
|
||
|
cloneObj.transform.parent = parent.transform;
|
||
|
cloneObj.transform.forward = ((placementPos2 - placementPos)).normalized;
|
||
|
cloneObj.transform.localScale = new Vector3(1, 1, 1);
|
||
|
//cloneObj.transform.localEulerAngles = new Vector3(90, cloneObj.transform.localEulerAngles.y, cloneObj.transform.localEulerAngles.z);
|
||
|
cloneObj.name = parent.name;
|
||
|
SetCengID(cloneObj);
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
GameObject cloneObj = Instantiate(prefab, placementPos2, Quaternion.identity) as GameObject;
|
||
|
cloneObj.transform.parent = parent.transform;
|
||
|
cloneObj.transform.forward = ((placementPos2 - placementPos)).normalized;
|
||
|
cloneObj.transform.localScale = new Vector3(1, 1, 1);
|
||
|
//cloneObj.transform.localEulerAngles = new Vector3(90, cloneObj.transform.localEulerAngles.y, cloneObj.transform.localEulerAngles.z);
|
||
|
cloneObj.name = parent.name;
|
||
|
SetCengID(cloneObj);
|
||
|
|
||
|
}
|
||
|
|
||
|
}
|
||
|
lol = true;
|
||
|
kongzhi = true;
|
||
|
placementPos = placementPos2;
|
||
|
}
|
||
|
public void SetCengID(GameObject obj)
|
||
|
{
|
||
|
BuildItem build = new BuildItem();
|
||
|
if (hit.collider.GetComponent<CengID>())
|
||
|
{
|
||
|
build.floor = hit.collider.GetComponent<CengID>().cengID;
|
||
|
build.buildType = hit.collider.GetComponent<CengID>().CengIDBuildType;
|
||
|
MessageDispatcher.SendMessage(obj.name, "SetCengID", build);
|
||
|
}
|
||
|
|
||
|
}
|
||
|
}
|