local UIHeroDetailInfo = UIViewClass() local SCROLL_SPEED = 0.6 --天赋滚动速度 function UIHeroDetailInfo:OnOpened(context) self.hplmtAttrData = DataSheetManager.AttrData:GetDataByID(LuaConst.AttrTypeId.hplmt) self.atkAttrData = DataSheetManager.AttrData:GetDataByID(LuaConst.AttrTypeId.atk) self.defAttrData = DataSheetManager.AttrData:GetDataByID(LuaConst.AttrTypeId.def) self:RegistSystemEvent(EventID.UI_HeroShow_UpdateHeroShow, self.RefreshHeroDetailInfoPanel) self:RegistSystemEvent(EventID.UI_LightEffect_Refresh, self.RefreshHeroDetailInfoPanel) self.currentSkillGroupIndex = 1 --当前显示的技能组索引 self:RefreshHeroDetailInfoPanel() end function UIHeroDetailInfo:OnButtonClicked(comp) local heroId = MDL.HeroSelect.curSelectHeroID if comp == self.event_BaseAttr then UIManager.OpenView(Const_UI_Lua.UIEnum.UIHeroDetailProperties, {showHeroId = heroId}) -- 武将详细属性界面 elseif comp == self.group_ActiveSkill.btn_Change then --切换技能展示 self.currentSkillGroupIndex = self.currentSkillGroupIndex + 1 if self.currentSkillGroupIndex > #self.activeSkillList then self.currentSkillGroupIndex = 1 end local heroId = MDL.HeroSelect.curSelectHeroID self:RefreshHeroSkills(heroId) elseif comp == self.group_HP then if GameAppInfo.IsVietnamPackage() then UIManager.OpenView(Const_UI_Lua.UIEnum.UIDescriptionPanel, { target = self.sprite_HP, posType = LuaConst.DescriptionPanelType.RightLower, offsetX = -400, text = Const_IDS[self.hplmtAttrData.AttrDesc] }) else UIManager.OpenView(Const_UI_Lua.UIEnum.UIDescriptionPanel, { target = self.sprite_HP, posType = LuaConst.DescriptionPanelType.RightLower, offsetX = -20, text = Const_IDS[self.hplmtAttrData.AttrDesc] }) end elseif comp == self.group_ATK then UIManager.OpenView(Const_UI_Lua.UIEnum.UIDescriptionPanel, { target = self.sprite_ATK, posType = LuaConst.DescriptionPanelType.RightLower, offsetX = -20, text = Const_IDS[self.atkAttrData.AttrDesc] }) elseif comp == self.group_DEF then UIManager.OpenView(Const_UI_Lua.UIEnum.UIDescriptionPanel, { target = self.sprite_DEF, posType = LuaConst.DescriptionPanelType.RightLower, offsetX = -20, text = Const_IDS[self.defAttrData.AttrDesc] }) elseif comp == self.obj_Country.btn_Country then UIManager.OpenView(Const_UI_Lua.UIEnum.UIHeroFilterView, {canJump = true, heroId = MDL.HeroSelect.curSelectHeroID, isCountry = true, heroFilterPos = self.obj_HeroFilterPos}) elseif comp == self.obj_Profession.btn_Profession then UIManager.OpenView(Const_UI_Lua.UIEnum.UIHeroFilterView, {canJump = true, heroId = MDL.HeroSelect.curSelectHeroID, isCountry = false, heroFilterPos = self.obj_HeroFilterPos}) else for index, cell in ipairs(self.group_ActiveSkill.cells) do if comp == cell.btn_Skill then CTL.Tips.OpenHeroSkillTips(self.ActiveSkillTips, heroId, self.activeSkillList[self.currentSkillGroupIndex][index], MDL.HeroAwaken.GetIsHeroAwaken(heroId)) return end end end end function UIHeroDetailInfo:RefreshHeroDetailInfoPanel() self.currentSkillGroupIndex = 1 --重置技能组索引 self.currentHeroSkillId = {} local heroId = MDL.HeroSelect.curSelectHeroID if MDL.HeroSelect.IsHasHero(MDL.HeroSelect.curSelectHeroID) then self:SetProperties(heroId) UIUtils.SetActive(self.Info_Properties, true) else UIUtils.SetActive(self.Info_Properties, false) end self:SetBaseAttrNumbers(heroId) self:RefreshHeroSkills(heroId) local heroData = DataSheetManager.HeroNum:GetDataByID(heroId) UIUtils.SetLabel(self.txt_heroIntroduction, UIUtils.GetLocalizedTxt(Const_IDS[heroData.Desc])) --设置英雄介绍 -- 武将国别 CTL.HeroSelect.SetHeroCountry(heroId, self.obj_Country) -- 武将职业 CTL.HeroSelect.SetHeroProfession(heroId, self.obj_Profession, true) end function UIHeroDetailInfo:RefreshHeroSkills(heroId) --武将技能 self.activeSkillList = MDL.HeroSelect.GetHeroDisplaySkillIdList(heroId) --多套技能显示切换展示按钮 local showChangeState = #self.activeSkillList > 1 and 0 or 1 self.group_ActiveSkill.state_Line:SetState(showChangeState) for index, cell in ipairs(self.group_ActiveSkill.cells) do local skillId = self.activeSkillList[self.currentSkillGroupIndex][index] if skillId == nil then UIUtils.SetActive(cell.gameObject,false) else UIUtils.SetActive(cell.gameObject,true) self:RefreshSkillIconShow(cell, heroId, skillId, false) end end -- 武将天赋 self.loop_PassiveSkills:ClearCells() local appearanceWearID = MDL.HeroSelect.GetAttrAppearanceIDByHeroID(heroId) self.passiveSkillList = MDL.HeroStar.GetCurrentDevelopEffectIdTableByHeroId(heroId) if MDL.HeroAwaken.GetIsHeroAwaken(heroId) then for i, v in ipairs(CTL.HeroAwaken.GetHeroAwakenTalent(heroId)) do self.loop_PassiveSkills:AddData(v, 0) end end if appearanceWearID > 0 then local appearanceData = DataSheetManager.HeroAppearance:GetDataByID(appearanceWearID) if appearanceData.TalentID > 0 then self.loop_PassiveSkills:AddData({heroId = heroId, skillId = appearanceData.TalentID, isAppearancePassiveSkill = true, appearanceData = appearanceData}, 0) end end for k,v in ipairs(self.passiveSkillList) do self.loop_PassiveSkills:AddData({heroId = heroId, skillId = v, isAppearancePassiveSkill = false}, 0) end end local SkillPath = ConstAssetPathConfig.SkillImagePath function UIHeroDetailInfo:RefreshSkillIconShow(cell, heroId, skillId, isPassive) local skillIcon, skillTips cell.txt_Level.text = 1 local isLock,currentSkillId,currentSkillLevel = MDL.HeroSelect.GetSkillTipsOfCurrentLevel(heroId,skillId) local skillData = DataSheetManager.SkillTipsData:GetDataByID(currentSkillId) if skillData then skillIcon = skillData.SkillIcon skillTips = skillData.SkillFuncType UIUtils.SetActive(cell.group_Locked, isLock) UIUtils.SetActive(cell.img_Level, not isLock) cell.txt_Level.text = currentSkillLevel if MDL.HeroAwaken.GetIsHeroAwaken(heroId) then UIUtils.SetImageByAssetBundle(cell.sprite_Skill, CTL.HeroAwaken.GetAwakenDisplaySkillIcon(heroId, skillId)) else UIUtils.SetImageByAssetBundle(cell.sprite_Skill, string.format(SkillPath, skillIcon)) end UIUtils.SetLabelText(cell.txt_SkillType, Const_IDS[skillTips]) if skillData.LevelUpType == 5 then UIUtils.SetActive(cell.img_Level, false) end end if not MDL.HeroSelect.IsHasHero(heroId) then UIUtils.SetActive(cell.group_Locked, false) UIUtils.SetActive(cell.img_LevelBg, false) UIUtils.SetActive(cell.img_Level, false) end end local nameTemp = "[%s]" function UIHeroDetailInfo:SetProperties(id) local heroLevel = MDL.HeroSelect.GetHeroLevelName(id) UIUtils.SetLabel(self.txt_Level, heroLevel) --设置英雄等级 local heroStar if MDL.HeroAwaken.GetIsHeroAwaken(id) then self.state_lab:SetState(1) heroStar = MDL.HeroAwaken.GetCurStar(id) else self.state_lab:SetState(0) heroStar = MDL.HeroStar.GetHeroStarLevel(id) end UIUtils.SetLabel(self.txt_Break, "+"..heroStar) local heroData = DataSheetManager.HeroNum:GetDataByID(id) local nameTxt = UTL.Color.FormatQualityText( string.format(nameTemp, UIUtils.GetLocalizedTxt(Const_IDS[heroData.NameIDS])), heroData.HeroQuality ) UIUtils.SetLabel(self.txt_Name, nameTxt) if MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.Advanced) then UIUtils.SetActive(self.group_Advance, true) local advancedData = DataSheetManager.HeroAdvance:GetDataByAdvanceID(MDL.Advanced.GetHeroAdvancedInfo(id)) local totalStar, lightStar = MDL.Advanced.GetStarInfoOfAdvanced(id) CTL.Advanced.InstantiateStarCell(self, self.group_Star[1].gameObject, self.group_Star, totalStar, lightStar, advancedData.StarColorIcon, advancedData.StarLockIcon) else UIUtils.SetActive(self.group_Advance, false) end end function UIHeroDetailInfo:SetBaseAttrNumbers(heroId) UIUtils.SetLabel(self.lab_HP, UIUtils.GetLocalizedTxt(Const_IDS[self.hplmtAttrData.Name])) UIUtils.SetLabel(self.lab_ATK, UIUtils.GetLocalizedTxt(Const_IDS[self.atkAttrData.Name])) UIUtils.SetLabel(self.lab_DEF, UIUtils.GetLocalizedTxt(Const_IDS[self.defAttrData.Name])) if MDL.HeroSelect.IsHasHero(heroId) then local totalAttrList = MDL.HeroDetail.GetTotalAttr(heroId) local heroGS = MDL.HeroSelect.GetHeroGs(heroId) -- 英雄基础属性 UIUtils.SetLabel(self.txt_CEPresent, heroGS) --设置英雄战力 UIUtils.SetLabel(self.txt_HPPresent, totalAttrList[LuaConst.AttrTypeId.hplmt]) --设置英雄生命值 UIUtils.SetLabel(self.txt_ATKPresent, totalAttrList[LuaConst.AttrTypeId.atk]) --设置英雄攻击力 UIUtils.SetLabel(self.txt_DEFPresent, totalAttrList[LuaConst.AttrTypeId.def]) --设置英雄防御力 UIUtils.SetActive(self.event_BaseAttr, true) else local heroAttrId local appearanceWearID = MDL.HeroSelect.GetAttrAppearanceIDByHeroID(heroId) if appearanceWearID > 0 then local appearanceData = DataSheetManager.HeroAppearance:GetDataByID(appearanceWearID) if appearanceData.HeroLevelAttrReplace > 0 then heroAttrId = appearanceData.HeroLevelAttrReplace else heroAttrId = DataSheetManager.HeroNum:GetDataByID(heroId).HeroLevelAttrID end else heroAttrId = DataSheetManager.HeroNum:GetDataByID(heroId).HeroLevelAttrID end local attr = DataSheetManager.HeroLevelAttr:GetDataByLevelUpAttrTypeID(heroAttrId).Break_Table[1] -- 英雄基础属性 UIUtils.SetLabel(self.txt_HPPresent, attr.HplmtInitial) --设置英雄生命值 UIUtils.SetLabel(self.txt_ATKPresent, attr.AtkInitial) --设置英雄攻击力 UIUtils.SetLabel(self.txt_DEFPresent, attr.DefInitial) --设置英雄防御力 UIUtils.SetLabel(self.txt_CEPresent, CTL.HeroSelect.CalculateHeroBasicGs(attr.HplmtInitial, attr.AtkInitial, attr.DefInitial)) --设置英雄战力 UIUtils.SetActive(self.event_BaseAttr, false) end end --region ************************* loop ************************ function UIHeroDetailInfo:OnValueChanged(comp, state) if state then if comp == self.toggle_2 then CTL.Tips.AddTipsMsg(Const_IDS["IDS_JiBan_NotOpen"]) self.toggle_1.isOn = true end end end function UIHeroDetailInfo:OnCellInit(scrollRect, index, cellTable, data) if scrollRect == self.loop_PassiveSkills then local passiveData = DataSheetManager.DevelopEffectData:GetDataByID(data.skillId) UIUtils.SetImageByAssetBundle(cellTable.sprite_Skill, string.format(SkillPath, passiveData.Icon)) UIUtils.SetActive(cellTable.img_Appearance, not not data.isAppearancePassiveSkill) local skillName, _ = MDL.HeroStar.GetTalentNameAndDesc(data.skillId) cellTable.txt_SkillName:SetScrollSpeed(SCROLL_SPEED) cellTable.txt_SkillName:SetText(skillName) if data.isAppearancePassiveSkill then UIUtils.SetActive(cellTable.group_Level, false) UIUtils.SetActive(cellTable.group_Locked, false) elseif data.isHeroAwakenTalent then local level = data.level local isUnlock = level > 0 UIUtils.SetActive(cellTable.group_Level, isUnlock) UIUtils.SetActive(cellTable.group_Locked, not isUnlock) if not isUnlock then UIUtils.SetLabel(cellTable.txt_Unlock, UIUtils.GetLocalizedTxt(Const_IDS.IDS_HeroAwaken_TianZi)) end UIUtils.SetLabel(cellTable.txt_Lv, level) else if MDL.HeroSelect.IsHasHero(data.heroId) then local level = MDL.HeroStar.GetHeroTalentLevel(data.heroId, data.skillId) local isUnlock, unlockStar = CTL.HeroStar.IsDevelopEffectUnlock(data.heroId, data.skillId) UIUtils.SetActive(cellTable.group_Level, level > 0 and isUnlock) UIUtils.SetActive(cellTable.group_Locked, not isUnlock) if not isUnlock then UIUtils.SetLabel(cellTable.txt_Unlock, "+" .. unlockStar .. UIUtils.GetLocalizedTxt(Const_IDS.IDS_AssistanceFight_UnlockButton)) end UIUtils.SetLabel(cellTable.txt_Lv, level) else UIUtils.SetActive(cellTable.group_Locked, false) UIUtils.SetActive(cellTable.group_Level, false) end end end end function UIHeroDetailInfo:OnCellClicked(scrollRect, index, cellTable, target, data) if scrollRect == self.loop_PassiveSkills then self.ActiveSkillTips:CloseAll() self.PassiveSkillTips:CloseAll() local talentType = CTL.Tips.TalentType.HeroStarTalent local extraData if data.appearanceData then talentType = CTL.Tips.TalentType.AppearanceTalent extraData = data.appearanceData elseif data.isHeroAwakenTalent then talentType = CTL.Tips.TalentType.HeroAwakenTalent extraData = {pointId = data.pointId} end CTL.Tips.OpenTalentTips(self.PassiveSkillTips, data.heroId, data.skillId, talentType, extraData) end end --endregion ************************* loop ************************ return UIHeroDetailInfo