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.
209 lines
7.7 KiB
209 lines
7.7 KiB
using System.Collections; |
|
using System.Collections.Generic; |
|
using UnityEngine; |
|
using UnityEngine.UI; |
|
|
|
public class FireEngines : MonoBehaviour |
|
{ |
|
public GameObject Dept; |
|
public GameObject Engine; |
|
public GameObject Content; |
|
|
|
//每个中队的消防员人数 |
|
private Dictionary<string, int> Persons = new Dictionary<string, int>(); |
|
|
|
//按中队、车类型组织车辆数据(string:组织机构;List<KeyValuePair<FireCarEngine, int>:某类型车有多少辆) |
|
private Dictionary<string, List<KeyValuePair<FireCarEngine, int>>> DeptCars = |
|
new Dictionary<string, List<KeyValuePair<FireCarEngine, int>>>(); |
|
|
|
private List<Organization> orgList = new List<Organization>(); |
|
|
|
public List<Color> colors = new List<Color>(); |
|
|
|
// Use this for initialization |
|
void Awake() |
|
{ |
|
Content = transform.Find("Viewport/Content").gameObject; |
|
|
|
colors = new List<Color>() |
|
{ |
|
new Color(255/255f,0f,0f,0.9f), |
|
|
|
new Color(252/255f,0f,255/255f,0.9f), |
|
|
|
new Color(255/255f,255/255f,0f,0.9f), |
|
|
|
new Color(0f,0f,255/255f,0.9f), |
|
|
|
new Color(30/255f,255/255f,0f,0.9f), |
|
|
|
new Color(0f,213/255f,251/255f,0.9f), |
|
|
|
new Color(82/255f,143/255f,178/255f,0.9f), |
|
|
|
new Color(212/255f,157/255f,115/255f,0.9f), |
|
|
|
new Color(133/255f,168/255f,33/255f,0.9f), |
|
|
|
new Color(254/255f,212/255f,241/255f,0.9f), |
|
|
|
new Color(226/255f,208/255f,172/255f,0.9f), |
|
|
|
new Color(226/255f,185/255f,255/255f,0.9f), |
|
|
|
new Color(248/255f,126/255f,123/255f,0.9f), |
|
|
|
new Color(253/255f,251/255f,224/255f,0.9f), |
|
|
|
new Color(254/255f,194/255f,133/255f,0.9f), |
|
|
|
new Color(133/255f,133/255f,194/255f,0.9f), |
|
|
|
new Color(224/255f,102/255f,163/255f,0.9f), |
|
|
|
new Color(133/255f,194/255f,133/255f,0.9f), |
|
|
|
new Color(224/255f,224/255f,102/255f,0.9f), |
|
|
|
new Color(102/255f,194/255f,194/255f,0.9f), |
|
}; |
|
} |
|
|
|
// Update is called once per frame |
|
void Update() |
|
{ |
|
|
|
} |
|
|
|
private void OnEnable() |
|
{ |
|
Persons = FireEnginesData.Instance.GetAllPersons(); |
|
DeptCars = FireEnginesData.Instance.GetAllCas(); |
|
|
|
CreateEnginesUI(); |
|
} |
|
|
|
private void CreateEnginesUI() |
|
{ |
|
foreach (Transform dept in Content.transform) |
|
{ |
|
Destroy(dept.gameObject); |
|
} |
|
|
|
orgList.Clear(); |
|
if (CurrentUserInfo.room != null) |
|
{ |
|
foreach (var item in CurrentUserInfo.room.UserList) |
|
{ |
|
if (item.Org.Level == 4 && !orgList.Contains(item.Org)) |
|
{ |
|
orgList.Add(item.Org); |
|
} |
|
} |
|
} |
|
|
|
for (int i = 0; i < orgList.Count; i++) |
|
{ |
|
if (DeptCars.ContainsKey(orgList[i].DisplayName)) |
|
{ |
|
GameObject dept = GameObject.Instantiate(Dept, Content.transform) as GameObject; |
|
dept.transform.Find("Name/Text").GetComponent<Text>().text = orgList[i].DisplayName; |
|
dept.GetComponent<DeptItem>().org = orgList[i]; |
|
|
|
foreach (KeyValuePair<FireCarEngine, int> item in DeptCars[orgList[i].DisplayName]) |
|
{ |
|
GameObject engine = GameObject.Instantiate(Engine, dept.transform.Find("Viewport/Content")) as GameObject; |
|
engine.transform.Find("Text").GetComponent<Text>().text = item.Key.TypeName + "(" + item.Value + ")"; |
|
engine.transform.Find("Toggle/Background").GetComponent<Image>().color = colors[i]; |
|
engine.GetComponent<EngineItem>().org = orgList[i]; |
|
engine.GetComponent<EngineItem>().tpyeCar = item; |
|
|
|
engine.transform.Find("Toggle").GetComponent<Toggle>().group = |
|
dept.transform.Find("Viewport/Content").GetComponent<ToggleGroup>(); |
|
|
|
SetCloneType(item.Key.TypeName, engine); |
|
|
|
if (!CurrentUserInfo.generalCommanding) |
|
{ |
|
engine.transform.Find("Toggle").GetComponent<Toggle>().interactable = false; |
|
} |
|
} |
|
|
|
if (Persons.ContainsKey(orgList[i].DisplayName)) |
|
{ |
|
GameObject engine = GameObject.Instantiate(Engine, dept.transform.Find("Viewport/Content")) as GameObject; |
|
engine.transform.Find("Text").GetComponent<Text>().text = "消防员" + "(" + Persons[orgList[i].DisplayName] + ")"; |
|
if (GameSettings.othersSettings.mode == Mode.manoeuvre) |
|
{ |
|
engine.transform.Find("Text").GetComponent<Text>().text |
|
= "消防员" + "(" + GameSettings.othersSettings.FireEngines_Dic[orgList[i].DisplayName] + ")"; |
|
} |
|
engine.transform.Find("Toggle/Background").GetComponent<Image>().color = colors[i]; |
|
engine.GetComponent<EngineItem>().org = orgList[i]; |
|
|
|
engine.transform.Find("Toggle").GetComponent<Toggle>().group = |
|
dept.transform.Find("Viewport/Content").GetComponent<ToggleGroup>(); |
|
|
|
SetCloneType("消防员", engine); |
|
|
|
if (!CurrentUserInfo.generalCommanding) |
|
{ |
|
engine.transform.Find("Toggle").GetComponent<Toggle>().interactable = false; |
|
} |
|
} |
|
} |
|
} |
|
} |
|
|
|
private void SetCloneType(string typeName, GameObject engine) |
|
{ |
|
if (typeName == "水罐车") |
|
{ |
|
engine.transform.Find("Toggle").GetComponent<CloneFireDeployToolBtn>().cloneObjType = CloneObjType.FDWaterTanker; |
|
} |
|
if (typeName == "泡沫车") |
|
{ |
|
engine.transform.Find("Toggle").GetComponent<CloneFireDeployToolBtn>().cloneObjType = CloneObjType.FDFoamTruck; |
|
} |
|
if (typeName == "举高车") |
|
{ |
|
engine.transform.Find("Toggle").GetComponent<CloneFireDeployToolBtn>().cloneObjType = CloneObjType.FDAerialTowerTruck; |
|
} |
|
if (typeName == "高喷车") |
|
{ |
|
engine.transform.Find("Toggle").GetComponent<CloneFireDeployToolBtn>().cloneObjType = CloneObjType.FDHighSprayingTruck; |
|
} |
|
if (typeName == "云梯车") |
|
{ |
|
engine.transform.Find("Toggle").GetComponent<CloneFireDeployToolBtn>().cloneObjType = CloneObjType.FDLadderTruck; |
|
} |
|
if (typeName == "排烟车") |
|
{ |
|
engine.transform.Find("Toggle").GetComponent<CloneFireDeployToolBtn>().cloneObjType = CloneObjType.FDSmokeExhaustTruck; |
|
} |
|
if (typeName == "抢险车") |
|
{ |
|
engine.transform.Find("Toggle").GetComponent<CloneFireDeployToolBtn>().cloneObjType = CloneObjType.FDRescueVehicle; |
|
} |
|
if (typeName == "器材车") |
|
{ |
|
engine.transform.Find("Toggle").GetComponent<CloneFireDeployToolBtn>().cloneObjType = CloneObjType.FDApparatus; |
|
} |
|
if (typeName == "照明车") |
|
{ |
|
engine.transform.Find("Toggle").GetComponent<CloneFireDeployToolBtn>().cloneObjType = CloneObjType.FDLightingAppliance; |
|
} |
|
if (typeName == "供气车") |
|
{ |
|
engine.transform.Find("Toggle").GetComponent<CloneFireDeployToolBtn>().cloneObjType = CloneObjType.FDAirSupplyTruck; |
|
} |
|
if (typeName == "破拆车") |
|
{ |
|
engine.transform.Find("Toggle").GetComponent<CloneFireDeployToolBtn>().cloneObjType = CloneObjType.FDForcibleEntryTruck; |
|
} |
|
if (typeName == "消防员") |
|
{ |
|
engine.transform.Find("Toggle").GetComponent<CloneFireDeployToolBtn>().cloneObjType = CloneObjType.FDFireMan; |
|
} |
|
} |
|
}
|
|
|