12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- using static Manager;
- public class DianLiItem : MonoBehaviour
- {
- public JiLongItem item1;
- public JiLongItem item2;
- public Text sname;
- public Text zgl;
- public Text srdl;
- public int index;
- ServerRoomData srd;
- public static List<JiLongItem> jiLongItems = new List<JiLongItem>();
- public void updateData(ServerRoomData srd,int i)
- {
- this.srd = srd;
- index = i;
- sname.text = srd.name;
- zgl.text = srd.zonggonglv.ToString("F2")+"kW";
- zgl.text = srd.shangridl.ToString("F2") + "kWh";
- if(index==0)
- {
- choose(true);
- }
- }
- public void choose(bool b)
- {
- if(b)
- {
- for (int i = 0; i < jiLongItems.Count; i++)
- {
- Destroy(jiLongItems[i].gameObject);
- }
- jiLongItems = new List<JiLongItem>();
- for (int i = 0; i < this.srd.jilonglist.Count; i++)
- {
- JiLongItem fz;
- if (this.srd.jilonglist[i].jiguilist.Count>2)
- {
- fz= GameObject.Instantiate(item2,item2.transform.parent);
- }
- else
- {
- fz = GameObject.Instantiate(item1, item1.transform.parent);
- }
- fz.gameObject.SetActive(true);
- fz.updateData(this.srd.jilonglist[i]);
- jiLongItems.Add(fz);
- }
- }
- }
- }
|