using System.Collections.Generic; namespace ET { public class OpenRoleInfosRankComponent : Entity, IAwake, IDestroy { //通过角色id存储 public Dictionary OpenRolesDic = new Dictionary(); //有序列表 public SortedList RankList = new SortedList(new OpenRoleRankInfoCompare()); } public class OpenRoleRankInfoCompare : IComparer { public int Compare(OpenRoleRankInfo a, OpenRoleRankInfo b) { if(a.IsDisposed || b.IsDisposed) { return 0; } int result = (int)(b.OfflineTimeSec - a.OfflineTimeSec); if (result != 0) { return result; } result = b.RoleLvl - a.RoleLvl; if (result != 0) { return result; } if (b.Id > a.Id) { return -1; } if (b.Id < a.Id) { result = 1; } return 0; } } }