天津23维预案
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.
 
 
 
 
 
 

279 lines
11 KiB

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using AX.MessageSystem;
using System;
using MobileCFFSInfo;
/// <summary>
/// 克隆移动指挥终端同步过来的车辆(只生成可控范围内的)
/// </summary>
public class CloneCars : MonoBehaviour {
public float r = 1000;//可控范围
public string Name = "";
public string TopName = "";
// Use this for initialization
void Start () {
MessageDispatcher.AddListener("CLONE_CAR",CloneCar);
}
private void CloneCar(IMessage obj)
{
var FFSInfo = (FFSInfo)obj.Data;
List<FireTruckInfo> truckInfos = FFSInfo.FireTruckInfos;
foreach (FireTruckInfo truckInfo in truckInfos)
{
if (MobileCFFSInfo.Vector2.Distance(truckInfo.Position, FFSInfo.Origin) <= r)
{//生成可控范围内的车辆
InitCars(truckInfo, FFSInfo.Origin);
}
}
}
private void InitCars(FireTruckInfo truckInfo, MobileCFFSInfo.Vector2 origin)
{
TopName = truckInfo.FireSquadron + "-" + truckInfo.Type3D + "-" + truckInfo.PlateNumber;
if (truckInfo.Type3D.Equals("高喷车"))
{//高喷车
Name = truckInfo.FireSquadron + "-" + "xiaofangche" + "-" + "gpc" + "-" + truckInfo.PlateNumber;
NormalCars xfc = new NormalCars(Resources.Load<GameObject>("Prefabs/Car/gpc"),
GameObject.Find("pxiaofangche"),
null,
NormalCars.carIndex,
truckInfo.Position, origin, 0f);
xfc.InstatiateTruck(Name, TopName, truckInfo.Type);
}
else if (truckInfo.Type3D.Equals("泡沫车"))
{//泡沫车
Name = truckInfo.FireSquadron + "-" + "xiaofangche" + "-" + "pmc" + "-" + truckInfo.PlateNumber;
NormalCars xfc = new NormalCars(Resources.Load<GameObject>("Prefabs/Car/pmc"),
GameObject.Find("pxiaofangche"),
null,
NormalCars.carIndex,
truckInfo.Position, origin, 0f);
xfc.InstatiateTruck(Name, TopName, truckInfo.Type);
}
else if (truckInfo.Type3D.Equals("超高层供水车"))
{//超高层供水车
Name = truckInfo.FireSquadron + "-" + "xiaofangche" + "-" + "pmc" + "-" + truckInfo.PlateNumber;
NormalCars xfc = new NormalCars(Resources.Load<GameObject>("Prefabs/Car/cgpmc"),
GameObject.Find("pxiaofangche"),
null,
NormalCars.carIndex,
truckInfo.Position, origin, 0f);
xfc.InstatiateTruck(Name, TopName, truckInfo.Type);
}
else if (truckInfo.Type3D.Equals("登高车"))
{//登高车
Name = truckInfo.FireSquadron + "-" + "xiaofangche" + "-" + "dgc" + "-" + truckInfo.PlateNumber;
NormalCars xfc = new NormalCars(Resources.Load<GameObject>("Prefabs/Car/dgc"),
GameObject.Find("pxiaofangche"),
null,
NormalCars.carIndex,
truckInfo.Position, origin, 0f);
xfc.InstatiateTruck(Name, TopName, truckInfo.Type);
}
else if (truckInfo.Type3D.Equals("抢险车"))
{//抢险车
Name = truckInfo.FireSquadron + "-" + "xiaofangche" + "-" + "qxc" + "-" + truckInfo.PlateNumber;
NormalCars xfc = new NormalCars(Resources.Load<GameObject>("Prefabs/Car/qxc"),
GameObject.Find("pxiaofangche"),
null,
NormalCars.carIndex,
truckInfo.Position, origin, 0f);
xfc.InstatiateTruck(Name, TopName, truckInfo.Type);
}
else if (truckInfo.Type3D.Equals("器材车"))
{//器材车
Name = truckInfo.FireSquadron + "-" + "xiaofangche" + "-" + "qcc" + "-" + truckInfo.PlateNumber;
NormalCars xfc = new NormalCars(Resources.Load<GameObject>("Prefabs/Car/qcc"),
GameObject.Find("pxiaofangche"),
null,
NormalCars.carIndex,
truckInfo.Position, origin, 0f);
xfc.InstatiateTruck(Name, TopName, truckInfo.Type);
}
else if (truckInfo.Type3D.Equals("水罐车"))
{//水罐车
Name = truckInfo.FireSquadron + "-" + "xiaofangche" + "-" + "sgc" + "-" + truckInfo.PlateNumber;
NormalCars xfc = new NormalCars(Resources.Load<GameObject>("Prefabs/Car/sgc"),
GameObject.Find("pxiaofangche"),
null,
NormalCars.carIndex,
truckInfo.Position, origin, 0f);
xfc.InstatiateTruck(Name, TopName, truckInfo.Type);
}
else if (truckInfo.Type3D.Equals("云梯车"))
{//云梯车
Name = truckInfo.FireSquadron + "-" + "xiaofangche" + "-" + "ytc" + "-" + truckInfo.PlateNumber;
NormalCars xfc = new NormalCars(Resources.Load<GameObject>("Prefabs/Car/ytc"),
GameObject.Find("pxiaofangche"),
null,
NormalCars.carIndex,
truckInfo.Position, origin, 0f);
xfc.InstatiateTruck(Name, TopName, truckInfo.Type);
}
else if (truckInfo.Type3D.Equals("照明车"))
{//照明车
Name = truckInfo.FireSquadron + "-" + "xiaofangche" + "-" + "zmc" + "-" + truckInfo.PlateNumber;
NormalCars xfc = new NormalCars(Resources.Load<GameObject>("Prefabs/Car/zmc"),
GameObject.Find("pxiaofangche"),
null,
NormalCars.carIndex,
truckInfo.Position, origin, 0f);
xfc.InstatiateTruck(Name, TopName, truckInfo.Type);
}
else if (truckInfo.Type3D.Equals("指挥车"))
{//指挥车
Name = truckInfo.FireSquadron + "-" + "xiaofangche" + "-" + "zhc" + "-" + truckInfo.PlateNumber;
NormalCars xfc = new NormalCars(Resources.Load<GameObject>("Prefabs/Car/zhc"),
GameObject.Find("pxiaofangche"),
null,
NormalCars.carIndex,
truckInfo.Position, origin, 0f);
xfc.InstatiateTruck(Name, TopName, truckInfo.Type);
}
else if (truckInfo.Type3D.Equals("排烟车"))
{//排烟车
Name = truckInfo.FireSquadron + "-" + "xiaofangche" + "-" + "pyc" + "-" + truckInfo.PlateNumber;
NormalCars xfc = new NormalCars(Resources.Load<GameObject>("Prefabs/Car/pyc"),
GameObject.Find("pxiaofangche"),
null,
NormalCars.carIndex,
truckInfo.Position, origin, 0f);
xfc.InstatiateTruck(Name, TopName, truckInfo.Type);
}
else if (truckInfo.Type3D.Equals("救护车"))
{//救护车
Name = truckInfo.FireSquadron + "-" + "xiaofangche" + "-" + "jhc" + "-" + truckInfo.PlateNumber;
NormalCars xfc = new NormalCars(Resources.Load<GameObject>("Prefabs/Car/jhc"),
GameObject.Find("pxiaofangche"),
null,
NormalCars.carIndex,
truckInfo.Position, origin, 0f);
xfc.InstatiateTruck(Name, TopName, truckInfo.Type);
}
else if (truckInfo.Type3D.Equals("电力抢险车"))
{//电力抢险车
Name = truckInfo.FireSquadron + "-" + "xiaofangche" + "-" + "dlqx" + "-" + truckInfo.PlateNumber;
NormalCars xfc = new NormalCars(Resources.Load<GameObject>("Prefabs/Car/dlqx"),
GameObject.Find("pxiaofangche"),
null,
NormalCars.carIndex,
truckInfo.Position, origin, 0f);
xfc.InstatiateTruck(Name, TopName, truckInfo.Type);
}
else if (truckInfo.Type3D.Equals("燃气抢险车"))
{//燃气抢险车
Name = truckInfo.FireSquadron + "-" + "xiaofangche" + "-" + "rqqx" + "-" + truckInfo.PlateNumber;
NormalCars xfc = new NormalCars(Resources.Load<GameObject>("Prefabs/Car/rqqx"),
GameObject.Find("pxiaofangche"),
null,
NormalCars.carIndex,
truckInfo.Position, origin, 0f);
xfc.InstatiateTruck(Name, TopName, truckInfo.Type);
}
else if (truckInfo.Type3D.Equals("供水抢险车"))
{//供水抢险车
Name = truckInfo.FireSquadron + "-" + "xiaofangche" + "-" + "gsqx" + "-" + truckInfo.PlateNumber;
NormalCars xfc = new NormalCars(Resources.Load<GameObject>("Prefabs/Car/gsqx"),
GameObject.Find("pxiaofangche"),
null,
NormalCars.carIndex,
truckInfo.Position, origin, 0f);
xfc.InstatiateTruck(Name, TopName, truckInfo.Type);
}
else if (truckInfo.Type3D.Equals("公安车"))
{//公安车
Name = truckInfo.FireSquadron + "-" + "xiaofangche" + "-" + "gac" + "-" + truckInfo.PlateNumber;
NormalCars xfc = new NormalCars(Resources.Load<GameObject>("Prefabs/Car/gac"),
GameObject.Find("pxiaofangche"),
null,
NormalCars.carIndex,
truckInfo.Position, origin, 0f);
xfc.InstatiateTruck(Name, TopName, truckInfo.Type);
}
else if (truckInfo.Type3D.Equals("空气呼吸充气车"))
{//空气呼吸充气车
Name = truckInfo.FireSquadron + "-" + "xiaofangche" + "-" + "cqc" + "-" + truckInfo.PlateNumber;
NormalCars xfc = new NormalCars(Resources.Load<GameObject>("Prefabs/Car/cqc"),
GameObject.Find("pxiaofangche"),
null,
NormalCars.carIndex,
truckInfo.Position, origin, 0f);
xfc.InstatiateTruck(Name, TopName, truckInfo.Type);
}
else if (truckInfo.Type3D.Equals("油料补充车"))
{//油料补充车
Name = truckInfo.FireSquadron + "-" + "xiaofangche" + "-" + "ylc" + "-" + truckInfo.PlateNumber;
NormalCars xfc = new NormalCars(Resources.Load<GameObject>("Prefabs/Car/ylc"),
GameObject.Find("pxiaofangche"),
null,
NormalCars.carIndex,
truckInfo.Position, origin, 0f);
xfc.InstatiateTruck(Name, TopName, truckInfo.Type);
}
else if (truckInfo.Type3D.Equals("破拆车"))
{//破拆车
Name = truckInfo.FireSquadron + "-" + "xiaofangche" + "-" + "pchcgpc" + "-" + truckInfo.PlateNumber;
NormalCars xfc = new NormalCars(Resources.Load<GameObject>("Prefabs/Car/pchcgpc"),
GameObject.Find("pxiaofangche"),
null,
NormalCars.carIndex,
truckInfo.Position, origin, 0f);
xfc.InstatiateTruck(Name, TopName, truckInfo.Type);
}
}
// Update is called once per frame
void Update () {
}
private void OnDestroy()
{
MessageDispatcher.RemoveListener("CLONE_CAR", CloneCar);
}
}