/// <summary> /// 重新排序成员列表 /// </summary> /// <param name="type"></param> private void resort(CorpsSortType type) { if (type == CorpsSortType.None) { return; } if (LastSortType == type) { isDescend = !isDescend; //先修改这个否则箭头会错 } LastSortType = type; List <CorpsMember> memberList = CorpsMgr.Instance.CorpsMemberList; memberList.Sort((CorpsMember a, CorpsMember b) => { int mainRet = sortByType(type, a, b); if (mainRet != 0) { return(mainRet); } else { foreach (int sortType in System.Enum.GetValues(typeof(CorpsSortType))) { CorpsSortType t = (CorpsSortType)sortType; if (t == CorpsSortType.None || t == type) { continue; } int sortRet = sortByType(t, a, b); if (sortRet != 0) { return(sortRet); } } return(0); } }); this.mView.InitMemberList(); }
public void UpdateSortUI(CorpsSortType sortType, bool isDescend) { this.level_sort_rect.gameObject.SetActive(false); this.job_sort_rect.gameObject.SetActive(false); this.vigour_sort_rect.gameObject.SetActive(false); this.donate_sort_rect.gameObject.SetActive(false); this.lastol_sort_rect.gameObject.SetActive(false); switch (sortType) { case CorpsSortType.Level: this.level_sort_rect.gameObject.SetActive(true); this.level_sort_rect.localScale = isDescend ? Vector3.one : new Vector3(1, -1, 1); break; case CorpsSortType.Job: this.job_sort_rect.gameObject.SetActive(true); this.job_sort_rect.localScale = isDescend ? Vector3.one : new Vector3(1, -1, 1); break; case CorpsSortType.Vigour: this.vigour_sort_rect.gameObject.SetActive(true); this.vigour_sort_rect.localScale = isDescend ? Vector3.one : new Vector3(1, -1, 1); break; case CorpsSortType.Donate: this.donate_sort_rect.gameObject.SetActive(true); this.donate_sort_rect.localScale = isDescend ? Vector3.one : new Vector3(1, -1, 1); break; case CorpsSortType.LastOl: this.lastol_sort_rect.gameObject.SetActive(true); this.lastol_sort_rect.localScale = isDescend ? Vector3.one : new Vector3(1, -1, 1); break; default: break; } }
private int sortByType(CorpsSortType type, CorpsMember a, CorpsMember b) { switch (type) { case CorpsSortType.Level: return(a.Level < b.Level ? (isDescend ? 1 : -1) : ((a.Level > b.Level) ? (isDescend ? -1 : 1) : 0)); case CorpsSortType.Job: return(a.Job < b.Job ? (isDescend ? 1 : -1) : ((a.Job > b.Job) ? (isDescend ? -1 : 1) : 0)); case CorpsSortType.Vigour: return(a.Vigour < b.Vigour ? (isDescend ? 1 : -1) : ((a.Vigour > b.Vigour) ? (isDescend ? -1 : 1) : 0)); case CorpsSortType.Donate: return(a.Donate < b.Donate ? (isDescend ? 1 : -1) : ((a.Donate > b.Donate) ? (isDescend ? -1 : 1) : 0)); case CorpsSortType.LastOl: return(lastOl2SortType(a.LastOL) < lastOl2SortType(b.LastOL) ? (isDescend ? 1 : -1) : ((lastOl2SortType(a.LastOL) > lastOl2SortType(b.LastOL)) ? (isDescend ? -1 : 1) : 0)); default: return(0); } }