123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- 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";
- srdl.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>();
- DataManager.Instance.GetJL(this.srd.id, (data) =>
- {
- for (int i = 0; i < data.Count; i++)
- {
- JiLongItem fz;
- if (data[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(data[i]);
- jiLongItems.Add(fz);
- }
- });
-
- }
- }
- }
|