123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284 |
- using System;
- using System.Collections.Generic;
- using Core.Utility;
- using Excel2Json;
- using Fort23.Core;
- using Fort23.UTool;
- using GameLogic.Bag;
- using GameLogic.Hero;
- using UnityEngine;
- using UnityEngine.UI;
- namespace Fort23.Mono
- {
- public static class HeroUITools
- {
-
-
-
-
- public static WidgetHero GetCloseHero(List<WidgetHero> widgetHeroes, WidgetHero widgetHero, bool isNext)
- {
- int idx = widgetHeroes.IndexOf(widgetHero);
- if (isNext && idx < widgetHeroes.Count - 1)
- {
- return widgetHeroes[idx + 1];
- }
- if (!isNext && idx > 0)
- {
- return widgetHeroes[idx - 1];
- }
- return null;
- }
-
-
- /// <summary>
- /// 获取技能参数
- /// </summary>
- /// <param name="skillConfig"></param>
- /// <returns></returns>
- public static object[] GetSkillParam(SkillConfig skillConfig)
- {
- object[] data = null;
- if (skillConfig.SkillType == 5)
- {
- data = new object[skillConfig.addPropertyValue.Length];
- for (int j = 0; j < skillConfig.addPropertyValue.Length; j++)
- {
- data[j] = skillConfig.addPropertyValue[j];
- }
- }
- else
- {
- data = new object[skillConfig.effectValue.Length];
- for (int j = 0; j < skillConfig.effectValue.Length; j++)
- {
- data[j] = skillConfig.effectValue[j];
- }
- }
- return data;
- }
- /// <summary>
- /// 是否显示职业装备的小红点
- /// </summary>
- /// <param name="zy"></param>
- /// <returns></returns>
- public static bool IsShowRedPointProEq(int zy)
- {
- if (PlayerManager.Instance.eqController.allBestEqDic != null)
- {
- if (PlayerManager.Instance.eqController.allBestEqDic.TryGetValue(zy, out var bestEq))
- {
- if (bestEq.Count > 0)
- {
- return true;
- }
- }
- }
- return false;
- }
-
- /// <summary>
- /// 更新对应职业的装备图标
- /// 该方法调用后,可以把装备了的职业装备, 显示到指定的UI(eqsUIObj)上
- /// </summary>
- /// <param name="zy">职业类型</param>
- /// <param name="eqsUIObj">装备的icon</param>
- public static async void UpdateZyEqIcon(int zy, List<object> eqsUIObj, string poolName = "eq", float size = 1, Action action = null)
- {
- List<ItemInfo> eqList = PlayerManager.Instance.eqController.equipZyEqDic[zy];
-
- for (int i=0; i < 5; i++)
- {
- bool empty = true;
- ItemInfo eqInfo = null;
- foreach (ItemInfo itemInfo in eqList)
- {
- if (itemInfo.eqInfo.basicEquipConfig.Type == i + 1)
- {
- empty = false;
- eqInfo = itemInfo;
- break;
- }
- }
-
- GameObject eqGo = eqsUIObj[0] as GameObject;
- WidgetItem eqItem = await UIManager.Instance.
- CreateGComponentForObject<WidgetItem>(eqGo, null, isInstance:true, poolName:poolName, root:eqGo.transform.parent.GetComponent<RectTransform>());
-
- eqItem.transform.localScale = new Vector3(size, size, size);
-
- if (empty)
- {
- // LogTool.Log(zy + "---" + i + "空");
- eqItem.SetEmpty(action);
- }
- else
- {
- eqItem.InitWidget(eqInfo, action);
- }
- eqItem.numObj.SetActive(false);
- }
- }
- public static string GetEquipmentIconName(ItemInfo eqItem)
- {
- int q = 1;
- if (eqItem.eqInfo.quality > 3 && eqItem.eqInfo.quality <= 4)
- {
- q = 2;
- }
- else if (eqItem.eqInfo.quality > 4)
- {
- q = 3;
- }
-
- string eqIcon = "icon_eq_" +
- eqItem.eqInfo.basicEquipConfig.profession + "_" +
- eqItem.eqInfo.basicEquipConfig.Type + "_" +
- q;
-
-
- // switch (eqItem.eqInfo.basicEquipConfig.profession)
- return eqIcon;
- }
-
- /// <summary>
- /// 根据星级,显示不同的数量的星星和样子
- /// </summary>
- /// <param name="stars"></param>
- /// <param name="starGrade"></param>
- public static void SetStarShow(List<object> stars, int starGrade)
- {
- // 最大星级展示个数(6星,只显示一颗星星,换颜色)
- int maxShowStar = 5;
- // 计算 当前星级 应该用什么星星的表现
- int group = (starGrade - 1) / maxShowStar;
- int i = 1;
- int showCount = (starGrade - 1) % maxShowStar + 1;
- foreach (GameObject star in stars)
- {
- SetStarImg(group, star);
- // 根据星级显示星星
- if (showCount >= i)
- {
- star.SetActive(true);
- }
- else
- {
- star.SetActive(false);
- }
- i++;
- }
-
- SimpleLayout.Layout(stars, LayoutType.Horizontal);
- }
-
- private static void SetStarImg(int group, GameObject starObj)
- {
- MyImage image = starObj.GetComponent<MyImage>();
- // 执行对应的逻辑 (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_2";
- break;
- default: // 其他情况
- LogTool.Error("超出设计表现");
- //image.icon_name = "dec_star";
- break;
- }
- }
- /// <summary>
- /// 是否展示"去升级"的引导
- /// </summary>
- /// <param name="heroInfo"></param>
- /// <returns></returns>
- public static bool IsLvUpShowGuild(HeroInfo heroInfo)
- {
- long totalExp = heroInfo.powerUpConfig.levelUpExp;
- for (int i = 1; i < 10; i++)
- {
- HeroPowerUpConfig powerUpConfig =
- ConfigComponent.Instance.Get<HeroPowerUpConfig>(heroInfo.promoteConfig.ID + i);
-
- totalExp += powerUpConfig.levelUpExp;
- }
-
- if (BagController.Instance.IsEnough(GlobalParam.Item_HeroExp_ID, totalExp) &&
- heroInfo.level.Value - PlayerManager.Instance.heroController.mainLevel < 10)
- {
- return true;
- }
- return false;
- }
-
- /// <summary>
- /// 打开对应职业的装备面板
- /// </summary>
- /// <param name="zy">1战士;2法师;3牧师;4游侠</param>
- public static async void OpenSpecificProfessionEquipmentPanel(int zy, Action action = null)
- {
- SpecificProfessionEquipmentPanel specificProfessionEquipmentPanel
- = await UIManager.Instance.LoadAndOpenPanel<SpecificProfessionEquipmentPanel>(null);
- specificProfessionEquipmentPanel.InitPanel(zy, action);
- }
-
- /// <summary>
- /// 修改指定 GameObject 和其所有子对象的 Layer
- /// </summary>
- /// <param name="obj">目标 GameObject</param>
- /// <param name="newLayer">新的 Layer 值</param>
- public static void ChangeLayerRecursively(GameObject obj, int newLayer)
- {
- if (obj == null || obj.layer == newLayer) return;
- // 修改当前对象的 Layer
- obj.layer = newLayer;
- // 遍历所有子对象,递归修改
- foreach (Transform child in obj.transform)
- {
- ChangeLayerRecursively(child.gameObject, newLayer);
- }
- }
- public static string GetZyIcon(int zy)
- {
- string iconZhiYe = "";
- switch (zy)
- {
- case 1 :
- iconZhiYe = "icon_zy_Shield";
- break;
- case 2 :
- iconZhiYe = "icon_zy_Hat";
- break;
- case 3 :
- iconZhiYe = "icon_zy_Potion";
- break;
- case 4 :
- iconZhiYe = "icon_zy_Bow";
- break;
- }
-
- return iconZhiYe;
- }
-
- }
- }
|