public void SortByLevel() { DarkestSoundManager.PlayOneShot("event:/ui/town/sort_by"); System.Comparison <Hero> sorting = (x, y) => { int result = -x.Resolve.Level.CompareTo(y.Resolve.Level); return(result == 0 ? x.Name.CompareTo(y.Name) : result); }; DarkestDungeonManager.Campaign.Heroes.Sort(sorting); HeroSlots.Sort((x, y) => sorting(x.Hero, y.Hero)); for (int i = 0; i < HeroSlots.Count; i++) { HeroSlots[i].RectTransform.SetSiblingIndex(i); } }
public void SortByStress() { DarkestSoundManager.PlayOneShot("event:/ui/town/sort_by"); Comparison <Hero> sorting = (x, y) => { int result = x.Stress.CurrentValue.CompareTo(y.Stress.CurrentValue); return(result == 0 ? string.Compare(x.Name, y.Name, StringComparison.Ordinal) : result); }; DarkestDungeonManager.Campaign.Heroes.Sort(sorting); HeroSlots.Sort((x, y) => sorting(x.Hero, y.Hero)); for (int i = 0; i < HeroSlots.Count; i++) { HeroSlots[i].RectTransform.SetSiblingIndex(i); } }