using System; using System.Collections; using System.Collections.Generic; using Sfs2X.Entities; using Sfs2X.Entities.Data; using UnityEngine; using UnityEngine.UI; public class RoomData { #region Config private static string IDLabel = "i"; private static string OwnerLabel = "o"; private static string DurationLabel = "d"; private static string MaxPlayerLabel = "m"; private static string NameLabel = "n"; private static string StartTimeLabel = "s"; private static string EndTimeLabel = "e"; public TimeSpan RemainTime { get { if (IsSystemRoom) { return new TimeSpan(1, 0, 0, 0); } else { return EndTime.Subtract(StartTime); } } } public int ID; public int Duration; public int MaxPlayer; public long Owner; public bool IsSystemRoom; public string Name; public DateTime StartTime; public DateTime EndTime; #endregion public RoomData(ISFSObject arg) { ID = arg.GetInt(IDLabel); Owner = arg.GetLong(OwnerLabel); Duration = arg.GetInt(DurationLabel); MaxPlayer = arg.GetInt(MaxPlayerLabel); Name = arg.GetUtfString(NameLabel); StartTime = DateUtil.GetTimeFromSeconds(arg.GetLong(StartTimeLabel).ToString()); EndTime = DateUtil.GetTimeFromSeconds(arg.GetLong(EndTimeLabel).ToString()); if (ID == 1) IsSystemRoom = true; //Debug.Log(ID); //Debug.Log(Owner); //Debug.Log(Duration); //Debug.Log(MaxPlayer); //Debug.Log(Name); //Debug.Log(StartTime); //Debug.Log(EndTime); //Debug.Log(RemainHour); //Debug.Log(IsSystemRoom); } public PlazaRoomItem CreateItem() { PlazaRoomItem plazaRoomItem = ResourceManager.Get(ResourceLabel.PlazaRoomItem, Folder.UI, false, ResourceManager.Get(CanvasLabel.Z_Grid), false, ObjType.PlazaRoomItem, typeof(PlazaRoomItem)).GetComponent(); plazaRoomItem.Init(); return plazaRoomItem; } public static bool operator ==(RoomData r1, RoomData r2) { if (r1.ID == r2.ID) { return true; } else { return false; } } public static bool operator !=(RoomData r1, RoomData r2) { return !(r1 == r2); } public override bool Equals(object obj) { return this == (RoomData) obj; } public override int GetHashCode() { return ID.GetHashCode(); } } public class PlazaRoomItemLabel { public static string ID = "ID"; public static string Name = "Name"; public static string Status = "Status"; public static string Duration = "Duration"; public static string People = "People"; public static string SystemIconBK = "SystemIconBK"; public static string Btn = "Btn"; public static string BtnLab = "BtnLab"; } public class PlazaRoomItem : MonoBehaviour { #region Config public bool Inited; public RoomData RoomData; public Text ID; public Text Name; public Text Status; public Text Duration; public Text People; public Text ButtonLab; public Image SystemIconBK; public Button Button; #endregion public void Init() { if (Inited) return; else Inited = true; Dictionary dictionary = new Dictionary(); Auxiliary.CompileDic(transform, dictionary); ID = dictionary[PlazaRoomItemLabel.ID].GetComponent(); Name = dictionary[PlazaRoomItemLabel.Name].GetComponent(); Status = dictionary[PlazaRoomItemLabel.Status].GetComponent(); Duration = dictionary[PlazaRoomItemLabel.Duration].GetComponent(); People = dictionary[PlazaRoomItemLabel.People].GetComponent(); SystemIconBK = dictionary[PlazaRoomItemLabel.SystemIconBK].GetComponent(); Button = dictionary[PlazaRoomItemLabel.Btn].GetComponent