local UIPetReproduction = UIViewClass() local LightLeft = ConstAssetPathConfig.LightLeft local LightRight = ConstAssetPathConfig.LightRight local Const_Msg_Duration = 10 local Index_Double = 0 local Index_Single = 1 local State_OwnerSingle = 0 local State_OwnerUnLock_NoCouple = 1 local State_OwnerLocked_NoCouple = 2 local State_OwnerUnLock_CoupleUnChoose = 3 local State_OwnerLocked_CoupleUnChoose = 4 local State_OwnerUnLock_CoupleUnLock = 5 local State_OwnerLocked_CoupleUnLock = 6 local State_OwnerLocked_CoupleLocked = 7 local State_OwnerUnLock_CoupleLocked = 8 function UIPetReproduction:OnCreated() UIUtils.SetActive(self.group_My.group_Chat, false) UIUtils.SetActive(self.group_Other.group_Chat, false) UIUtils.SetActive(self.group_My.modelShow, true) self.group_My.obj_state:SetState(1) UIUtils.SetActive(self.UIPetPopUp.btn_Info, false) UIUtils.SetActive(self.UIPetPopUp.img_TitleBg, false) UIUtils.SetActive(self.UIPetPopUp.group_Title, false) UTL.Item.ItemSquareIcon(self.icon_Cost, nil, DataSheetManager.ConstData:GetDataByID("PetSingleBornItem").IntListValue[1]) self.isLockPet = false if self.UIPetPopUp.loc_Title.CurState == 0 then UIUtils.SetLocalizationImage(self.UIPetPopUp.img_Title, "UI_Pet/fz_bg_msz.png") else UIUtils.SetLabelText(self.UIPetPopUp.txt_Title, Const_IDS.IDS_PetReproduceTitle) end self.hasInitHandle = false self.modelComponentDataHandleLeft = UTL.UIRender.CreateModelComponentDatas(self.group_My.modelShow) self.modelComponentDataHandleRight = UTL.UIRender.CreateModelComponentDatas(self.group_Other.modelShow) self.loadedHandleTab = {} end function UIPetReproduction:OnOpened(context) UIManager.ActiveUIModle(false, "UIPetReproduction") --被其他界面push导致关闭的再pop返回来打开的,此时已经是不合法状态了,需要关闭 if CTL.Pet.GetIsBreedRoomValid() then self:CloseView(true) return end self:RegistSystemEvent(EventID.UI_Pet_ClosePetPanel, self.OnClosePanel) self:RegistSystemEvent(EventID.UI_Pet_ChooseBreedPet, self.OnChooseBreedPet) self:RegistSystemEvent(EventID.UI_Pet_LockBreedPet, self.OnBreedLock) self:RegistSystemEvent(EventID.UI_Pet_PushBreedInfo, self.UpdateBreedState) self:RegistSystemEvent(EventID.UI_Pet_UpdateGlobalInfo, self.OnGlobalInfoUpdate) self:RegistSystemEvent(EventID.BagItem_Update, self.UpdateLockMat) self:RegistSystemEvent(EventID.UI_RefreshCurrency, self.UpdateSingleCost) self:RegistSystemEvent(EventID.UI_Pet_ProcessBreedConfirmState, self.OnProcessBreedConfirmState) self:RegistSystemEvent(EventID.UI_CloseAndRecoverView, self.OnCloseAndRecoverView) self:RegistSystemEvent(EventID.UI_ChannelChat_OnReceiveNewMsg, self.OnReceiveNewMsg) self.chatRoot:OpenView(GetViewClass(Const_UI_Lua.UIEnum.UIBattleChatDlg), { isHideReminder = true }) self.isOwner = MDL.Pet.IsBreedRoomOwner() if self.isOwner then MDL.ChannelChat.JoinPetBreedChannel(BattleDataGetter.GetAcID()) UIUtils.SetActive(self.group_toogle, true) self.toggle_TopGroup:SelectIndex(Index_Double) if not context or not context.isCallbackInvitation then MDL.Pet.OpenPetBreedViewReq(true, context.petUniqId) end self.group_My.txt_Name.text = BattleDataGetter.GetPlayerName() CTL.Character.SetSelfPortraitAndFrame(self.group_My.herohead) else MDL.ChannelChat.JoinPetBreedChannel(MDL.Pet.GetRoomBreedInfo().playerAcid) UIUtils.SetActive(self.group_toogle, false) UIUtils.SetActive(self.group_Other.group_Name, true) self.group_Other.txt_Name.text = BattleDataGetter.GetPlayerName() CTL.Character.SetSelfPortraitAndFrame(self.group_Other.herohead) --加载房主信息 local breedInfo = MDL.Pet.GetRoomBreedInfo() self.group_My.txt_Name.text = breedInfo.playerName CTL.Character.SetPortraitAndFrame(self.group_My.herohead, breedInfo.playerPortrait, breedInfo.playerFrameId) end CTL.ChannelChat.SetLastSelectChannelChat(MDL.ChannelChat.ChannelCfgId.PetBreedChat) self:UpdateBagCells() self:UpdateLockMat() self:UpdateRewardInfo() self:UpdateSingleCost() self:UpdateBreedTimes() if context and string.isNilOrEmpty(context.petUniqId) == false then self:OnChooseBreedPet(context.petUniqId) if context.isCallbackInvitation then local state = not self.isLockPet MDL.Pet.BreedPetLockReq(state) end else self:UpdateBreedState() end end function UIPetReproduction:UpdateSingleCost() local singleCostInfo = DataSheetManager.ConstData:GetDataByID("PetSingleBornItem").IntListValue local itemId = singleCostInfo[1] local costNum = singleCostInfo[2] local curNum = MDL.Currency.GetMoneyCount(itemId) if curNum >= costNum then self.txt_Cost.text = UTL.Color.FormatGreenColor(curNum) .. "/" .. costNum else self.txt_Cost.text = UTL.Color.FormatRedColor(curNum) .. "/" .. costNum end end function UIPetReproduction:OnGlobalInfoUpdate() if self:UpdateBreedState() then return end self:UpdateRewardInfo() self:UpdateBreedTimes() end function UIPetReproduction:UpdateLockMat() local constList = DataSheetManager.ConstData:GetDataByID("PetBornExtraItem").IntListValue local curNum = MDL.Bag.GetItemCount(constList[1]) local costNum = constList[2] if curNum >= costNum then UTL.Item.SetItemCell(self.Item, constList[1], UTL.Color.FormatGreenColor(curNum) .. "/" .. costNum) else UTL.Item.SetItemCell(self.Item, constList[1], UTL.Color.FormatRedColor(curNum) .. "/" .. costNum) end self.isItemEnough = curNum >= costNum if self.isItemEnough == false then self.toggle_AutoInvited.isOn = false else self.toggle_AutoInvited.isOn = CTL.Pet.IsUseExtraBreedMat end end --更新对方的宠物 function UIPetReproduction:UpdateBreedState() local breedState = MDL.Pet.GetPetBreedState() if breedState == MDL.Pet.BreedState.Breeding then --繁殖中状态,切换界面 self:CloseView(true) UIManager.OpenView(Const_UI_Lua.UIEnum.UIPetReproductionGet) return true else if MDL.Pet.GetIsSingleBreed() then self:HandleCoupleBreed(State_OwnerSingle) else if self.isOwner and self.selectData == nil then logging.error(LTAG.ERROR, "owner unChoose pet") self:CloseView(true) return true end local breedInfo = MDL.Pet.GetRoomBreedInfo() if self.isOwner then if breedInfo == nil then if self.isLockPet then self:HandleCoupleBreed(State_OwnerLocked_NoCouple) else self:HandleCoupleBreed(State_OwnerUnLock_NoCouple) end return false end if self.isLockPet then if breedInfo.selectPet and breedInfo.isLock then self:HandleCoupleBreed(State_OwnerLocked_CoupleLocked) elseif breedInfo.selectPet and breedInfo.isLock == false then self:HandleCoupleBreed(State_OwnerLocked_CoupleUnLock) elseif breedInfo.selectPet == false then self:HandleCoupleBreed(State_OwnerLocked_CoupleUnChoose) else logging.error(LTAG.ERROR, "couple state error", breedInfo) end else if breedInfo.selectPet and breedInfo.isLock then self:HandleCoupleBreed(State_OwnerUnLock_CoupleLocked) elseif breedInfo.selectPet and breedInfo.isLock == false then self:HandleCoupleBreed(State_OwnerUnLock_CoupleUnLock) else self:HandleCoupleBreed(State_OwnerUnLock_CoupleUnChoose) end end else if breedInfo == nil then --既不是房主又无对方信息,此时应该是个错误状态,关闭界面 logging.error(LTAG.ERROR, "room info error") self:CloseView(true) return true end if self.isLockPet then if breedInfo.selectPet and breedInfo.isLock then self:HandleCoupleBreed(State_OwnerLocked_CoupleLocked) elseif breedInfo.selectPet and breedInfo.isLock == false then self:HandleCoupleBreed(State_OwnerUnLock_CoupleLocked) else logging.error(LTAG.ERROR, "owner state error, couple locked", breedInfo) end else if breedInfo.selectPet and breedInfo.isLock then if self.selectData then self:HandleCoupleBreed(State_OwnerLocked_CoupleUnLock) else self:HandleCoupleBreed(State_OwnerLocked_CoupleUnChoose) end elseif breedInfo.selectPet and breedInfo.isLock == false then if self.selectData then self:HandleCoupleBreed(State_OwnerUnLock_CoupleUnLock) else self:HandleCoupleBreed(State_OwnerUnLock_CoupleUnChoose) end else logging.error(LTAG.ERROR, "owner state error, couple unlock", breedInfo) end end end end end return false end function UIPetReproduction:UpdatePreview() if self.selectData == nil then self.txt_Probability.text = nil UIUtils.SetActive(self.group_Preview, false) return end local petId = self.selectData.Config.ID local tarPetPedigree = 0 if MDL.Pet.GetIsSingleBreed() then tarPetPedigree = self.selectData.Info.petPedigree else local breedInfo = MDL.Pet.GetRoomBreedInfo() if breedInfo then tarPetPedigree = breedInfo.petPedigree end end if tarPetPedigree == 0 then self.txt_Probability.text = nil UIUtils.SetActive(self.group_Preview, false) return end local lineageID --同类宠物的血脉模板一致,因此只需要遍历第一个即可 for i, v in DataSheetManager.PetData:GetEnumerator() do if v.ID == petId then lineageID = v.PetLineage break end end local petPedigree = self.selectData.Info.petPedigree + tarPetPedigree local cfg = DataSheetManager.PetLineage:GetDataByLineageID_LineageType_ParentStar(lineageID, 2, petPedigree) local start_min = cfg.Lineage_Table[1].LineageStar local start_max = cfg.Lineage_Table[#cfg.Lineage_Table].LineageStar self.txt_Probability.text = CTL.Pet.GetPetPedigreeImgText(start_min) .. "-" .. CTL.Pet.GetPetPedigreeImgText(start_max) .. UIUtils.GetLocalizedTxt(Const_IDS.IDS_PetSecond) UIUtils.SetActive(self.group_Preview, true) end function UIPetReproduction:UpdateBagCells() self.loop_PetList:ReloadAll(CTL.Pet.GetSortedReproductionPetList()) if self.loop_PetList.Count == 0 then UIUtils.SetLabelText(self.lab_Empty, Const_IDS.IDS_Pet_PetSkill3) else self.lab_Empty.text = nil end end function UIPetReproduction:OnBreedLock(state) self.isLockPet = state self:UpdateBreedState() end function UIPetReproduction:OnBackButtonPressed() self:OnButtonClicked(self.UIPetPopUp.btn_Close) end function UIPetReproduction:OnButtonClicked(comp) if comp == self.UIPetPopUp.btn_Close then self:CloseView(true) elseif comp == self.group_My.btn_Lock then if self.isOwner then local state = not self.isLockPet MDL.Pet.BreedPetLockReq(state) end elseif comp == self.group_Other.btn_Lock then if self.isOwner then return end local state = not self.isLockPet MDL.Pet.BreedPetLockReq(state) elseif comp == self.Item.event_Click then UTL.ItemTips.ShowCommonTipsById(DataSheetManager.ConstData:GetDataByID("PetBornExtraItem").IntListValue[1]) elseif comp == self.group_Other.btn_Kick then if self.isOwner then MDL.Pet.BreedPetKickOutReq() end elseif comp == self.group_Other.uiclick then if self.selectData == nil then CTL.Tips.AddTipsMsg(Const_IDS["IDS_ERRORCODE_4041_InfoCode_Pet_Born14"]) return end if self.isLockPet == false then CTL.Tips.AddTipsMsg(Const_IDS["IDS_ERRORCODE_4054_InfoCode_Pet_Born27"]) return end UIManager.OpenView(Const_UI_Lua.UIEnum.UIPetInvitePopUp, { petUniqId = self.context.petUniqId }) elseif comp == self.btn_Reproduction then MDL.Pet.StartBreedPetReq() elseif comp == self.btn_Close then UIUtils.SetActive(self.info_Reward, false) elseif comp == self.btn_Reward then if self.canGetReward then MDL.Pet.RewardPetWeekBreedReq(1) else local _, hasReward = MDL.Pet.GetWeekBreedTimeInfo() if hasReward then CTL.Tips.AddTipsMsg(Const_IDS["IDS_ERRORCODE_4068_InfoCode_Pet_BornRewardGot"]) end UIUtils.SetActive(self.info_Reward, true) self:ShowRewardPreview() end elseif comp == self.btn_Lock then local state = not self.isLockPet MDL.Pet.BreedPetLockReq(state) elseif comp == self.btn_Info then if self.selectData then UIManager.OpenView(Const_UI_Lua.UIEnum.UIPetReproductionStarTip, { lineageID = self.selectData.Config.PetLineage }) else local petCfg = self:GetOtherPetParams() UIManager.OpenView(Const_UI_Lua.UIEnum.UIPetReproductionStarTip, { lineageID = petCfg.PetLineage }) end elseif comp == self.event_SeekForLifeMate then if self.isLockPet == false then CTL.Tips.AddTipsMsg(Const_IDS["IDS_ERRORCODE_4054_InfoCode_Pet_Born27"]) return end UIUtils.SetActive(self.img_ChannelBg, true) UIUtils.SetActive(self.btn_WarZoneChannel, CTL.WarZone.IsWarZoneOpen()) elseif comp == self.img_ChannelBg then UIUtils.SetActive(self.img_ChannelBg, false) elseif comp == self.btn_WorldChannel then self:OnClickShout(MDL.ChannelChat.ChannelCfgId.World) UIUtils.SetActive(self.img_ChannelBg, false) elseif comp == self.btn_GuildChannel then self:OnClickShout(MDL.ChannelChat.ChannelCfgId.Legion) UIUtils.SetActive(self.img_ChannelBg, false) elseif comp == self.btn_WarZoneChannel then self:OnClickShout(MDL.ChannelChat.ChannelCfgId.WarZone) UIUtils.SetActive(self.img_ChannelBg, false) end end function UIPetReproduction:ShowRewardPreview() if self.hasInitReward then return end local rewardId = DataSheetManager.ConstData:GetDataByID("PetBreedWeeklyTaskRewardID").IntValue local rewardCfg = DataSheetManager.PetTaskRewardRepeat:GetDataByID(rewardId) self.ChestRewardScroll:ReloadAll(rewardCfg.Item_Table) self.hasInitReward = true end function UIPetReproduction:OnCellInit(scrollRect, index, cellTable, data) if scrollRect == self.ChestRewardScroll then UTL.Item.SetItemCell(cellTable.item, data.ItemID, data.ItemNum) else local petInfo, petConfig = data.Info, data.Config UIUtils.SetActive(cellTable.img_AssistanceIcon, MDL.Pet.IsPetAssistanceFight(petInfo.petUniqId)) UIUtils.SetActive(cellTable.sprite_BgZhen, MDL.Pet.IsPetLineUp(petInfo.petUniqId)) CTL.Pet.SetPetName(cellTable.txt_Name, petInfo, petConfig) cellTable.txt_Level.text = nil --保证动效一致 for i, v in ipairs(cellTable.group_Star) do UIUtils.SetActive(v, false) end for i, v in ipairs(cellTable.group_Star) do if i <= petInfo.petPedigree then UIUtils.SetActive(v, true) else break end end UIUtils.SetImageByAssetBundle(cellTable.img_Pet, petConfig.PetIcon) cellTable.txt_Num.text = nil if self.selectData and self.selectData.Info.petUniqId == petInfo.petUniqId then UIUtils.SetActive(cellTable.img_Select, true) else UIUtils.SetActive(cellTable.img_Select, false) end end end function UIPetReproduction:OnCellClicked(scrollRect, index, cellTable, target, data) if scrollRect == self.ChestRewardScroll then UTL.ItemTips.ShowCommonTipsById(data.ItemID) else if self.isLockPet then return end MDL.Pet.ChooseBreedPetReq(data.Info.petUniqId) end end function UIPetReproduction:OnChooseBreedPet(petUniqId) self.context.petUniqId = petUniqId UIUtils.SetActive(self.group_Item, true) local data = MDL.Pet.GetActiveInfo(petUniqId) self.selectData = data self:UpdateBreedState() end function UIPetReproduction:SetPetInfo(petCfg, petPedigree, col) --保证动效一致 for i, v in ipairs(col.group_Star) do UIUtils.SetActive(v, false) end for i, v in ipairs(col.group_Star) do if i <= petPedigree then UIUtils.SetActive(v, true) else break end end UIUtils.SetLabelText(col.txt_PetName, Const_IDS[petCfg.PetName]) end function UIPetReproduction:LoadModel(handle, petCfg) if self.hasInitHandle == false then UTL.UIRender.CreateRTSceneTrans(self.modelComponentDataHandleLeft, LightLeft) UTL.UIRender.CreateRTSceneTrans(self.modelComponentDataHandleRight, LightRight) self.hasInitHandle = true end if self.loadedHandleTab[handle] == petCfg.PetModelID then return end self.loadedHandleTab[handle] = petCfg.PetModelID UTL.UIRender.DisposePlayerModel(handle, true) 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 function UIPetReproduction:OnClosed() UIManager.ActiveUIModle(true, "UIPetReproduction") UIUtils.SetActive(self.UIPetPopUp.btn_Info, true) UIUtils.SetActive(self.UIPetPopUp.img_TitleBg, true) UIUtils.SetActive(self.UIPetPopUp.group_Title, true) if MDL.Pet.GetRoomBreedInfo() then CTL.Pet.SetIsBreedRoomInValid(true) else CTL.Pet.SetIsBreedRoomInValid(false) end MDL.Pet.ClearRoomBreedInfo() MDL.Pet.SetSingleBreed(false) MDL.Pet.OpenPetBreedViewReq(false, self.context.petUniqId) if UIManager.IsViewOpened(Const_UI_Lua.UIEnum.UIChannelChatMain) then UIManager.CloseView(Const_UI_Lua.UIEnum.UIChannelChatMain) end MDL.ChannelChat.ExitPetBreedChannel() UTL.UIRender.DisposeModelComponentData(self.modelComponentDataHandleLeft) UTL.UIRender.DisposeModelComponentData(self.modelComponentDataHandleRight) end function UIPetReproduction:SetShoutCountdown(cdTime) if cdTime > 0 then self.txt_ShoutCountTime:ResetAndBeginCustomTimer(false, cdTime, 0, UIUtils.GetLocalizedTxt(Const_IDS["IDS_TeamUI_Myteam_RecruitingTime"]), 1) self.event_SeekForLifeMate:SetGray(true) self:StartRepeatFunc(self.OnUpdateFun, cdTime) else self.txt_ShoutCountTime:EndTimer() self.event_SeekForLifeMate:SetGray(false) self:StopRepeatFunc(self.OnUpdateFun) end end function UIPetReproduction:OnUpdateFun(deltaTime, timeSinceUpdate) self:SetShoutCountdown(CTL.Pet.GetShutTimeCD()) end function UIPetReproduction:OnClickShout(channelID) if self.isLockPet == false then CTL.Tips.AddTipsMsg(Const_IDS["IDS_ERRORCODE_4054_InfoCode_Pet_Born27"]) return end if channelID == MDL.ChannelChat.ChannelCfgId.Legion then if MDL.Guild.IsHasGuild() == false then CTL.Tips.AddTipsMsg(Const_IDS.IDS_Chat_ConditionLegion) return end end if channelID == MDL.ChannelChat.ChannelCfgId.WarZone then if CTL.WarZone.IsWarZoneOpen() == false then CTL.Tips.AddTipsMsg(Const_IDS.IDS_WarZoneBoss_ZhanQuWeiKaiQi) return end end local cdTime = CTL.Pet.GetShutTimeCD() self:SetShoutCountdown(cdTime) if cdTime == 0 then local petData = MDL.Pet.GetActiveInfo(self.selectData.Info.petUniqId) if CTL.Pet.ShutBreedMsg(channelID, "IDS_Pet_LookForMate", petData.Info.petPedigree, petData.Config.ID) then CTL.Tips.AddTipsMsg(Const_IDS["IDS_Team_CallInfoSendToChannel"]) cdTime = CTL.Pet.GetShutTimeCD() self:SetShoutCountdown(cdTime) end end end function UIPetReproduction:OnValueChanged(comp, state) if comp == self.toggle_AutoInvited then if state and self.isItemEnough == false then CTL.Tips.AddTipsMsg(Const_IDS["IDS_ERRORCODE_1011_InfoCode_Item_Not_Enough"]) self.toggle_AutoInvited.isOn = false return end CTL.Pet.IsUseExtraBreedMat = state elseif comp == self.toggle_TopGroup then self.txt_colorstate:SetState(state) if state == Index_Single then --单人繁殖 if self.state ~= State_OwnerUnLock_NoCouple and self.state ~= State_OwnerLocked_NoCouple then --有人在的情况下不允许切换 CTL.Tips.AddTipsMsg(Const_IDS.IDS_Pet_OtherGuyCantChange) self.toggle_TopGroup:SelectIndex(Index_Double) return end if MDL.Pet.GetIsSingleBreed() == false then self.isLockPet = false MDL.Pet.BreedPetInviteReq(nil, 2) end UIUtils.SetActive(self.event_SeekForLifeMate, false) else if MDL.Pet.GetIsSingleBreed() then self.isLockPet = false MDL.Pet.BreedPetKickOutReq() end UIUtils.SetActive(self.event_SeekForLifeMate, true) end end end function UIPetReproduction:OnClosePanel(viewName) if viewName == Const_UI_Lua.UIEnum.UIPetReproduction then self:CloseView(true) end end function UIPetReproduction:OnProcessBreedConfirmState(state) if self.isOwner == false then return end if state == MDL.Pet.BreedConfirmType.RequireConfirm then UIUtils.SetActive(self.btn_Reproduction, false) UIUtils.SetActive(self.group_Timer_Get, true) self.timer_Get:SetCDLabel(UIUtils.GetLocalizedTxt(Const_IDS.IDS_Pet_WaitConfirm)) elseif state == MDL.Pet.BreedConfirmType.RejectConfirm then --对方拒绝,切换成按钮 UIUtils.SetActive(self.btn_Reproduction, true) UIUtils.SetActive(self.group_Timer_Get, false) end end function UIPetReproduction:UpdateRewardInfo() local times, hasReward = MDL.Pet.GetWeekBreedTimeInfo() if hasReward == true then self.btn_Reward:SetRedPoint(false) self.canGetReward = false UIUtils.SetLabelText(self.txt_Times, Const_IDS.IDS_Achievement_AlreadyGet) return end local totalTimes = DataSheetManager.ConstData:GetDataByID("PetBreedWeeklyTaskNum").IntValue if times >= totalTimes then self.canGetReward = true self.btn_Reward:SetRedPoint(true) else self.canGetReward = false self.btn_Reward:SetRedPoint(false) end self.txt_Times.text = times .. "/" .. totalTimes end function UIPetReproduction:UpdateBreedTimes() local totalTimes = DataSheetManager.ConstData:GetDataByID("PetBreedNum").IntValue local curTimes = MDL.Pet.GetWeekBreedTimes() self.txt_ReproductionTimes.text = string.FormatByIdsId(Const_IDS.IDS_Pet_BornTimeTips1, curTimes .. "/" .. totalTimes) end --双人繁殖 function UIPetReproduction:HandleCoupleBreed(state) self.state = state self:HandlePetList(state) self:HandleLayoutState(state) self:HandlePetModel(state) self:HandlePetInfos(state) self:HandleLocks(state) self:HandleMiddleMsg(state) end function UIPetReproduction:HandleLocks(state) if state == State_OwnerLocked_NoCouple or state == State_OwnerLocked_CoupleUnChoose or state == State_OwnerLocked_CoupleUnLock or state == State_OwnerLocked_CoupleLocked then UIUtils.SetActive(self.group_My.group_LockMark, true) if self.isOwner then UIUtils.SetActive(self.group_My.btn_Lock, true) else UIUtils.SetActive(self.group_My.btn_Lock, false) end else UIUtils.SetActive(self.group_My.group_LockMark, false) end if state == State_OwnerLocked_CoupleLocked or state == State_OwnerUnLock_CoupleLocked then UIUtils.SetActive(self.group_Other.group_LockMark, true) if self.isOwner then UIUtils.SetActive(self.group_Other.btn_Lock, false) else UIUtils.SetActive(self.group_Other.btn_Lock, true) end else UIUtils.SetActive(self.group_Other.group_LockMark, false) end end function UIPetReproduction:HandleMiddleMsg(state) UIUtils.SetActive(self.group_Invite, false) if self.isOwner then if state == State_OwnerUnLock_NoCouple or state == State_OwnerUnLock_CoupleUnChoose or state == State_OwnerUnLock_CoupleUnLock or state == State_OwnerUnLock_CoupleLocked then UIUtils.SetActive(self.group_Timer_Get, false) UIUtils.SetActive(self.btn_Reproduction, false) UIUtils.SetActive(self.btn_Lock, true) elseif state == State_OwnerLocked_NoCouple then UIUtils.SetActive(self.group_Timer_Get, true) if self.context.isCallbackInvitation then UIUtils.SetActive(self.group_Timer_Get, false) UIUtils.SetActive(self.group_Invite, true) UIUtils.SetLabel(self.lab_Invite1, string.FormatByIdsId(Const_IDS.IDS_PetBorn_InviteBorn3, self.context.playerName)) else UIUtils.SetActive(self.group_Timer_Get, true) UIUtils.SetActive(self.group_Invite, false) self.timer_Get:SetCDLabel(UIUtils.GetLocalizedTxt(Const_IDS.IDS_Pet_InviteOtherGuy)) end UIUtils.SetActive(self.btn_Reproduction, false) UIUtils.SetActive(self.btn_Lock, false) elseif state == State_OwnerLocked_CoupleUnChoose then UIUtils.SetActive(self.group_Timer_Get, true) self.timer_Get:SetCDLabel(UIUtils.GetLocalizedTxt(Const_IDS.IDS_Pet_WaitOtherGuyPut)) UIUtils.SetActive(self.btn_Reproduction, false) UIUtils.SetActive(self.btn_Lock, false) elseif state == State_OwnerLocked_CoupleUnLock then UIUtils.SetActive(self.group_Timer_Get, true) self.timer_Get:SetCDLabel(UIUtils.GetLocalizedTxt(Const_IDS.IDS_Pet_WaitOtherGuyConfirm)) UIUtils.SetActive(self.btn_Reproduction, false) UIUtils.SetActive(self.btn_Lock, false) elseif state == State_OwnerLocked_CoupleLocked or state == State_OwnerSingle then UIUtils.SetActive(self.group_Timer_Get, false) UIUtils.SetActive(self.btn_Reproduction, true) UIUtils.SetActive(self.btn_Lock, false) end else if state == State_OwnerUnLock_CoupleUnChoose or state == State_OwnerLocked_CoupleUnChoose then UIUtils.SetActive(self.group_Timer_Get, true) self.timer_Get:SetCDLabel(UIUtils.GetLocalizedTxt(Const_IDS.IDS_Pet_PutSameBaby)) UIUtils.SetActive(self.btn_Reproduction, false) UIUtils.SetActive(self.btn_Lock, false) elseif state == State_OwnerUnLock_CoupleUnLock or state == State_OwnerLocked_CoupleUnLock then UIUtils.SetActive(self.group_Timer_Get, false) UIUtils.SetActive(self.btn_Reproduction, false) UIUtils.SetActive(self.btn_Lock, true) elseif state == State_OwnerLocked_CoupleLocked or state == State_OwnerUnLock_CoupleLocked then UIUtils.SetActive(self.group_Timer_Get, true) self.timer_Get:SetCDLabel(UIUtils.GetLocalizedTxt(Const_IDS.IDS_Pet_WaitOtherGuyConfirm)) UIUtils.SetActive(self.btn_Reproduction, false) UIUtils.SetActive(self.btn_Lock, false) end end end function UIPetReproduction:HandlePetInfos(state) if self.isOwner then self:SetPetInfo(self.selectData.Config, self.selectData.Info.petPedigree, self.group_My) if state == State_OwnerUnLock_CoupleUnLock or state == State_OwnerLocked_CoupleUnLock or state == State_OwnerLocked_CoupleLocked or state == State_OwnerUnLock_CoupleLocked then local petCfg, petPedigree = self:GetOtherPetParams() self:SetPetInfo(petCfg, petPedigree, self.group_Other) end else local petCfg, petPedigree = self:GetOtherPetParams() self:SetPetInfo(petCfg, petPedigree, self.group_My) if state == State_OwnerUnLock_CoupleUnLock or state == State_OwnerLocked_CoupleUnLock or state == State_OwnerLocked_CoupleLocked or state == State_OwnerUnLock_CoupleLocked then self:SetPetInfo(self.selectData.Config, self.selectData.Info.petPedigree, self.group_Other) end end self:UpdatePreview() end function UIPetReproduction:HandlePetModel(state) if self.isOwner then self:LoadModel(self.modelComponentDataHandleLeft, self.selectData.Config) if state == State_OwnerUnLock_CoupleUnLock or state == State_OwnerLocked_CoupleUnLock or state == State_OwnerLocked_CoupleLocked or state == State_OwnerUnLock_CoupleLocked then UIUtils.SetActive(self.group_Other.modelShow, true) local petCfg = self:GetOtherPetParams() self:LoadModel(self.modelComponentDataHandleRight, petCfg) else UIUtils.SetActive(self.group_Other.modelShow, false) end else local petCfg = self:GetOtherPetParams() self:LoadModel(self.modelComponentDataHandleLeft, petCfg) if state == State_OwnerUnLock_CoupleUnLock or state == State_OwnerLocked_CoupleUnLock or state == State_OwnerLocked_CoupleLocked or state == State_OwnerUnLock_CoupleLocked then UIUtils.SetActive(self.group_Other.modelShow, true) self:LoadModel(self.modelComponentDataHandleRight, self.selectData.Config) else UIUtils.SetActive(self.group_Other.modelShow, false) end end end function UIPetReproduction:HandleLayoutState(state) if state == State_OwnerSingle then UIUtils.SetActive(self.group_SingleCost, true) UIUtils.SetActive(self.group_Other.group_single, true) UIUtils.SetActive(self.group_Other.group_PetType, false) else UIUtils.SetActive(self.group_SingleCost, false) UIUtils.SetActive(self.group_Other.group_single, false) UIUtils.SetActive(self.group_Other.group_PetType, true) if state == State_OwnerUnLock_NoCouple or state == State_OwnerLocked_NoCouple then self.group_Other.obj_state:SetState(0) UIUtils.SetActive(self.group_Other.group_Name, false) if state == State_OwnerLocked_NoCouple then self.group_Other.group_Invite:PlayAnim() else self.group_Other.group_Invite:StopAnim(false) end else UIUtils.SetActive(self.group_Other.group_Name, true) if self.isOwner then local breedInfo = MDL.Pet.GetRoomBreedInfo() self.group_Other.txt_Name.text = breedInfo.playerName CTL.Character.SetPortraitAndFrame(self.group_Other.herohead, breedInfo.playerPortrait, breedInfo.playerFrameId) end if state == State_OwnerUnLock_CoupleUnChoose or state == State_OwnerLocked_CoupleUnChoose then self.group_Other.obj_state:SetState(1) else self.group_Other.obj_state:SetState(2) end end end if self.isOwner then UIUtils.SetActive(self.group_Other.btn_Kick, state ~= State_OwnerUnLock_NoCouple and state ~= State_OwnerLocked_NoCouple and state ~= State_OwnerSingle) else UIUtils.SetActive(self.group_Other.btn_Kick, false) end end function UIPetReproduction:HandlePetList(state) if self.isOwner then if state == State_OwnerSingle or state == State_OwnerUnLock_NoCouple or state == State_OwnerUnLock_CoupleUnChoose or state == State_OwnerUnLock_CoupleUnLock or state == State_OwnerUnLock_CoupleLocked then UIUtils.SetActive(self.group_PetList, true) self.state_PetList:SetState(0) self:UpdateBagCells() else UIUtils.SetActive(self.group_PetList, false) end else if state == State_OwnerUnLock_CoupleUnLock or state == State_OwnerLocked_CoupleUnLock or state == State_OwnerUnLock_CoupleUnChoose or state == State_OwnerLocked_CoupleUnChoose then UIUtils.SetActive(self.group_PetList, true) self.state_PetList:SetState(1) self:UpdateBagCells() else UIUtils.SetActive(self.group_PetList, false) end end end function UIPetReproduction:GetOtherPetParams() local breedInfo = MDL.Pet.GetRoomBreedInfo() return DataSheetManager.PetData:GetDataByID_Stage(breedInfo.petId, breedInfo.petVariation), breedInfo.petPedigree end function UIPetReproduction:OnReceiveNewMsg(msg) local chatCfgData = MDL.ChannelChat.GetChatCfgDataByChannelId(msg.ChannelId) if chatCfgData.ID == MDL.ChannelChat.ChannelCfgId.PetBreedChat then local isMyMsg = msg.fromId == BattleDataGetter.GetAcID() self:ShowChatMsg(msg.content, isMyMsg) end end function UIPetReproduction:ShowChatMsg(content, isMyMsg) if self.isOwner then if isMyMsg then self:StopRepeatFunc(self.HideMyChat) UIUtils.SetActive(self.group_My.group_Chat, true) self:StartRepeatFunc(self.HideMyChat, Const_Msg_Duration, 1) self.group_My.txt_ChatMsg.text = content else self:StopRepeatFunc(self.HideOtherChat) UIUtils.SetActive(self.group_Other.group_Chat, true) self:StartRepeatFunc(self.HideOtherChat, Const_Msg_Duration, 1) self.group_Other.txt_ChatMsg.text = content end else if isMyMsg then self:StopRepeatFunc(self.HideOtherChat) UIUtils.SetActive(self.group_Other.group_Chat, true) self:StartRepeatFunc(self.HideOtherChat, Const_Msg_Duration, 1) self.group_Other.txt_ChatMsg.text = content else self:StopRepeatFunc(self.HideMyChat) UIUtils.SetActive(self.group_My.group_Chat, true) self:StartRepeatFunc(self.HideMyChat, Const_Msg_Duration, 1) self.group_My.txt_ChatMsg.text = content end end end function UIPetReproduction:HideMyChat() UIUtils.SetActive(self.group_My.group_Chat, false) end function UIPetReproduction:HideOtherChat() UIUtils.SetActive(self.group_Other.group_Chat, false) end return UIPetReproduction