/// <summary> /// 比较a和b的大小,按照等级->稀有度->经验->出生日期 /// </summary> /// <param name="a"></param> /// <param name="b"></param> /// <returns>a大返回1,a小返回-1</returns> private int CompareAsLevel(HeroShowInfo a, HeroShowInfo b) { if (a.level != b.level) { if (a.level > b.level) { return(1); } else { return(-1); } } else { if (CompareRarity(a.rarity, b.rarity) != 0) { if (CompareRarity(a.rarity, b.rarity) > 0) { return(1); } else { return(-1); } } else { if (a.exp >= b.exp) { return(1); } else { if (a.born > b.born) { return(1); } else { return(-1); } } } } }
/// <summary> /// 以折叠形式将所有式神展示到面板上 /// </summary> private void ShowHerosFold(string rarity, int star, string name) { //清除面板上所有信息 panel1.Controls.Clear(); heroShowInfos.Clear(); //御魂面板上,SP-SSR-SR-R-N顺序,稀有度相同的按照等级,等级相同的按照获得顺序,若两个相同类型的式神经验都是0则可以折叠显示 HeroShowInfo heroShowInfo = new HeroShowInfo(); int x = 0; int y = 0; int count = 0; //将式神信息放入list中 for (int i = 0; i < GlobalData.root.data.heroes.Count; i++) { if (rarity != string.Empty) { if (GlobalData.root.data.heroes[i].rarity != rarity) { continue; } } if (star != -1) { if (GlobalData.root.data.heroes[i].star != star) { continue; } } if (name != string.Empty) { if (!GameConfig.GetHeroName(GlobalData.root.data.heroes[i].hero_id).Contains(name)) { continue; } } heroShowInfo.hero_id = GlobalData.root.data.heroes[i].id; heroShowInfo.born = GlobalData.root.data.heroes[i].born; heroShowInfo.exp = GlobalData.root.data.heroes[i].exp; heroShowInfo.id = GlobalData.root.data.heroes[i].hero_id; heroShowInfo.level = GlobalData.root.data.heroes[i].level; heroShowInfo.name = GameConfig.GetHeroName(GlobalData.root.data.heroes[i].hero_id); heroShowInfo.rarity = GlobalData.root.data.heroes[i].rarity; heroShowInfo.star = GlobalData.root.data.heroes[i].star; heroShowInfo.awake = GlobalData.root.data.heroes[i].awake; heroShowInfo.count = 1; heroShowInfos.Add(heroShowInfo); } //对式神稀有度进行排序 for (int i = 0; i < heroShowInfos.Count - 1; i++) { for (int j = i + 1; j < heroShowInfos.Count; j++) { if (CompareAsLevel(heroShowInfos[i], heroShowInfos[j]) < 0) { HeroShowInfo temp = heroShowInfos[i]; heroShowInfos[i] = heroShowInfos[j]; heroShowInfos[j] = temp; } } } for (int i = 0; i < heroShowInfos.Count; i++) { if (heroShowInfos[i].rarity == "R" || heroShowInfos[i].rarity == "N") { continue; } HeroUserControl heroUserControl = new HeroUserControl(heroShowInfos[i]); x = (count % 10) * 126 + 10; y = (count - count % 10) / 10 * 159 + 10; heroUserControl.Location = new Point(x, y); heroUserControl.Tag = heroShowInfos[i].hero_id; panel1.Controls.Add(heroUserControl); count++; } }