local UIWeaponForgeSoulMain = UIViewClass() local lockStrColor1 = "4b4849" local lockStrColor2 = "635b56" local unlockStrColor1 = "522f0c" local unlockStrColor2 = "6c502f" local gradientTopColor = "#DFC688" local gradientBottomColor = "#FDF1D9" local whiteColor = "#ffffff" local lockRightSkillBg = ConstAssetPathConfig.LockRightSkillBg --未解锁时显示的技能底图 local lockRightSkillNameBg = ConstAssetPathConfig.LockRightSkillNameBg --未解锁时显示的技能名底图 local isSoulForthSkillIsOpen = DataSheetManager.ConstData:GetDataByID("WeaponForgeSoul4SkillIsOpen").BoolValue -- 天命第四个技能是否开启 function UIWeaponForgeSoulMain:OnOpened(context) self:RegistSystemEvent(EventID.UI_DivineWeapon_ForgeSoul_Update,self.RefreshUI) self.heroId = context.heroId self.forgeSoulData = DataSheetManager.MagicWeaponForgeSoulData:GetDataByMagicWeaponID(self.heroId).ForgeSoulSkill UTL.Item.ItemSquareIconByHeroId(self.heroId, self.img_Head, nil, nil, MDL.HeroAwaken.GetIsHeroAwaken(self.heroId)) self:RefreshSkillPlotInfo() self.curSelectedPlotIndex = CTL.DivineWeaponForgeSoul.GetDefaultSelectedSkill(self.heroId) self.curSelectedPlotskillLv = MDL.DivineWeaponForgeSoul.GetWeaponForgeSoulSkillLv(self.heroId, self.forgeSoulData[self.curSelectedPlotIndex]) self:RefreshSkillPlotSelect() end function UIWeaponForgeSoulMain:RefreshUI() self.curSelectedPlotskillLv = MDL.DivineWeaponForgeSoul.GetWeaponForgeSoulSkillLv(self.heroId, self.forgeSoulData[self.curSelectedPlotIndex]) self:RefreshSkillPlotInfo() self:RefreshSkillTopInfo() self:RefreshSkillDetailInfo() self:RefreshSkillUpLvInfo() end function UIWeaponForgeSoulMain:RefreshSkillPlotInfo() if MDL.DivineWeaponForgeSoul.IsWeaponSoulActive(self.heroId) then self.state_ForgeSoul:SetState(1) else self.state_ForgeSoul:SetState(0) end CTL.DivineWeaponForgeSoul.RefreshSoulFourLittlePoint(self.group_ForgeSoulFour, MDL.DivineWeaponForgeSoul.GetWeaponForgeSoulSkillsLv(self.heroId)) for index, groupSkill in ipairs(self.Group_SkillFour) do local skillLv = MDL.DivineWeaponForgeSoul.GetWeaponForgeSoulSkillLv(self.heroId, self.forgeSoulData[index]) local cfglv = skillLv == 0 and 1 or skillLv local skillcfg = DataSheetManager.MagicWeaponForgeSoulSkill:GetDataByForgeSoulSkillID_ForgeSoulSkillLevel(self.forgeSoulData[index], cfglv) local cfg = DataSheetManager.MagicWeaponForgeSoulEffect:GetDataByMagicWeaponForgeSoulSkillLevel(cfglv) UIUtils.SetImageByAssetBundle(groupSkill.img_BgQuailtyType, cfg.ForgeSoulSkillIconBG) UIUtils.SetImageByAssetBundle(groupSkill.img_SkillIcon, skillcfg.ForgeSoulSkillIcon) UIUtils.SetImageByAssetBundle(groupSkill.img_SkillIconBg, cfg.ForgeSoulSkillIconBG) UIUtils.SetActive(groupSkill.group_Lock, skillLv == 0) groupSkill.txt_SkillName.text = UIUtils.GetLocalizedTxt(Const_IDS[skillcfg.ForgeSoulSkillName]) groupSkill.btn_Choose:SetRedPoint(CTL.DivineWeaponForgeSoul.IsPlotCanLevelUp(self.heroId, index, skillLv)) end end function UIWeaponForgeSoulMain:RefreshSkillTopInfo() local cfglv = self.curSelectedPlotskillLv == 0 and 1 or self.curSelectedPlotskillLv local skillcfg = DataSheetManager.MagicWeaponForgeSoulSkill:GetDataByForgeSoulSkillID_ForgeSoulSkillLevel(self.forgeSoulData[self.curSelectedPlotIndex], cfglv) UIUtils.SetImageByAssetBundle(self.sprite_Skill, skillcfg.ForgeSoulSkillIcon) if self.curSelectedPlotskillLv == 0 then UIUtils.SetImageByAssetBundle(self.skill_bg2, lockRightSkillBg) UIUtils.SetImageByAssetBundle(self.skill_name_bg, lockRightSkillNameBg) else local cfg = DataSheetManager.MagicWeaponForgeSoulEffect:GetDataByMagicWeaponForgeSoulSkillLevel(cfglv) UIUtils.SetImageByAssetBundle(self.skill_bg2, cfg.ForgeSoulSkillIconBG2) UIUtils.SetImageByAssetBundle(self.skill_name_bg, cfg.ForgeSoulSkillNameBG) end UIUtils.SetActive(self.skill_mask, self.curSelectedPlotskillLv == 0) if self.curSelectedPlotskillLv == 0 then self.txt_SkillName.text = UIUtils.GetLocalizedTxt(Const_IDS[skillcfg.ForgeSoulSkillName]) UIUtils.SetTitleText(self.txt_SkillName, 28, whiteColor, whiteColor) self.txt_SkillLV.text = UTL.Color.FormatTextByColor(lockStrColor1, UIUtils.GetLocalizedTxt(Const_IDS.IDS_Store_Opt_NotActivate)) UIUtils.SetActive(self.skill_mask, true) else self.txt_SkillName.text = UIUtils.GetLocalizedTxt(Const_IDS[skillcfg.ForgeSoulSkillName]) UIUtils.SetTitleText(self.txt_SkillName, 28, gradientTopColor, gradientBottomColor) self.txt_SkillLV.text = UTL.Color.FormatTextByColor(unlockStrColor1, string.FormatByIdsId(Const_IDS["IDS_Resonance_Level"], self.curSelectedPlotskillLv)) UIUtils.SetActive(self.skill_mask, false) end end function UIWeaponForgeSoulMain:RefreshSkillDetailInfo() local basicDesIds = DataSheetManager.MagicWeaponForgeSoulData:GetDataByMagicWeaponID(self.heroId).ForgeSoulSkillName[self.curSelectedPlotIndex] if Localization.IsEnglish() or Localization.IsIndonesian() or Localization.IsThailand() then self.txt_SkillInfo.text = "" else if self.curSelectedPlotskillLv == 0 then self.txt_SkillInfo.text = UTL.Color.FormatTextByColor(lockStrColor1, UIUtils.GetLocalizedTxt(Const_IDS[basicDesIds])) else self.txt_SkillInfo.text = UTL.Color.FormatTextByColor(unlockStrColor1, UIUtils.GetLocalizedTxt(Const_IDS[basicDesIds])) end end for index, cfg in DataSheetManager.MagicWeaponForgeSoulSkill:GetDataByForgeSoulSkillID_ForgeSoulSkillLevel(self.forgeSoulData[self.curSelectedPlotIndex]) do local collection = self.group_skill_Info[index] local isMeet, str = CTL.DivineWeaponForgeSoul.IsMeetUpLvCondition(cfg.ForgeSoulSkillPictorialHeroNum, cfg.ForgeSoulSkillPictorialFoundryNum, index) if self.curSelectedPlotskillLv < index then collection.txt_SkillInfo.text = UTL.Color.FormatTextByColor(lockStrColor2, UTL.String.FormatCombineTextByID(cfg.ForgeSoulSkillDes)) collection.lab_LV.text = UTL.Color.FormatTextByColor(lockStrColor2, string.FormatByIdsId(Const_IDS["IDS_Resonance_Level"], index)) collection.txt_SkillCondition.text = str UIUtils.SetActive(collection.group_Conditon, true) else collection.txt_SkillInfo.text = UTL.Color.FormatTextByColor(unlockStrColor2, UTL.String.FormatCombineTextByID(cfg.ForgeSoulSkillDes)) collection.lab_LV.text =UTL.Color.FormatTextByColor(unlockStrColor2, string.FormatByIdsId(Const_IDS["IDS_Resonance_Level"], index)) UIUtils.SetActive(collection.group_Conditon, false) end end end function UIWeaponForgeSoulMain:RefreshSkillUpLvInfo() local skillId = self.forgeSoulData[self.curSelectedPlotIndex] local succ, skillcfg = DataSheetManager.MagicWeaponForgeSoulSkill:TryGetDataByForgeSoulSkillID_ForgeSoulSkillLevel(skillId, self.curSelectedPlotskillLv + 1) if succ then local isMeet = CTL.DivineWeaponForgeSoul.IsMeetUpLvCondition(skillcfg.ForgeSoulSkillPictorialHeroNum, skillcfg.ForgeSoulSkillPictorialFoundryNum, self.curSelectedPlotskillLv + 1) self.up_state:SetState(0) if self.curSelectedPlotskillLv == 0 then if GameAppInfo.IsJapanesePackage() then self.lab_Upgrade.text = UIUtils.GetLocalizedTxt(Const_IDS.IDS_ForgeActivate_JP) else self.lab_Upgrade.text = UIUtils.GetLocalizedTxt(Const_IDS.IDS_Bag_Item_Button_Activation) end else self.lab_Upgrade.text = UIUtils.GetLocalizedTxt(Const_IDS.IDS_GuildCultivation_Button_LevelUp) end for i, v in ipairs(self.group_Item) do UIUtils.SetActive(self.group_Item[i].gameObject, false) end for i, v in ipairs(skillcfg.Item_Table) do UTL.Item.SetItemCell(self.group_Item[i], v.ItemID, self:GetItemStr(v.ItemID,v.ItemNum)) UIUtils.SetActive(self.group_Item[i].gameObject, true) end self.btn_Upgrade:SetRedPoint(CTL.DivineWeaponForgeSoul.IsPlotCanLevelUp(self.heroId,self.curSelectedPlotIndex, self.curSelectedPlotskillLv)) UIUtils.SetActive(self.btn_mask, not isMeet) else self.up_state:SetState(2) self.txt_Tips.text = UIUtils.GetLocalizedTxt(Const_IDS.IDS_WeaponForgeSoul_LevelHint_6) end end function UIWeaponForgeSoulMain:GetItemStr(id,needCount) local haveCount = MDL.Bag.GetItemCount(id) if needCount<=haveCount then return UTL.Color.FormatQualityText(haveCount,1).."/"..needCount else self.itemNotEnough = true return UTL.Color.FormatRedColor(haveCount).."/"..needCount end end function UIWeaponForgeSoulMain:OnBackButtonPressed() self:OnButtonClicked(self.btn_Close) end function UIWeaponForgeSoulMain:OnButtonClicked(comp) if comp == self.btn_Close then self:CloseView(true) elseif comp == self.img_Info or comp == self.img_Info1 then UIManager.OpenView(Const_UI_Lua.UIEnum.UICommonNoteView, {id = LuaConst.NoteID.WeaponForgeSoul}) elseif comp == self.btn_Upgrade then self:OnClickUpgateBtn() elseif comp == self.group_ForgeSoul then UIManager.OpenView(Const_UI_Lua.UIEnum.UIWeaponForgeSoulInfo, {heroId = self.heroId}) elseif comp == self.group_Item[1].event_Click then local skillId = self.forgeSoulData[self.curSelectedPlotIndex] local skillcfg = DataSheetManager.MagicWeaponForgeSoulSkill:GetDataByForgeSoulSkillID_ForgeSoulSkillLevel(skillId, self.curSelectedPlotskillLv + 1) UTL.ItemTips.ShowCommonTipsById(skillcfg.Item_Table[1].ItemID) elseif comp == self.group_Item[2].event_Click then local skillId = self.forgeSoulData[self.curSelectedPlotIndex] local skillcfg = DataSheetManager.MagicWeaponForgeSoulSkill:GetDataByForgeSoulSkillID_ForgeSoulSkillLevel(skillId, self.curSelectedPlotskillLv + 1) UTL.ItemTips.ShowCommonTipsById(skillcfg.Item_Table[2].ItemID) else for index, groupSkill in ipairs(self.Group_SkillFour) do if comp == groupSkill.btn_Choose then self.curSelectedPlotIndex = index self.curSelectedPlotskillLv = MDL.DivineWeaponForgeSoul.GetWeaponForgeSoulSkillLv(self.heroId, self.forgeSoulData[self.curSelectedPlotIndex]) self:RefreshSkillPlotSelect() break end end end end function UIWeaponForgeSoulMain:OnClickUpgateBtn() local skillId = self.forgeSoulData[self.curSelectedPlotIndex] local skillcfg = DataSheetManager.MagicWeaponForgeSoulSkill:GetDataByForgeSoulSkillID_ForgeSoulSkillLevel(skillId, self.curSelectedPlotskillLv + 1) local isMeet = CTL.DivineWeaponForgeSoul.IsMeetUpLvCondition(skillcfg.ForgeSoulSkillPictorialHeroNum, skillcfg.ForgeSoulSkillPictorialFoundryNum, self.curSelectedPlotskillLv + 1) if not isMeet then CTL.Tips.AddTipsMsg(Const_IDS["IDS_WeaponForgeSoul_SoulHint_16"]) return end for i, v in ipairs(skillcfg.Item_Table) do local haveCount = MDL.Bag.GetItemCount(v.ItemID) if v.ItemNum > haveCount then if self.curSelectedPlotskillLv == 0 then CTL.Tips.AddTipsMsg(Const_IDS["IDS_WeaponForgeSoul_LevelHint_4"]) else CTL.Tips.AddTipsMsg(Const_IDS["IDS_WeaponForgeSoul_LevelHint_5"]) end return end end MDL.DivineWeaponForgeSoul.WeaponSoulLevelUpReq(self.heroId, skillId) end function UIWeaponForgeSoulMain:RefreshSkillPlotSelect() self:RefreshSkillTopInfo() self:RefreshSkillDetailInfo() self:RefreshSkillUpLvInfo() for index, groupSkill in ipairs(self.Group_SkillFour) do UIUtils.SetActive(groupSkill.img_Select, self.curSelectedPlotIndex == index) end local state = (self.curSelectedPlotIndex == 4 and not isSoulForthSkillIsOpen) and 0 or 1 self.forth_skill_state:SetState(state) end return UIWeaponForgeSoulMain