OpenRoleInfosRankComponent.cs 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. using System.Collections.Generic;
  2. namespace ET
  3. {
  4. public class OpenRoleInfosRankComponent : Entity, IAwake, IDestroy
  5. {
  6. //通过角色id存储
  7. public Dictionary<long, OpenRoleRankInfo> OpenRolesDic = new Dictionary<long, OpenRoleRankInfo>();
  8. //有序列表
  9. public SortedList<OpenRoleRankInfo, long> RankList = new SortedList<OpenRoleRankInfo, long>(new OpenRoleRankInfoCompare());
  10. }
  11. public class OpenRoleRankInfoCompare : IComparer<OpenRoleRankInfo>
  12. {
  13. public int Compare(OpenRoleRankInfo a, OpenRoleRankInfo b)
  14. {
  15. if(a.IsDisposed || b.IsDisposed)
  16. {
  17. return 0;
  18. }
  19. int result = (int)(b.OfflineTimeSec - a.OfflineTimeSec);
  20. if (result != 0)
  21. {
  22. return result;
  23. }
  24. result = b.RoleLvl - a.RoleLvl;
  25. if (result != 0)
  26. {
  27. return result;
  28. }
  29. if (b.Id > a.Id)
  30. {
  31. return -1;
  32. }
  33. if (b.Id < a.Id)
  34. {
  35. result = 1;
  36. }
  37. return 0;
  38. }
  39. }
  40. }