190 lines
6.1 KiB
190 lines
6.1 KiB
using UnityEngine; |
|
using System.Collections; |
|
using System; |
|
using AX.TrackRecord; |
|
using UnityEngine.EventSystems; |
|
using System.Collections.Generic; |
|
using UnityEngine.UI; |
|
using AX.MessageSystem; |
|
|
|
public class SetPowerScript : MonoBehaviour { |
|
|
|
private string[] CarTpyeList = new string[] { "高喷车", "登高车", "云梯车", "水罐车", "泡沫车", "排烟车", "器材车", "抢险车", "照明车", "指挥车" }; |
|
public static SetPowerScript Instance; |
|
public GameObject Father; |
|
public GameObject Item; |
|
public Toggle toggle; |
|
public List<TeamAttri> TeamList = new List<TeamAttri>(); |
|
public GameObject PingBi; |
|
/// <summary> |
|
/// 模式形式 |
|
/// </summary> |
|
|
|
public ModeType modeType = ModeType.AllPower; |
|
void Awake() |
|
{ |
|
if (Instance == null) |
|
{ |
|
Instance = this; |
|
} |
|
} |
|
void Start () |
|
{ |
|
toggle.onValueChanged.AddListener(Changed); |
|
} |
|
public void Changed(bool check) |
|
{ |
|
if (check) |
|
{ |
|
MessageDispatcher.SendMessage("ToggleIson"); |
|
} |
|
else |
|
{ |
|
MessageDispatcher.SendMessage("ToggleIsFlase"); |
|
} |
|
} |
|
|
|
TeamAttri Attri; |
|
public void DoestroyItem() |
|
{ |
|
foreach (Transform child in Father.transform) |
|
{ |
|
Destroy(child.gameObject); |
|
} |
|
} |
|
public void InstanceItem(TeamAttri teamAttri) |
|
{ |
|
DoestroyItem(); |
|
Attri = teamAttri; |
|
PowerAttri power=new PowerAttri(); |
|
for (int i = 0; i < 10; i++) |
|
{ |
|
string Name = CarTpyeList[i]; |
|
GameObject Game = Instantiate(Item) as GameObject; |
|
Game.transform.SetParent(Father.transform); |
|
Game.transform.localScale = new Vector3(1, 1, 1); |
|
Game.GetComponent<PowerScript>().Name.text = Name; |
|
Game.GetComponent<PowerScript>().TeamName = Attri.TeamName; |
|
|
|
|
|
if (Attri.PowerAttriList.Count == 0) |
|
{ |
|
Game.GetComponent<PowerScript>().Water.text = power.HasWater.ToString(); |
|
Game.GetComponent<PowerScript>().PaoMo.text = power.HasPaoMo.ToString(); |
|
Game.GetComponent<PowerScript>().GanFen.text = power.HasGanFen.ToString(); |
|
Game.GetComponent<PowerScript>().People.text = power.XFYCount.ToString(); |
|
Game.GetComponent<PowerScript>().Num.text = power.CarCount.ToString(); |
|
} |
|
else |
|
{ |
|
Game.GetComponent<PowerScript>().Water.text = Attri.PowerAttriList[i].HasWater.ToString(); |
|
Game.GetComponent<PowerScript>().PaoMo.text = Attri.PowerAttriList[i].HasPaoMo.ToString(); |
|
Game.GetComponent<PowerScript>().GanFen.text = Attri.PowerAttriList[i].HasGanFen.ToString(); |
|
Game.GetComponent<PowerScript>().People.text = Attri.PowerAttriList[i].XFYCount.ToString(); |
|
Game.GetComponent<PowerScript>().Num.text = Attri.PowerAttriList[i].CarCount.ToString(); |
|
bool has = Attri.PowerAttriList[i].HasThisPower; |
|
if (has) |
|
{ |
|
Game.GetComponent<PowerScript>().toogle.isOn = true; |
|
} |
|
else |
|
{ |
|
Game.GetComponent<PowerScript>().toogle.isOn = false; |
|
} |
|
} |
|
|
|
if (i > 2) |
|
{ |
|
Game.GetComponent<PowerScript>().Heigh.text = "-"; |
|
Game.GetComponent<PowerScript>().Heigh.enabled = false; |
|
} |
|
else |
|
{ |
|
if (Attri.PowerAttriList.Count == 0) |
|
{ |
|
Game.GetComponent<PowerScript>().Heigh.enabled = true; |
|
Game.GetComponent<PowerScript>().Heigh.text = power.Hegih.ToString(); |
|
} |
|
else |
|
{ |
|
Game.GetComponent<PowerScript>().Heigh.enabled = true; |
|
Game.GetComponent<PowerScript>().Heigh.text = Attri.PowerAttriList[i].Hegih.ToString(); |
|
|
|
} |
|
} |
|
Game.name = Name; |
|
} |
|
|
|
} |
|
public void CloseThis() |
|
{ |
|
this.gameObject.SetActive(false); |
|
} |
|
public void SureBtn() |
|
{ |
|
if (ExamInfoHelpClass.loadSceneMode == ExamInfoHelpClass.LoadSceneMode.CheckQuestion) |
|
{ |
|
this.gameObject.SetActive(false); |
|
return; |
|
} |
|
bool HasOver = false; |
|
foreach (Transform child in Father.transform) |
|
{ |
|
|
|
if (child.gameObject.name.Equals("高喷车") || child.gameObject.name.Equals("举高车") || child.gameObject.name.Equals("云梯车")) |
|
{ |
|
float Num = float.Parse(child.transform.Find("Heigh").GetComponent<InputField>().text); |
|
if (Num > 100f) |
|
{ |
|
HasOver = true; |
|
} |
|
} |
|
} |
|
|
|
if (!HasOver) |
|
{ |
|
MessageDispatcher.SendMessage("Operatinghints", (object)"编辑成功"); |
|
} |
|
else |
|
{ |
|
MessageDispatcher.SendMessage("Operatinghints", (object)"车辆最高可升100米"); |
|
return; |
|
} |
|
|
|
foreach (Transform child in Father.transform) |
|
{ |
|
PowerScript Power = child.GetComponent<PowerScript>(); |
|
for (int i = 0; i < TeamList.Count; i++) |
|
{ |
|
if (Power.TeamName.Equals(TeamList[i].TeamName)) |
|
{ |
|
TeamList[i].PowerAttriList.Clear(); |
|
} |
|
} |
|
} |
|
foreach (Transform child in Father.transform) |
|
{ |
|
PowerScript Power=child.GetComponent<PowerScript>(); |
|
if (Power.toogle.isOn) |
|
{ |
|
Power.Has = true; |
|
} |
|
else |
|
{ |
|
Power.Has = false; |
|
} |
|
for (int i = 0; i < TeamList.Count; i++) |
|
{ |
|
if (Power.TeamName.Equals(TeamList[i].TeamName)) |
|
{ |
|
TeamList[i].PowerAttriList.Add(Power.Attri); |
|
} |
|
} |
|
|
|
} |
|
toggle.isOn = false; |
|
this.gameObject.SetActive(false); |
|
} |
|
|
|
|
|
}
|
|
|