1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- 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++)
- {
- try
- {
- Destroy(jiLongItems[i].gameObject);
- }
- catch
- {
- }
- }
- 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);
- }
- });
-
- }
- }
- }
|