using System; using System.Collections; using System.Collections.Generic; using LitJson; using UnityEngine; using UnityEngine.UI; //天赋 public partial class HeroUIManager : GameSystemManager { public int normalGiftMaxCnt = 4; //初始天赋格子数 public const int giftMaxCnt = 8; //关联界面排版问题,暂时写死,通过觉醒可以增加上限 public int maxGiftLevel; //单天赋最高等级,其他功能可能会增加这个上限 public int starLevelCanAwake; //x星可以觉醒 public int washItemID; public int[] washByLockUseCounts; public int canWashStarLevel; //达到X星可以洗练 public string selectHeroGuidForGiftFunc;//武将主体GUID public int eatHeroIDForResult; //等待吞噬结果武将ID 为了弹成功界面使用 public string selectHeroGuidForGiftFuncForSuccessWin; //等待服务器返回的武将GUID 显示成功界面内容 public List heroBeforeGiftIDList = new List(); //会有重复的ID,不要用字典 public List heroBeforeGiftLevelList = new List(); public event Action SelectEatHeroEvent; string m_SelectEatHeroGuid; //被吞噬武将GUID public string selectEatHeroGuid { get { return m_SelectEatHeroGuid; } set { m_SelectEatHeroGuid = value; SelectEatHeroEvent?.Invoke(); } } #region 洗炼 public string selectWashHeroGUID; //被洗练武将GUID public Action changeLockEvent; #endregion public List heroEatList = new List(); void ParseGiftConfig() { var config = FuncConfigConfig.Get("HeroStarTalent"); normalGiftMaxCnt = int.Parse(config.Numerical1); maxGiftLevel = int.Parse(config.Numerical2); starLevelCanAwake = int.Parse(config.Numerical4); config = FuncConfigConfig.Get("HeroWash"); washItemID = int.Parse(config.Numerical1); washByLockUseCounts = JsonMapper.ToObject(config.Numerical2); canWashStarLevel = int.Parse(config.Numerical3); } //根据天赋锁状态获取消耗的材料数量 public int GetTalentLockUseWashCount(HeroInfo hero) { int heroTalentLockCount = hero.GetTalentLockCount(); //不够取最后一个 if (heroTalentLockCount >= washByLockUseCounts.Length) { heroTalentLockCount = washByLockUseCounts.Length - 1; } return washByLockUseCounts[heroTalentLockCount]; } //天赋格子总数上限 public int GetGiftGirdMaxCount(int heroID) { //没有觉醒配置的 为默认4,否则8 if (HeroAwakeConfig.GetHeroAwakeConfig(heroID, 1) == null) { return Instance.normalGiftMaxCnt; } return giftMaxCnt; } //星最终上限由品质 和 觉醒决定 public int GetMaxStarCount(int heroID, int quality) { if (HeroAwakeConfig.GetHeroAwakeConfig(heroID, 1) == null) { return HeroQualityConfig.Get(quality).InitStarUpper; } //根据觉醒累计提升星上限 int addStarCount = 0; for (int i = 1; i <= HeroAwakeConfig.GetMaxAwakeLV(heroID); i++) { addStarCount += HeroAwakeConfig.GetHeroAwakeConfig(heroID, i).AddStarUpper; } return HeroQualityConfig.Get(quality).InitStarUpper + addStarCount; } //beforeGiftIDList用于对比变化的天赋格子 public void RefreshGiftCell(GiftBaseCell[] giftBaseCells, HeroInfo hero, List beforeGiftIDList = null, List beforeGiftLevelList = null) { int showCount = GetGiftGirdMaxCount(hero.heroId); for (int i = 0; i < giftBaseCells.Length; i++) { if (i >= showCount) { giftBaseCells[i].SetActive(false); continue; } giftBaseCells[i].SetActive(true); if (i < hero.talentIDList.Count) { int giftID = hero.talentIDList[i]; int giftLV = hero.talentLvList[i]; int state = 0; //0:不显示 1:新增 2:提升 if (!beforeGiftIDList.IsNullOrEmpty()) { if (i >= beforeGiftIDList.Count) { state = 1; } else { if (giftID != beforeGiftIDList[i]) { state = 1; } else { if (giftLV > beforeGiftLevelList[i]) { state = 2; } } } } giftBaseCells[i].Init(giftID, giftLV, state, hero.heroId, i, hero.awakeLevel); } else { if (!beforeGiftIDList.IsNullOrEmpty()) { //对比情况下不显示 giftBaseCells[i].SetActive(false); continue; } //非对比的显示 if (i < normalGiftMaxCnt) { giftBaseCells[i].Init(0, 0); } else { giftBaseCells[i].Init(-1, 0, 0, hero.heroId, i); } } } } public void CacheHeroEatList() { heroEatList = PackManager.Instance.GetSinglePack(PackType.Hero).GetItemGUIDListById( HeroManager.Instance.GetHero(selectHeroGuidForGiftFunc).heroId); heroEatList.Remove(selectHeroGuidForGiftFunc); //排除吞噬主体 heroEatList.Sort(CmpDeleteHero); } public void ShowStarImg(int starCount, Image[] starImages, bool noStarShow = true) { int imgCount = starImages.Length; for (int i = 0; i < imgCount; i++) { if (starCount == 0 && i == 0) { if (noStarShow) { // 无星级 特殊处理 显示一个空星星 starImages[i].SetActive(true); starImages[i].SetSprite("herostar" + starCount); } else { starImages[i].SetActive(false); } } else if ((starCount - 1) % imgCount >= i) { starImages[i].SetActive(true); starImages[i].SetSprite("herostar" + (((starCount - 1) / imgCount) + 1) * imgCount); } else { starImages[i].SetActive(false); } } } // public ushort ItemIndex; //武将物品所在武将背包位置索引 // public byte LockCnt; // public byte[] LockTalentIndexs; //锁定天赋索引列表 // public byte OPType; // 操作类型:0-执行洗炼;1-替换原天赋;2-保留原天赋 public void SendWash(HeroInfo hero, byte opType) { var pack = new CB235_tagCSHeroWash(); pack.ItemIndex = (ushort)hero.itemHero.gridIndex; pack.LockCnt = (byte)hero.talentLockList.Count; pack.LockTalentIndexs = new byte[pack.LockCnt]; for (int i = 0; i < pack.LockCnt; i++) { pack.LockTalentIndexs[i] = (byte)hero.talentLockList[i]; } pack.OPType = opType; GameNetSystem.Instance.SendInfo(pack); } }