using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
namespace Fort23.Mono
{
public static class HeroUITools
{
///
/// 根据星级,显示不同的数量的星星和样子
///
///
///
public static void SetStarShow(List stars, int starGrade)
{
// 最大星级展示个数(6星,只显示一颗星星,换颜色)
int maxShowStar = 5;
// 计算 当前星级 应该用什么星星的表现
int group = (starGrade - 1) / maxShowStar;
int i = 1;
foreach (GameObject star in stars)
{
SetStarImg(group, star);
// 根据星级显示星星
if (starGrade >= i)
{
star.SetActive(true);
}
else
{
star.SetActive(false);
}
i++;
}
}
private static void SetStarImg(int group, GameObject starObj)
{
MyImage image = starObj.GetComponent();
// 执行对应的逻辑 (0)GradeIcon_Star_s_Yellow (1)GradeIcon_Star_s_Premium
switch (group)
{
case 0: // n = 1~5
image.icon_name = "dec_star";
break;
case 1: // n = 6~10
image.icon_name = "dec_star";
break;
default: // 其他情况
image.icon_name = "dec_star";
break;
}
}
}
}