天津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.
 
 
 
 
 
 

140 lines
4.4 KiB

using UnityEngine;
using System.Collections;
using AX.MessageSystem;
using System.Collections.Generic;
using AX.TrackRecord;
using UnityEngine.UI;
using System;
public class CarAttributeControl : MonoBehaviour
{
public List<CarAttri> TheCarAttriList = new List<CarAttri>();
private string[] CarTpyeList = new string[] { "高喷车", "登高车", "云梯车", "水罐车", "泡沫车", "排烟车", "器材车", "抢险车", "照明车", "通信车" };
public GameObject Father;
public GameObject Item;
public static CarAttributeControl Instance;
private MouseFollowRotation MouseFollow;
void Awake()
{
InstanceItem();
InitCarAttriList();
MouseFollow = GameObject.Find("Main Camera").GetComponent<MouseFollowRotation>();
if (null == Instance)
{
Instance = this;
}
}
void OnDisable()
{
if (MouseFollow!=null)
MouseFollow.enabled = true;
}
void OnEnable()
{
MouseFollow.enabled = false;
SetItemAttri();
}
private void SetItemAttri()
{
if(TheCarAttriList.Count== CarTpyeList.Length)
{
int index = 0;
foreach(Transform childItem in Father.transform)
{
childItem.GetComponent<CarItemAttribute>().Attri = TheCarAttriList[index++];
}
}
}
private void InitCarAttriList()
{
for (int i = 0; i < CarTpyeList.Length; i++)
{
CarAttri carAttri = new CarAttri();
if (i > 2)
{
carAttri.Hegih = "-";
}
TheCarAttriList.Add(carAttri);
}
}
public CarAttri GetCarAttriFromCarName(string carName)
{
int carType = -1;
switch (carName)
{
case "gpc": carType = 0; break;
case "dgc": carType = 1; break;
case "ytc": carType = 2; break;
case "sgc": carType = 3; break;
case "pmc": carType = 4; break;
case "pyc": carType = 5; break;
case "qcc": carType = 6; break;
case "qxc": carType = 7; break;
case "zmc": carType = 8; break;
case "zhc": carType = 9; break;
}
return TheCarAttriList[carType];
}
public void SureSaveBtn()
{
bool HasOver=false;
foreach (Transform child in Father.transform)
{
string childIntro = child.transform.Find("Heigh").GetComponent<InputField>().text;
if (childIntro == null || childIntro == "")
{
child.transform.Find("Heigh").GetComponent<InputField>().text = "0";
}
}
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("CollectCarAttri");
MessageDispatcher.SendMessage("SetCarMessage");
MessageDispatcher.SendMessage("Operatinghints", (object)"编辑成功");
this.gameObject.SetActive(false);
}
else
{
MessageDispatcher.SendMessage("Operatinghints", (object)"车辆最高可升100米");
}
}
public void InstanceItem()
{
for (int i = 0; i < CarTpyeList.Length; 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<CarItemAttribute>().Name.text = Name;
Game.GetComponent<CarItemAttribute>().carType = i;
if (i > 2)
{
Game.GetComponent<CarItemAttribute>().Heigh.text = "-";
Game.GetComponent<CarItemAttribute>().Heigh.enabled = false;
}
Game.name = Name;
}
}
public void ShowThePlane()
{
string name = "CarAttributeUI";
MessageDispatcher.SendMessage("OPEN", (object)name,"CUBE");
}
}