--[[ 洗宠界面 ]]-- local UIPetSuccinct = UIViewClass() local LightLeft = ConstAssetPathConfig.LightLeft local LightRight = ConstAssetPathConfig.LightRight function UIPetSuccinct:OnCreated() UIUtils.SetActive(self.UIPetPopUp.btn_Info, false) UIUtils.SetActive(self.group_Before.model_Show, true) UIUtils.SetActive(self.group_After.model_Show, false) self.leftModelComponentHandle = UTL.UIRender.CreateModelComponentDatas(self.group_Before.model_Show) self.rightModelComponentHandle = UTL.UIRender.CreateModelComponentDatas(self.group_After.model_Show) end function UIPetSuccinct:OnOpened(context) UIManager.ActiveUIModle(false, "UIPetSuccinct") self.newCongenitalSkill = {} if self.UIPetPopUp.loc_Title.CurState == 0 then UIUtils.SetLocalizationImage(self.UIPetPopUp.img_Title, "UI_Pet/xc_msz.png") else UIUtils.SetLabelText(self.UIPetPopUp.txt_Title, Const_IDS.IDS_PetWash1) end self:RegistSystemEvent(EventID.UI_Pet_UpdatePetInfo, self.RefreshPanel) self:RegistSystemEvent(EventID.UI_Pet_UpdateGlobalInfo, self.UpdateTimesShow) self:RegistSystemEvent(EventID.BagItem_Update, self.UpdateCostMat) self:RegistSystemEvent(EventID.UI_CloseAndRecoverView, self.OnCloseAndRecoverView) self.petUniqueID = context.petUniqueID self:RefreshPanel() self:UpdateCostMat() end function UIPetSuccinct:OnClosed() UIManager.ActiveUIModle(true, "UIPetSuccinct") UIUtils.SetActive(self.UIPetPopUp.btn_Info, true) UTL.UIRender.DisposeModelComponentData(self.leftModelComponentHandle) UTL.UIRender.DisposeModelComponentData(self.rightModelComponentHandle) end function UIPetSuccinct:UpdateCostMat() local tempInfo = MDL.Pet.GetActiveInfo(self.petUniqueID) local cfg = DataSheetManager.PetTalentRefine:GetDataByTalentRefineID_ParentStar(tempInfo.Config.TalentRefineID, tempInfo.Info.petPedigree) self.refineCostTb = cfg.Item_Table[1] UTL.Item.ItemSquareIcon(self.icon_Cost, nil, self.refineCostTb.ItemID) local curCount = MDL.Bag.GetItemCount(self.refineCostTb.ItemID) or 0 local costCount = self.refineCostTb.ItemNum if curCount >= costCount then self.txt_Cost.text = UTL.Color.FormatGreenColor(UTL.String.GetCountStr(curCount)) .. "/" .. UTL.String.GetCountStr(costCount) else self.txt_Cost.text = UTL.Color.FormatRedColor(UTL.String.GetCountStr(curCount)) .. "/" .. UTL.String.GetCountStr(costCount) end self.isItemEnough = curCount >= costCount end function UIPetSuccinct:UpdateTimesShow() if self.petConfig then if self.petConfig.Stage == MDL.Pet.PetState.Basic then UIUtils.SetLabelText(self.txt_Info, Const_IDS.IDS_PetWash4) else UIUtils.SetLabelText(self.txt_Info, Const_IDS.IDS_PetWash9) end else UIUtils.SetLabel(self.txt_Info, nil) end end function UIPetSuccinct:RefreshPanel() self.isResultUp = false --洗炼结果是否提升 local tempInfo = MDL.Pet.GetActiveInfo(self.petUniqueID) self.petInfo, self.petConfig = tempInfo.Info, tempInfo.Config -- 左右信息 -- left self:SetPetInfo(self.group_Before, self.petConfig, self.petInfo, self.leftModelComponentHandle, false) --right if self.petInfo.hasUnSavePurifyInfo then UIUtils.SetActive(self.group_Before.btn_Save, true) UIUtils.SetActive(self.group_After.gameObject, true) UIUtils.SetActive(self.group_Empty, false) UIUtils.SetActive(self.group_After.model_Show, true) local newConfig = DataSheetManager.PetData:GetDataByID_Stage(self.petConfig.ID, self.petInfo.newPetVariation) self:SetPetInfo(self.group_After, newConfig, self.petInfo, self.rightModelComponentHandle, true) --箭头判断 local oldScore = CTL.Pet.GetGrowUpScore(self.petInfo.petAptitude, self.petInfo.petPedigree, false) local newScore = CTL.Pet.GetGrowUpScore(self.petInfo.newAptitude, self.petInfo.petPedigree, false) if oldScore < newScore then self.group_After.state_Arrow:SetState(0) self.isResultUp = true elseif oldScore > newScore then self.group_After.state_Arrow:SetState(1) else self.group_After.state_Arrow:SetState(2) end for i, v in ipairs(newConfig.Talent_Table) do self.group_After.Attr_arr[i].state_Arrow:SetState(2) local new, old = 0, 0 for _, item in ipairs(self.petInfo.newAptitude) do if item.aptitudeType == v.TalentType then new = item.aptitudeValue break end end for _, item in ipairs(self.petInfo.petAptitude) do if item.aptitudeType == v.TalentType then old = item.aptitudeValue break end end if new > old then self.group_After.Attr_arr[i].state_Arrow:SetState(0) elseif new < old then self.group_After.Attr_arr[i].state_Arrow:SetState(1) end end else UIUtils.SetActive(self.group_After.gameObject, false) UIUtils.SetActive(self.group_Empty, true) UIUtils.SetActive(self.group_Before.btn_Save, false) end self:UpdateCostMat() self:UpdateTimesShow() end function UIPetSuccinct:SetPetInfo(comp, petCfg, petInfo, modelHandle, isNew) local petPedigree = self.petInfo.petPedigree local congenitalSkill, aptitude, petVariation if isNew then table.clearArray(self.newCongenitalSkill) for i, v in ipairs(petInfo.newCongenitalSkill) do table.insert(self.newCongenitalSkill, v) end for i, v in ipairs(petInfo.childSkill) do table.insert(self.newCongenitalSkill, v) end aptitude, petVariation = petInfo.newAptitude, petInfo.newPetVariation table.sort(self.newCongenitalSkill, MDL.Pet.SortSkill) congenitalSkill = self.newCongenitalSkill else congenitalSkill, aptitude, petVariation = petInfo.congenitalSkill, petInfo.petAptitude, petInfo.petVariation end CTL.Pet.SetPetStar(comp.group_Star, petInfo.petPedigree, petInfo.petGeneration) -- 技能 CTL.Pet.SetTalentSkillGroup(comp.cells, congenitalSkill) -- 属性 CTL.Pet.SetPetAptitude(comp.Attr_arr, petInfo, petCfg, isNew) -- 变异 comp.state_Sign:SetState(petVariation == 0 and 1 or 0) -- 成长分 local maxScore = CTL.Pet.CalcuGrowUpScore(CTL.Pet.GetMaxAptitude(petCfg, petPedigree, false), petPedigree, false) UIUtils.SetLabel(comp.txt_BaseAttr, CTL.Pet.GetGrowUpScore(aptitude, petPedigree, false) .. "/" .. UTL.Color.FormatTextByColor("F9D33A", maxScore)) -- 形象 self:LoadModel(modelHandle, petCfg) end function UIPetSuccinct:OnClickPurify() if self.isItemEnough == false then -- 道具不足 CTL.Tips.AddTipsMsg(Const_IDS.IDS_PetWash7) return end if self.petInfo.hasUnSavePurifyInfo then if (self.petInfo.petVariation == MDL.Pet.PetState.Basic and self.petInfo.newPetVariation == MDL.Pet.PetState.Mutation) then UTL.MessageBox.ShowOKCancelBox(nil, Const_IDS.IDS_PetWash8, function() MDL.Pet.PurifyPetSaveReq(self.petUniqueID, true) end) return end if self.isResultUp then UTL.MessageBox.ShowOKCancelBox(nil, Const_IDS.IDS_Pet_ReplaceConfirm, function() MDL.Pet.PurifyPetSaveReq(self.petUniqueID, true) end, nil) return end end MDL.Pet.PurifyPetReq(self.petUniqueID) end function UIPetSuccinct:OnBackButtonPressed() self:OnButtonClicked(self.UIPetPopUp.btn_Close) end function UIPetSuccinct:OnButtonClicked(comp) if comp == self.UIPetPopUp.btn_Close then self:CloseView(true) elseif comp == self.bg_Cost then UTL.ItemTips.ShowCommonTipsById(self.refineCostTb.ItemID) elseif comp == self.group_Before.btn_Save then MDL.Pet.PurifyPetSaveReq(self.petUniqueID, false) elseif comp == self.group_After.btn_Change then MDL.Pet.PurifyPetSaveReq(self.petUniqueID, true) elseif comp == self.btn_Break then self:OnClickPurify() else for i, v in ipairs(self.group_Before.cells) do if comp == v.btn_Skill then CTL.Pet.ShowSkillTips(self.petInfo.congenitalSkill[i]) return end if comp == v.img_Locked then CTL.Pet.ShowSkillUnlockTips(i) return end end for i, v in ipairs(self.group_After.cells) do if comp == v.btn_Skill then CTL.Pet.ShowSkillTips(self.newCongenitalSkill[i]) return end if comp == v.img_Locked then CTL.Pet.ShowSkillUnlockTips(i) return end end for i, v in ipairs(self.group_Before.Attr_arr) do if comp == v.btn_Attr then CTL.Pet.ShowTalentDesc(self.petConfig, self.petInfo, i, comp) return end end for i, v in ipairs(self.group_After.Attr_arr) do if comp == v.btn_Attr then CTL.Pet.ShowTalentDesc(self.petConfig, self.petInfo, i, comp) return end end end end function UIPetSuccinct:LoadModel(handle, petCfg) if self.leftModelComponentHandle == handle then if self.leftModelID == petCfg.PetModelID then return end self.leftModelID = petCfg.PetModelID end if self.rightModelComponentHandle == handle then if self.rightModelID == petCfg.PetModelID then return end self.rightModelID = petCfg.PetModelID end UTL.UIRender.DisposePlayerModel(handle) if handle == self.leftModelComponentHandle then UTL.UIRender.CreateRTSceneTrans(handle, LightLeft) else UTL.UIRender.CreateRTSceneTrans(handle, LightRight) end local modelPath, modelScale, showEquipmentID, renderID, idleAnimCilp, heroEffectPath, psEffectPath, modelXYZ, modelRot = CTL.Pet.GetRenderTextureModelParam(petCfg, self.__viewClassPath) UTL.UIRender.CreateRTRenderModel(handle, modelPath, modelScale, showEquipmentID, renderID, idleAnimCilp, heroEffectPath, psEffectPath) UTL.UIRender.SetRTRootParam(handle, modelXYZ, modelRot) end return UIPetSuccinct