local UIHeroAppearanceFashion = UIViewClass() local EventSystem = require('Event/EventSystem') local SkillImagePath = ConstAssetPathConfig.SkillImagePath local AttrTypeId = { HP = 1, Atk = 2, Defense = 3, } local lvBuSpecialEffectID1 = 1301 local lvBuSpecialEffectID2 = 1302 local lvBuSpecialEffectID3 = 1303 local lvBuSpecialEffectID4 = 1304 local diaoChanSpecialEffectID = 3001 function UIHeroAppearanceFashion:OnOpened(context) self.appearanceDataList = {} self.curSpecialEffectID = CTL.Appearance.curSelectSpecialEffectId CTL.Appearance.curSelectSpecialEffectId = nil self.heroId = MDL.HeroSelect.curSelectHeroID self:RegistSystemEvent(EventID.UI_Appearance_Refresh, self.RefreshAppearanceCell) self:RegistSystemEvent(EventID.BagItem_Update, self.RefreshAppearanceInfo) self:RegistSystemEvent(EventID.FunctionUnlockUpdate, self.UpdateDyeEntry) self:RegistSystemEvent(EventID.UI_DyeAppearance_UpdateInfo, self.UpdateDyeEntry) if self.curSpecialEffectID then local specialEffectCfg = DataSheetManager.SkinSpecialData:GetDataByID(self.curSpecialEffectID) if specialEffectCfg then self.curAppearanceID = specialEffectCfg.HeroSkinID end else if context.fashionID then self.curAppearanceID = context.fashionID end end self.WearAppearanceID = MDL.HeroSelect.GetAppearanceIDByHeroID(self.heroId) if not self.curAppearanceID then self.curAppearanceID = self.WearAppearanceID end self.curIndex = 0 self:RefreshFashionList() end function UIHeroAppearanceFashion:OnClosed() EventSystem.Dispatch(EventID.UI_Appearance_ChangePreviewAppearance, MDL.HeroSelect.GetAppearanceIDByHeroID(MDL.HeroSelect.curSelectHeroID)) end function UIHeroAppearanceFashion:OnButtonClicked(comp) if comp == self.btn_Check then UIManager.OpenView(Const_UI_Lua.UIEnum.UICommonNoteView, {id = LuaConst.NoteID.HeroAppearance}) elseif comp == self.btn_Video then -- 播视频 UIManager.OpenView(Const_UI_Lua.UIEnum.UICommonPlayMovie, {MovieName = self.curAppearanceData.appearanceConfig.PromotionalVideo}) elseif comp == self.btn_ArrowLeft then if self.curIndex == 0 then CTL.Tips.AddTipsMsg(Const_IDS.IDS_Appearance_FirstOne) else self:ChangeAppearance(self.curIndex - 1) end elseif comp == self.btn_ArrowRight then if self.curIndex == #self.appearanceDataList - 1 then CTL.Tips.AddTipsMsg(Const_IDS.IDS_Appearance_LastOne) else self:ChangeAppearance(self.curIndex + 1) end elseif comp == self.Btn_ActiveItem then -- 激活消耗物品 UTL.ItemTips.ShowCommonTipsById(self.curAppearanceData.appearanceConfig.Activation) elseif comp == self.Btn_UpgradeItem then -- 升级消耗物品 UTL.ItemTips.ShowCommonTipsById(self.nextAppearanceLevelUpCfg.DemandItem) elseif comp == self.group_CP.group_SkillIcon[1].btn_Skill then self.group_CP.state_Select:SetState(0) self:RefreshSpecialEffectData(1) elseif comp == self.group_CP.group_SkillIcon[2].btn_Skill then self.group_CP.state_Select:SetState(1) self:RefreshSpecialEffectData(2) elseif comp == self.group_CP.btn_Active then self:TryActiveAppearanceSpecialEffect() elseif comp == self.group_CP.item.event_Click then local specialEffectCfg = DataSheetManager.SkinSpecialData:GetDataByID(self.curSpecialEffectID) UTL.ItemTips.ShowCommonTipsById(specialEffectCfg.ItemID) elseif comp == self.btn_DyeEntry then CTL.DyeAppearance.OpenMain(MDL.HeroSelect.curSelectHeroID, self.curAppearanceID) elseif comp == self.btn_CheckUpgrade then UIManager.OpenView(Const_UI_Lua.UIEnum.UICommonNoteView, {id = LuaConst.NoteID.HeroAppearanceAttr}) else if MDL.HeroSelect.IsHasHero(self.heroId) then if comp == self.btn_InitialEquip or comp == self.btn_Equip then -- 穿戴 MDL.Appearance.WearAppearanceRequest(self.curAppearanceData.appearanceID, self.heroId, MDL.Appearance.AppearanceType.Hero) elseif comp == self.btn_Upgrade then -- 升级 if UTL.Item.GetItemStockCount(self.nextAppearanceLevelUpCfg.DemandItem) >= self.nextAppearanceLevelUpCfg.DemandNum then MDL.Appearance.AppearanceLevelUpRequest(self.curAppearanceData.appearanceID, MDL.Appearance.AppearanceType.Hero) else CTL.Tips.AddTipsMsg(string.FormatByIdsId(Const_IDS.IDS_Guild_CommonFail1, UTL.Item.GetItemDataSpliceByType(self.nextAppearanceLevelUpCfg.DemandItem).Name)) end elseif comp == self.btn_Act then -- 激活 if UTL.Item.GetItemStockCount(self.curAppearanceData.appearanceConfig.Activation) >= 1 then MDL.Appearance.ActiveAppearanceRequest(self.curAppearanceData.appearanceID, MDL.Appearance.AppearanceType.Hero) MDL.Appearance.IsActive = true else CTL.Tips.AddTipsMsg(Const_IDS.IDS_Appearance_WeiHuoDe) end end else CTL.Tips.AddTipsMsg(Const_IDS.IDS_Hero_NotEngouh) end end end function UIHeroAppearanceFashion:OnValueChanged(comp, value) if comp == self.group_CP.toggle_Open then if value ~= MDL.Appearance.IsHasOpenSpecialEffect(self.heroId, self.curAppearanceID, self.curSpecialEffectID) then MDL.Appearance.OpenAppearanceSpecialEffectRequest(self.curAppearanceID, self.heroId, MDL.Appearance.AppearanceType.Hero, self.curSpecialEffectID) end end end --region ************ loop ScrollRect ******************* function UIHeroAppearanceFashion:OnCellInit(scrollRect, index, cellTable, data) -- 背景图 UTL.Color.SetQualityImageByType(cellTable.img_AppearanceBg, data.appearanceConfig.HeroQuality, UTL.Color.QualityType.AppearanceInfoBase) UIUtils.SetActive(cellTable.img_LvBg, not data.isOriginal) local useOriginal = data.isOriginal or data.appearanceConfig.IsBigImage UIUtils.SetActive(cellTable.img_AppearanceIcon, not useOriginal) UIUtils.SetActive(cellTable.img_AppearanceIcon_origin, useOriginal) if useOriginal then -- 如果是原始皮肤,那么显示有偏移的图片 UIUtils.SetImageByAssetBundle(cellTable.img_AppearanceIcon_origin, data.appearanceConfig.PreviewCardImage) else -- 如果是时装,那么显示没有设置偏移的图片 UIUtils.SetImageByAssetBundle(cellTable.img_AppearanceIcon, data.appearanceConfig.PreviewCardImage) end if not data.isOriginal then -- 皮肤名 UIUtils.SetLabelText(cellTable.txt_AppearanceName, Const_IDS[data.appearanceConfig.AppearanceName]) -- 皮肤等级 UIUtils.SetActive(cellTable.img_LvBg, data.appearanceLevel > 0) if data.appearanceLevel > 0 then UIUtils.SetLabel(cellTable.txt_Lv, data.appearanceLevel) end -- 等级底图 UTL.Color.SetQualityImageByType(cellTable.img_LvBg, data.appearanceConfig.HeroQuality, UTL.Color.QualityType.AppearanceLevelInfoBase) else -- 皮肤名 UIUtils.SetLabelText(cellTable.txt_AppearanceName, Const_IDS.IDS_Appearance_UI_ChuShiShiZhuang) end UIUtils.SetActive(cellTable.img_Unselected, not data.isActive) UIUtils.SetActive(cellTable.img_RedPoint, false) cellTable.effect_HeroAppearance:StopUIEffect() UIUtils.SetActive(cellTable.img_YelPoint, false) if data.appearanceID > 0 then if data.isActive then local isMax = DataSheetManager.HeroAppearanceLevelUp:GetDataLengthByHeroAppearanceID_Level(data.appearanceID) == data.appearanceLevel local isItemEnough = false if not isMax then self.nextAppearanceLevelUpCfg = DataSheetManager.HeroAppearanceLevelUp:GetDataByHeroAppearanceID_Level(data.appearanceID, data.appearanceLevel + 1) local curItemCount = UTL.Item.GetItemStockCount(self.nextAppearanceLevelUpCfg.DemandItem) isItemEnough = curItemCount >= self.nextAppearanceLevelUpCfg.DemandNum end if not MDL.HeroSelect.IsHasHero(self.heroId) then UIUtils.SetActive(cellTable.img_RedPoint, false) elseif CTL.Appearance.IsCanActiveAppearanceSpecialEffect(self.heroId, data.appearanceID) then UIUtils.SetActive(cellTable.img_RedPoint, true) else if MDL.Player.HeroIsLineUp(self.heroId) then UIUtils.SetActive(cellTable.img_RedPoint, not isMax and isItemEnough) else UIUtils.SetActive(cellTable.img_RedPoint, false) UIUtils.SetActive(cellTable.img_YelPoint, not isMax and isItemEnough) end end --品质特效 UTL.Color.PlayQualityEffect(cellTable.effect_HeroAppearance, data.appearanceConfig.EffectID, UTL.Color.EffectType.Skin) else local curItemCount = UTL.Item.GetItemStockCount(data.appearanceConfig.Activation) UIUtils.SetActive(cellTable.img_RedPoint, MDL.HeroSelect.IsHasHero(self.heroId) and curItemCount >= 1) end local isSuccess, collectionAPData = DataSheetManager.CollectionAP:TryGetDataByID(data.appearanceID) if isSuccess then -- 典藏外观框 UIUtils.SetImageByAssetBundle(cellTable.img_AppearanceFrame, collectionAPData.AppearanceBase_Frame) cellTable.effect_CollectionAppearance:PlayUIEffect() else -- 外观框 UTL.Color.SetQualityImageByType(cellTable.img_AppearanceFrame, data.appearanceConfig.HeroQuality, UTL.Color.QualityType.AppearanceBase_Frame) cellTable.effect_CollectionAppearance:StopUIEffect() end else UTL.Color.SetQualityImageByType(cellTable.img_AppearanceFrame, data.appearanceConfig.HeroQuality, UTL.Color.QualityType.AppearanceBase_Frame) end end function UIHeroAppearanceFashion:OnCellSelect(scrollRect, index, cellTable, data) self:ChangeAppearance(index) end function UIHeroAppearanceFashion:OnCellMoveCenter(scrollRect, index, cellTable, data) self:ChangeAppearance(index) end --endregion ************ loop ScrollRect ******************* function UIHeroAppearanceFashion:IsWearAppearance(showAppearanceId) CTL.HeroSelect.ShowHeroExpression(self.heroId, showAppearanceId) CTL.HeroSelect.SetIsHeroAppearanceViewToHeroShow(true) end function UIHeroAppearanceFashion:RefreshAppearanceInfo() self.curAppearanceData = MDL.Appearance.GetAppearanceDataByHeroID_AppearanceID(self.heroId, self.curAppearanceID, MDL.Appearance.AppearanceType.Hero) self.state_Appearance:SetState(self.curAppearanceID == 0 and 0 or 1) if self.curAppearanceID == 0 then self.state_OriginalIsWear:SetState(self.WearAppearanceID == self.curAppearanceID and 0 or 1) UIUtils.SetActive(self.btn_Video, false) -- 播视频按钮 else self.state_Attr:SetState(self.curAppearanceData.isActive and 1 or 0) self.state_ActiveOrLevelUp:SetState(self.curAppearanceData.isActive and 1 or 0) self.state_Equipped:SetState(self.WearAppearanceID == self.curAppearanceID and 1 or 0) UIUtils.SetActive(self.btn_Video, self.curAppearanceData.appearanceConfig.PromotionalVideo ~= "") -- 播视频按钮 local extraAttr = CTL.DyeAppearance.GetSuitExtraAttr(self.curAppearanceData.appearanceID) if extraAttr and table.getDictCount(extraAttr) > 3 then UIUtils.SetActive(self.cell_Extra.gameObject, true) for i, v in pairs(extraAttr) do if i ~= AttrTypeId.HP and i ~= AttrTypeId.Defense and i ~= AttrTypeId.Atk then UTL.Attr.SetAttrIcon(self.cell_Extra.img_Extra, i) local attrData = DataSheetManager.AttrData:GetDataByID(i) UIUtils.SetLabelText(self.cell_Extra.lab_Extra, Const_IDS[attrData.Name]) self.cell_Extra.txt_ExtraValue.text = UTL.Attr.FormatNumberToPercentage(v, 0) break end end else UIUtils.SetActive(self.cell_Extra.gameObject, false) end if self.curAppearanceData.isActive then local appearanceLevelUpCfg if self.curAppearanceData.appearanceLevel == 0 then appearanceLevelUpCfg = self.curAppearanceData.appearanceConfig else appearanceLevelUpCfg = DataSheetManager.HeroAppearanceLevelUp:GetDataByHeroAppearanceID_Level(self.curAppearanceData.appearanceID, self.curAppearanceData.appearanceLevel) end local isMax = DataSheetManager.HeroAppearanceLevelUp:GetDataLengthByHeroAppearanceID_Level(self.curAppearanceData.appearanceID) == self.curAppearanceData.appearanceLevel self.state_IsMax:SetState(isMax and 0 or 1) if isMax then self.state_Attr:SetState(2) for k, v in ipairs(appearanceLevelUpCfg.Attr_Table) do local value = v.AttrNum if extraAttr then value = value + extraAttr[v.AttrType] end if v.AttrType == AttrTypeId.HP then UIUtils.SetLabel(self.cell_Hp.txt_Hp1, "+" .. value) elseif v.AttrType == AttrTypeId.Atk then UIUtils.SetLabel(self.cell_Atk.txt_Atk1, "+" .. value) elseif v.AttrType == AttrTypeId.Defense then UIUtils.SetLabel(self.cell_Defense.txt_Defense1, "+" .. value) end end else for k,v in ipairs(appearanceLevelUpCfg.Attr_Table) do if v.AttrType == AttrTypeId.HP then UIUtils.SetLabel(self.cell_Hp.txt_Hp, v.AttrNum) elseif v.AttrType == AttrTypeId.Atk then UIUtils.SetLabel(self.cell_Atk.txt_Atk, v.AttrNum) elseif v.AttrType == AttrTypeId.Defense then UIUtils.SetLabel(self.cell_Defense.txt_Defense, v.AttrNum) end end self.nextAppearanceLevelUpCfg = DataSheetManager.HeroAppearanceLevelUp:GetDataByHeroAppearanceID_Level(self.curAppearanceData.appearanceID, self.curAppearanceData.appearanceLevel + 1) for k, v in ipairs(self.nextAppearanceLevelUpCfg.Attr_Table) do local value = v.AttrNum if extraAttr then value = value + extraAttr[v.AttrType] end if v.AttrType == AttrTypeId.HP then UIUtils.SetLabel(self.cell_Hp.txt_Hp1, value) elseif v.AttrType == AttrTypeId.Atk then UIUtils.SetLabel(self.cell_Atk.txt_Atk1, value) elseif v.AttrType == AttrTypeId.Defense then UIUtils.SetLabel(self.cell_Defense.txt_Defense1, value) end end -- 升级消耗道具数量 local curItemCount = UTL.Item.GetItemStockCount(self.nextAppearanceLevelUpCfg.DemandItem) local itemData = DataSheetManager.ItemData:GetDataByID(self.nextAppearanceLevelUpCfg.DemandItem) UTL.Item.ItemIconByName(self.img_UpgradeIcon, itemData.Icon) local count if curItemCount >= self.nextAppearanceLevelUpCfg.DemandNum then count = UTL.Color.FormatGreenColor(curItemCount).."/"..self.nextAppearanceLevelUpCfg.DemandNum else count = UTL.Color.FormatRedColor(curItemCount).."/"..self.nextAppearanceLevelUpCfg.DemandNum end UIUtils.SetLabel(self.txt_UpgradeNum, count) local isShowRp = MDL.HeroSelect.IsHasHero(self.heroId) and curItemCount >= self.nextAppearanceLevelUpCfg.DemandNum if MDL.Player.HeroIsLineUp(self.heroId) then self.btn_Upgrade:SetRedPoint(isShowRp) UIUtils.SetActive(self.img_YelPoint, false) else self.btn_Upgrade:SetRedPoint(false) UIUtils.SetActive(self.img_YelPoint, isShowRp) end end else for k,v in ipairs(self.curAppearanceData.appearanceConfig.Attr_Table) do local value = v.AttrNum if extraAttr then value = value + extraAttr[v.AttrType] end if v.AttrType == AttrTypeId.HP then UIUtils.SetLabel(self.cell_Hp.txt_Hp1, value) elseif v.AttrType == AttrTypeId.Atk then UIUtils.SetLabel(self.cell_Atk.txt_Atk1, value) elseif v.AttrType == AttrTypeId.Defense then UIUtils.SetLabel(self.cell_Defense.txt_Defense1, value) end end -- 激活道具数量 local curItemCount = UTL.Item.GetItemStockCount(self.curAppearanceData.appearanceConfig.Activation) local itemData = DataSheetManager.ItemData:GetDataByID(self.curAppearanceData.appearanceConfig.Activation) UTL.Item.ItemIconByName(self.img_ActIcon, itemData.Icon) local count if curItemCount >= 1 then count = UTL.Color.FormatGreenColor(curItemCount).."/"..1 else count = UTL.Color.FormatRedColor(curItemCount).."/"..1 end UIUtils.SetLabel(self.txt_ActNum, count) self.btn_Act:SetRedPoint(MDL.HeroSelect.IsHasHero(self.heroId) and curItemCount >= 1) end -- 穿戴生效 UIUtils.SetActive(self.group_Equip, self.curAppearanceData.appearanceConfig.Intelligence > 0 or self.curAppearanceData.appearanceConfig.TalentID > 0) if self.curAppearanceData.appearanceConfig.Intelligence > 0 or self.curAppearanceData.appearanceConfig.TalentID > 0 then -- 资质 UIUtils.SetActive(self.group_SkillInfo, self.curAppearanceData.appearanceConfig.Intelligence > 0) if self.curAppearanceData.appearanceConfig.Intelligence > 0 then local difference = self.curAppearanceData.appearanceConfig.Intelligence - DataSheetManager.HeroNum:GetDataByID(self.heroId).HeroIntelligence if self.curAppearanceData.isActive then difference = UTL.Color.FormatWhiteColor("+"..difference) else difference = UTL.Color.FormatGreenColor("+"..difference) end UIUtils.SetLabel(self.txt_Intelligence, difference) end -- 天赋 UIUtils.SetActive(self.group_SkillInfo, self.curAppearanceData.appearanceConfig.TalentID > 0) if self.curAppearanceData.appearanceConfig.TalentID > 0 then local passiveData = DataSheetManager.DevelopEffectData:GetDataByID(self.curAppearanceData.appearanceConfig.TalentID) UIUtils.SetImageByAssetBundle(self.img_Skill, string.format(SkillImagePath, passiveData.Icon)) local name, desc = MDL.HeroStar.GetTalentNameAndDesc(self.curAppearanceData.appearanceConfig.TalentID) if self.curAppearanceData.isActive then UIUtils.SetLabel(self.txt_SkillName, UTL.Color.FormatWhiteColor(name)) UIUtils.SetLabel(self.txt_SkillInfo, UTL.Color.FormatWhiteColor(desc)) else UIUtils.SetLabel(self.txt_SkillName, UTL.Color.FormatGreenColor(name)) UIUtils.SetLabel(self.txt_SkillInfo, UTL.Color.FormatGreenColor(desc)) end end end end self:CheckShowSpecialEffect() self:UpdateDyeEntry() end function UIHeroAppearanceFashion:UpdateAppearanceData() table.clearArray(self.appearanceDataList) local list = MDL.Appearance.GetAppearanceDataByHeroID(self.heroId, MDL.Appearance.AppearanceType.Hero) for i, v in ipairs(list) do if (v.isOriginal == true) or (v.appearanceConfig.UnlockTriggerID == 0 or MDL.Unlock.IsTriggerIdComplete(v.appearanceConfig.UnlockTriggerID)) then table.insert(self.appearanceDataList, v) end end end -- 刷新皮肤列表 function UIHeroAppearanceFashion:RefreshFashionList() -- 皮肤列表 self:UpdateAppearanceData() if self.appearanceDataList then for k,v in ipairs(self.appearanceDataList) do if self.curAppearanceID == v.appearanceID then self.curIndex = k - 1 break end end --CTL.Appearance.CurAppearanceIndex是C#中的索引,因此和Lua中table长度比需要+1 if CTL.Appearance.CurAppearanceIndex + 1 > #self.appearanceDataList then CTL.Appearance.CurAppearanceIndex = 0 end self.loop_Fashion:ReloadAll(self.appearanceDataList) else CTL.Appearance.CurAppearanceIndex = 0 end if MDL.Appearance.IsActive then AuxUtil.InitEnhanceScroll(self.loop_Fashion.transform, CTL.Appearance.CurAppearanceIndex > 0 and CTL.Appearance.CurAppearanceIndex or self.curIndex) MDL.Appearance.IsActive = false else AuxUtil.InitEnhanceScroll(self.loop_Fashion.transform, self.curIndex) end UIUtils.SetActive(self.btn_ArrowLeft, self.curIndex ~= 0) self:RefreshAppearanceInfo() end -- 刷新皮肤列表 function UIHeroAppearanceFashion:RefreshAppearanceCell(optType, id) self.WearAppearanceID = MDL.HeroSelect.GetAppearanceIDByHeroID(self.heroId) self.loop_Fashion:ClearCells() -- 皮肤列表 self:UpdateAppearanceData() if self.appearanceDataList then for k,v in ipairs(self.appearanceDataList) do if self.curAppearanceID == v.appearanceID then self.curIndex = k - 1 end self.loop_Fashion:AddData(v, 0) end end AuxUtil.InitEnhanceScroll(self.loop_Fashion.transform, self.curIndex) UIUtils.SetActive(self.btn_ArrowLeft, self.curIndex ~= 0) self:RefreshAppearanceInfo() if optType == MDL.Appearance.OptType.Active then self:IsWearAppearance(id) end end -- 切换皮肤预览 function UIHeroAppearanceFashion:ChangeAppearance(index) if self.curIndex == index then return end self.curIndex = index CTL.Appearance.CurAppearanceIndex = self.curIndex UIUtils.SetActive(self.btn_ArrowLeft, self.curIndex ~= 0) UIUtils.SetActive(self.btn_ArrowRight, self.curIndex ~= #self.appearanceDataList - 1) self.curAppearanceID = self.appearanceDataList[index + 1].appearanceID AuxUtil.SetCenterChildIndex(self.loop_Fashion.transform, self.curIndex) EventSystem.Dispatch(EventID.UI_Appearance_ChangePreviewAppearance, self.curAppearanceID) self:RefreshAppearanceInfo() self:UpdateDyeEntry() end --检测是否需要显示特殊效果 function UIHeroAppearanceFashion:CheckShowSpecialEffect() local dyeSpecialEffect, icon, skillName, isActive = CTL.DyeAppearance.GetDyeSpecialEffectDetail(self.curAppearanceID) if dyeSpecialEffect > 0 then self.group_CP.state_Select:SetState(0) UIUtils.SetActive(self.group_CP.gameObject, true) UIUtils.SetActive(self.group_CP.group_SkillIcon[2].gameObject, false) UIUtils.SetActive(self.group_CP.group_Active, false) UIUtils.SetActive(self.group_CP.group_Open, false) local cfg = DataSheetManager.HeroAppearance:GetDataByID(self.curAppearanceID) UIUtils.SetLabelText(self.group_CP.txt_Info, Const_IDS[cfg.SpecialIDS]) self.group_CP.UIState_Active:SetState(1) self.state_Attr:SetState(3) UIUtils.SetActive(self.btn_Check, false) UIUtils.SetLabelText(self.group_CP.group_SkillIcon[1].txt_SkillName, Const_IDS[skillName]) UIUtils.SetImageByAssetBundle(self.group_CP.group_SkillIcon[1].sprite_Skill, icon) UIUtils.SetActive(self.group_CP.group_SkillIcon[1].group_Locked, isActive == false) return end UIUtils.SetActive(self.btn_Check, true) local skinId = self.curAppearanceID local specialEffects = MDL.Appearance.GetAppearanceSpecialEffects(skinId) if specialEffects then UIUtils.SetActive(self.group_CP.gameObject, true) local selectIndex = 1 for index, specialEffectCfgId in ipairs(specialEffects) do UIUtils.SetActive(self.group_CP.group_SkillIcon[index].gameObject, true) local specialEffectCfg = DataSheetManager.SkinSpecialData:GetDataByID(specialEffectCfgId) UIUtils.SetLabelText(self.group_CP.group_SkillIcon[index].txt_SkillName, Const_IDS[specialEffectCfg.SpecialName]) UIUtils.SetImageByAssetBundle(self.group_CP.group_SkillIcon[index].sprite_Skill, specialEffectCfg.SpecialIcon) self.group_CP.group_SkillIcon[index].btn_Skill:SetRedPoint(CTL.Appearance.IsCanActiveAppearanceSpecialEffectBySpecailEffectCfgId(self.heroId, self.curAppearanceID, specialEffectCfgId)) UIUtils.SetActive(self.group_CP.group_SkillIcon[index].group_Locked, not CTL.Appearance.IsHasActiveSpecialEffect(self.heroId, self.curAppearanceID, specialEffectCfgId)) if self.curSpecialEffectID == specialEffectCfgId then selectIndex = index end end for index=#specialEffects+1, #self.group_CP.group_SkillIcon do UIUtils.SetActive(self.group_CP.group_SkillIcon[index].gameObject, false) end self:OnButtonClicked(self.group_CP.group_SkillIcon[selectIndex].btn_Skill) else UIUtils.SetActive(self.group_CP.gameObject, false) end end function UIHeroAppearanceFashion:RefreshSpecialEffectData(index) if CTL.DyeAppearance.GetDyeSpecialEffectDetail(self.curAppearanceID) > 0 then return end local specialEffects = MDL.Appearance.GetAppearanceSpecialEffects(self.curAppearanceID) self.curSpecialEffectID = specialEffects[index] local specialEffectCfg = DataSheetManager.SkinSpecialData:GetDataByID(specialEffects[index]) UIUtils.SetLabelText(self.group_CP.txt_Info, Const_IDS[specialEffectCfg.SpecialDes]) if CTL.Appearance.IsHasActiveSpecialEffect(self.heroId, self.curAppearanceID, self.curSpecialEffectID) then self.group_CP.UIState_Active:SetState(0) UIUtils.SetActive(self.group_CP.group_Active, false) if specialEffectCfg.IsControl then UIUtils.SetActive(self.group_CP.group_Open, true) local labText = "" if self.curSpecialEffectID == lvBuSpecialEffectID1 or self.curSpecialEffectID == diaoChanSpecialEffectID or self.curSpecialEffectID == lvBuSpecialEffectID3 then labText = Const_IDS.IDS_SkinSpecialData_1302_Open elseif self.curSpecialEffectID == lvBuSpecialEffectID2 or self.curSpecialEffectID == lvBuSpecialEffectID4 then labText = Const_IDS.IDS_SkinSpecialData_1301_Open end UIUtils.SetLabelText(self.group_CP.lab_Open, labText) self.group_CP.toggle_Open.isOn = MDL.Appearance.IsHasOpenSpecialEffect(self.heroId, self.curAppearanceID, self.curSpecialEffectID) else UIUtils.SetActive(self.group_CP.group_Open, false) end else UIUtils.SetActive(self.group_CP.group_Open, false) self.group_CP.UIState_Active:SetState(1) if specialEffectCfg.ActivityType == 1 then UIUtils.SetActive(self.group_CP.group_Active, false) elseif specialEffectCfg.ActivityType == 2 then UIUtils.SetActive(self.group_CP.group_Active, true) --道具激活 local hasItemCount = CTL.Bag.GetHasCountByItemCfgID(specialEffectCfg.ItemID) if hasItemCount>=specialEffectCfg.ItemNum then UTL.Item.SetItemCell(self.group_CP.item, specialEffectCfg.ItemID, UTL.Color.FormatGreenColor(hasItemCount) .."/"..specialEffectCfg.ItemNum) else UTL.Item.SetItemCell(self.group_CP.item, specialEffectCfg.ItemID, UTL.Color.FormatRedColor(hasItemCount) .."/"..specialEffectCfg.ItemNum) end end end end function UIHeroAppearanceFashion:TryActiveAppearanceSpecialEffect() local specialEffectCfg = DataSheetManager.SkinSpecialData:GetDataByID(self.curSpecialEffectID) --外观是否激活 if not self.curAppearanceData.isActive then CTL.Tips.AddTipsMsg(Const_IDS.IDS_ERRORCODE_1976_InfoCode_Special_NeedSkinAct) return end --道具是否够 local hasItemCount = CTL.Bag.GetHasCountByItemCfgID(specialEffectCfg.ItemID) if hasItemCount < specialEffectCfg.ItemNum then CTL.Tips.AddTipsMsg(Const_IDS.IDS_ERRORCODE_1011_InfoCode_Item_Not_Enough) return end MDL.Appearance.ActiveAppearanceSpecialEffectRequest(self.curAppearanceID, self.heroId, MDL.Appearance.AppearanceType.Hero, self.curSpecialEffectID) end function UIHeroAppearanceFashion:UpdateDyeEntry() if MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.DyeAppearance) == false then UIUtils.SetActive(self.btn_DyeEntry, false) return false end local showEntry = MDL.DyeAppearance.GetIsAppearanceActive(self.curAppearanceID) if showEntry then UIUtils.SetActive(self.btn_DyeEntry, true) self.btn_DyeEntry:SetRedPoint(CTL.DyeAppearance.CheckDyeAppearanceRed(self.curAppearanceID)) self.state_IsMax:SetState(2) else UIUtils.SetActive(self.btn_DyeEntry, false) end return showEntry end return UIHeroAppearanceFashion