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.
88 lines
2.8 KiB
88 lines
2.8 KiB
3 years ago
|
using UnityEngine;
|
||
|
using System.Collections;
|
||
|
using UnityEngine.UI;
|
||
|
using AX.MessageSystem;
|
||
|
using AX.TrackRecord;
|
||
|
|
||
|
public class PowerScript : MonoBehaviour {
|
||
|
|
||
|
public Text Name;
|
||
|
public InputField Water;
|
||
|
public InputField PaoMo;
|
||
|
public InputField GanFen;
|
||
|
public InputField People;
|
||
|
public InputField Heigh;
|
||
|
public InputField Num;
|
||
|
public string TeamName="";
|
||
|
public Toggle toogle;
|
||
|
public bool Has = false;
|
||
|
void Start ()
|
||
|
{
|
||
|
Name = this.gameObject.transform.Find("Name").GetComponent<Text>();
|
||
|
Water = this.gameObject.transform.Find("Water").GetComponent<InputField>();
|
||
|
PaoMo = this.gameObject.transform.Find("PaoLiang").GetComponent<InputField>();
|
||
|
GanFen = this.gameObject.transform.Find("GanFen").GetComponent<InputField>();
|
||
|
People = this.gameObject.transform.Find("People").GetComponent<InputField>();
|
||
|
Heigh = this.gameObject.transform.Find("Heigh").GetComponent<InputField>();
|
||
|
Num = this.gameObject.transform.Find("Num").GetComponent<InputField>();
|
||
|
toogle = this.gameObject.transform.Find("Toggle").GetComponent<Toggle>();
|
||
|
Heigh.onValueChanged.AddListener(delegate { ValueChangeCheck(); });
|
||
|
}
|
||
|
|
||
|
public void ValueChangeCheck()
|
||
|
{
|
||
|
double num = double.Parse(Heigh.text);
|
||
|
if (num > 100)
|
||
|
{
|
||
|
Heigh.transform.Find("Text").GetComponent<Text>().color = Color.red;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
Heigh.transform.Find("Text").GetComponent<Text>().color = Color.black;
|
||
|
}
|
||
|
}
|
||
|
void OnDestroy()
|
||
|
{
|
||
|
MessageDispatcher.RemoveListener("ToggleIson", ToggleIson);
|
||
|
MessageDispatcher.RemoveListener("ToggleIsFlase", ToggleIsFlase);
|
||
|
}
|
||
|
void OnDisable()
|
||
|
{
|
||
|
MessageDispatcher.RemoveListener("ToggleIson", ToggleIson);
|
||
|
MessageDispatcher.RemoveListener("ToggleIsFlase", ToggleIsFlase);
|
||
|
}
|
||
|
void OnEnable()
|
||
|
{
|
||
|
MessageDispatcher.AddListener("ToggleIson", ToggleIson);
|
||
|
MessageDispatcher.AddListener("ToggleIsFlase", ToggleIsFlase);
|
||
|
}
|
||
|
public void ToggleIson(IMessage message)
|
||
|
{
|
||
|
toogle.isOn = true;
|
||
|
}
|
||
|
public void ToggleIsFlase(IMessage message)
|
||
|
{
|
||
|
toogle.isOn = false;
|
||
|
|
||
|
}
|
||
|
private PowerAttri attri;
|
||
|
public PowerAttri Attri
|
||
|
{
|
||
|
get
|
||
|
{
|
||
|
PowerAttri attri = new PowerAttri();
|
||
|
attri.CarName = Name.text;
|
||
|
attri.HasWater = int.Parse(Water.text);
|
||
|
attri.HasPaoMo = int.Parse(PaoMo.text);
|
||
|
attri.HasGanFen = int.Parse(GanFen.text);
|
||
|
attri.XFYCount = int.Parse(People.text);
|
||
|
attri.CarCount = int.Parse(Num.text);
|
||
|
attri.Hegih = Heigh.text;
|
||
|
attri.HasThisPower = toogle.isOn;
|
||
|
|
||
|
return attri;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|