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()
{
}
///
/// 物体统一实例化
///
///
///
///
///
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("Prefabs/ToolPrefab/NullPrefab"), placementPos, Quaternion.identity) as GameObject;
}
else
{
Obj = Instantiate(prefab, placementPos, Quaternion.identity) as GameObject;
}
if (objAttri.ObjName.Contains("jijiequ"))
{
Obj.GetComponent().Jijie = objAttri.jijiequ;
}
if (objAttri.ObjName.Contains("chetui") || objAttri.ObjName.Contains("jingong") || objAttri.ObjName.Contains("fengexian")|| objAttri.ObjName.Contains("dujiexian"))
{
Obj.GetComponent().size = objAttri.lineSize;
}
if (objAttri.ObjName.Contains("nametext"))
{
Obj.GetComponent().text = objAttri.jijiequ.Name;
Obj.GetComponent().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.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().youGuan = oilTankObj;
}
Obj.GetComponent().cengID = objAttri.CengID;
Obj.GetComponent().CengIDBuildType = objAttri.buildTpye;
Obj.GetComponent().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 + "_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 ctrl = null;
if (Obj.GetComponent())
{
ctrl = Obj.GetComponent();
}
else if (Obj.GetComponent())
{
ctrl = Obj.GetComponent();
}
//赋值速度和位置数组
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().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().CarAttri = objAttri.carAttriList[0];
}
if (ExamInfoHelpClass.applicationMode == ExamInfoHelpClass.ApplicationMode.PATHFINDING)
{
TrackRecordHelpClass.AddNavAgentScripts(Obj);
}
}
if (hasTopInfo)
{
Obj.transform.Find("info").Find("Name").GetComponent().text = objAttri.TopName;
if(Obj.transform.Find("info").Find("Function"))
Obj.transform.Find("info").Find("Function").GetComponent().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 = child.CengID;
childobj.GetComponent().CengIDBuildType = child.buildType;
childobj.transform.parent = Obj.transform;
if (childobj.GetComponent())
{
childobj.GetComponent().SetPos(child.beginP, child.endP);
childobj.transform.parent.GetComponent().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);
}
///
/// 移动指挥终端模块需要
///
///
///
///
///
///
///
///
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().hitTag = hit.transform.tag;
}
//RecordManager.Instance.objCount++;
if (Obj.GetComponent())
{
// Debug.Log(Obj.name+" "+ hit.normal);
Obj.GetComponent().SetDirec(hit);
// Debug.DrawLine(hit.collider.transform.position, hit.normal * 1000, Color.blue);
}
if (Obj.GetComponent())
{
JiJieQu ji = new JiJieQu();
Obj.GetComponent().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) == 0)
{
Game.GetComponent