local UIHeroLightEffectTool = require "View/Common/UIHeroLightEffectTool" local UIWarHorseBasePanel = UIViewClass() local STATE_SWITCH_TIME = 8 local RESET_TIME = 14.5 local OFFSET_TIME = 1.5 local DRIVER_POS_ANIM = "ride_showpos" local DRIVER_IDLE_ANIM = "ride_idle_loop" local DRIVER_SHOW_ANIM = "ride_stop_show" local ScreenFixedRatio = 0.51 local ScreenFixedConst = -0.9 local Const_NOIdlePosHorseDic = LuaConst.NOIdlePosHorseDic function UIWarHorseBasePanel:OnCreated() self.heroLightEffectDatas = UIHeroLightEffectTool.CreateHeroLightEffectDatas(true) if GameAppInfo.IsVersionGreaterThan19000() then UIUtils.SetActive(self.render, false) --删除版本判断时,需要同步删除界面上的render节点 self.modelComponentDataHandle = UTL.UIRender.CreateModelComponentDatas(self.horseRender) self:RegistTriggerEvent(self.horseRender, UIEventTriggerType.Drag) else UIUtils.SetActive(self.horseRender, false) end end function UIWarHorseBasePanel:OnDrag(comp, eventData) UTL.UIRender.RotateEntity(self.modelComponentDataHandle, -eventData.delta.x * 0.2, true, true) end function UIWarHorseBasePanel:OnOpened(context) self.resolutionRatio = UIUtils.GetScreenResolutionRatio() local w, h = UIUtils.GetScreenSize(1,1) self.fixedRatio = (w / h) * ScreenFixedRatio + ScreenFixedConst UIManager.ActiveUIModle(false, "UIWarHorseBasePanel") UIUtils.SetLabelText(self.UITemplateTitlePanel.lab_Title, Const_IDS.IDS_Horse_Title_1) self.context = context self.enterType = context.enterType self:RegistSystemEvent(EventID.UI_UpdateWarHorseInfo, self.RefreshPanel) self:RegistSystemEvent(EventID.UI_PlayHorseAnim, self.ForcePlayHorseAnim) self:RegistSystemEvent(EventID.UI_ActiveHorseSuccess, self.OnActiveHorseSuccess) self:RegistSystemEvent(EventID.UI_HorseBreakSuccess, self.OnHorseBreakSuccess) self:RegistSystemEvent(EventID.UI_WarHorse_OnCloseGamePlay, self.OnCloseActivity) self:RegistSystemEvent(EventID.UI_WarHorse_UpdateModelShow, self.UpdateModelShow) self:RegistSystemEvent(EventID.UI_UpdateHorseAppearance, self.UpdateModelShow) self:RegistSystemEvent(EventID.UI_CheatGreenBg, self.SetCheatGreenBg) self:RegistSystemEvent(EventID.UI_UpdateWarHorseEquipInfo, self.RefreshHorseEquipToggleRedPoint) self.RideState = 0 self.obj_state:SetState(self.RideState) -- 模型展示3中状态,CurHorseConfig 坐骑的配置, curShowHorseConfig 实际应当展示的配置, previewShowConfig 预览页签下要展示的配置 -- 初始默认选中非外观页签 self.CurHorseConfig = context.config self.curShowHorseConfig = CTL.WarHorse.GetCurRealHorseDataByHorseID(self.CurHorseConfig.HorseID) self:InitPreviewInfo(context.enterType) self:UpdateTabInfo(context.tabIndex, context.appearanceId) self:UpdateInfo(false) self:UpdateHorseRelationLoop() if GameAppInfo.IsVersionGreaterThan19000() then else self.render:SetSceneParam(self.curShowHorseConfig.GroundScale, self.curShowHorseConfig.ModelRot) self.render:PlayHorseAnim(self.curShowHorseConfig.ModelShowAnim) end self.isPlayingAnim = false self:StartRepeatFunc(self.UpdateAnimRefresh, 0.2, -1) for i = 1, 5 do self:SetToggles(i) end end function UIWarHorseBasePanel:SetToggles(i) local bgicon local selectedIcon if i == CTL.WarHorse.Horse_TabIndex.Break then bgicon = UTL.Toggle.GetToggleNormalIcon(UTL.Toggle.ToggleType.Breakthrough) selectedIcon = UTL.Toggle.GetToggleSelectedIcon(UTL.Toggle.ToggleType.Breakthrough) elseif i == CTL.WarHorse.Horse_TabIndex.Equip then bgicon = UTL.Toggle.GetToggleNormalIcon(UTL.Toggle.ToggleType.HorseEquip) selectedIcon = UTL.Toggle.GetToggleSelectedIcon(UTL.Toggle.ToggleType.HorseEquip) elseif i == CTL.WarHorse.Horse_TabIndex.HorseSoul then bgicon = UTL.Toggle.GetToggleNormalIcon(UTL.Toggle.ToggleType.HorseSoul) selectedIcon = UTL.Toggle.GetToggleSelectedIcon(UTL.Toggle.ToggleType.HorseSoul) elseif i == CTL.WarHorse.Horse_TabIndex.Appearance then bgicon = UTL.Toggle.GetToggleNormalIcon(UTL.Toggle.ToggleType.Appearance) selectedIcon = UTL.Toggle.GetToggleSelectedIcon(UTL.Toggle.ToggleType.Appearance) elseif i == CTL.WarHorse.Horse_TabIndex.Info then bgicon = UTL.Toggle.GetToggleNormalIcon(UTL.Toggle.ToggleType.Information) selectedIcon = UTL.Toggle.GetToggleSelectedIcon(UTL.Toggle.ToggleType.Information) end self.toggles:SetToggleCompImage(i, "img_bg_icon", bgicon) self.toggles:SetToggleCompImage(i, "img_SelectedIcon", selectedIcon) end function UIWarHorseBasePanel:OnCloseActivity() self:CloseView(true) end function UIWarHorseBasePanel:UpdateAnimRefresh(deltaTime, timeSinceUpdate) self.timeSinceUpdate = timeSinceUpdate if timeSinceUpdate >= RESET_TIME then self:ResetAnim(self.isStandOn) return end if timeSinceUpdate >= STATE_SWITCH_TIME and self.isPlayingAnim == false then if not Const_NOIdlePosHorseDic[self.CurHorseConfig.HorseID] then if GameAppInfo.IsVersionGreaterThan19000() then UTL.UIRender.HorsePlayAnim(self.modelComponentDataHandle, self.curShowHorseConfig.ModelIdleShowAnim) else self.render:PlayHorseAnim(self.curShowHorseConfig.ModelIdleShowAnim) end end if self.RideState > 0 then if not self.isStandOn then self:PlayDriverAnim(DRIVER_POS_ANIM, 5) end end self.isPlayingAnim = true --播放马休闲动作音效 self.soundId = CTL.Sound.PlayGameSound(self.curShowHorseConfig.HorseIdleShowAudio) end if self.isPlayingAnim and self.RideState > 0 then if self.targetTime and timeSinceUpdate > self.targetTime then self.targetTime = nil self:ResetAnim() end end end function UIWarHorseBasePanel:PlayDriverAnim(anim, animTime) if not self.isStandOn then if GameAppInfo.IsVersionGreaterThan19000() then UTL.UIRender.DriverEntityPlayAnim(self.modelComponentDataHandle, anim) else self.render:PlayDriverAnim(anim) end end self.isPlayingAnim = true self.targetTime = self.timeSinceUpdate + animTime end function UIWarHorseBasePanel:ResetAnim(isStandOn) if isStandOn then return end self.timeSinceUpdate = 0 self.isPlayingAnim = false if self.RideState > 0 then if GameAppInfo.IsVersionGreaterThan19000() then if self.isStandOn then UTL.UIRender.DriverEntityPlayAnim(self.modelComponentDataHandle, LuaConst.Animation_idle_loop) else UTL.UIRender.DriverEntityPlayAnim(self.modelComponentDataHandle, DRIVER_IDLE_ANIM) end else if self.isStandOn then self.render:PlayDriverAnim(LuaConst.Animation_idle_loop) else self.render:PlayDriverAnim(DRIVER_IDLE_ANIM) end end end self:ResetRepeatFunc(self.UpdateAnimRefresh) end function UIWarHorseBasePanel:OnClosed() UIManager.ActiveUIModle(true, "UIWarHorseBasePanel") if self.enterType == CTL.WarHorse.Horse_EnterType.Formation then local activeInfo = MDL.WarHorse.GetInfoByID(self.CurHorseConfig.HorseID) if activeInfo and activeInfo.HeroID then MDL.HeroSelect.curSelectHeroID = activeInfo.HeroID end end self.context.tabIndex = self.lastTabIndex self:StopHeroLightEffect(true) if GameAppInfo.IsVersionGreaterThan19000() then self:StopModelEffect() UTL.UIRender.DisposeModelComponentData(self.modelComponentDataHandle) end if self.soundId then CTL.Sound.StopById(self.soundId) end end function UIWarHorseBasePanel:InitPreviewInfo(enterType) self.PreviewHorseConfigList = {} if enterType == CTL.WarHorse.Horse_EnterType.Formation then --从阵容界面进来,只能预览装备的坐骑 local lineUpIds = MDL.Player.GetHeroLinUpIds() for i = 1, #lineUpIds do local equipHorse = MDL.WarHorse.GetInfoByHeroID(lineUpIds[i]) if equipHorse then table.insert(self.PreviewHorseConfigList, equipHorse.ConfigInfo) end end else --从坐骑一级界面进来,可以预览所有坐骑 self.PreviewHorseConfigList = MDL.WarHorse.GetSortedHorseList() end if #self.PreviewHorseConfigList == 1 then self.PreviewIndex = 1 UIUtils.SetActive(self.btn_Before.gameObject, false) UIUtils.SetActive(self.btn_Next.gameObject, false) else for i = 1, #self.PreviewHorseConfigList do if self.PreviewHorseConfigList[i].HorseID == self.CurHorseConfig.HorseID then self.PreviewIndex = i break end end end end function UIWarHorseBasePanel:UpdateTabInfo(index, appearanceId) self.toggles:SetToggleActive(CTL.WarHorse.Horse_TabIndex.Info, true) --未激活不显示突破标签 local isActive = MDL.WarHorse.GetInfoByID(self.CurHorseConfig.HorseID) ~= nil if isActive then self.toggles:SetToggleActive(CTL.WarHorse.Horse_TabIndex.Appearance, true) self.toggles:SetToggleActive(CTL.WarHorse.Horse_TabIndex.Break, true) self.toggles:SetToggleActive(CTL.WarHorse.Horse_TabIndex.HorseSoul, MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.HorseSoul) and MDL.WarHorse.GetEquippedHeroIDByHorseID(self.CurHorseConfig.HorseID) > 0) self.toggles:SetToggleActive(CTL.WarHorse.Horse_TabIndex.Equip, MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.HorseEquip) and MDL.WarHorse.GetEquippedHeroIDByHorseID(self.CurHorseConfig.HorseID) > 0) self:ChangeTabShow(index, false, appearanceId) --刷新选中态 self.toggles:SelectIndex(index - 1) else self.toggles:SetToggleActive(CTL.WarHorse.Horse_TabIndex.Break, false) self.toggles:SetToggleActive(CTL.WarHorse.Horse_TabIndex.Appearance, false) self.toggles:SetToggleActive(CTL.WarHorse.Horse_TabIndex.HorseSoul, false) self.toggles:SetToggleActive(CTL.WarHorse.Horse_TabIndex.Equip, false) --未激活只能选中信息页签 self:ChangeTabShow(CTL.WarHorse.Horse_TabIndex.Info, false) self.toggles:SelectIndex(CTL.WarHorse.Horse_TabIndex.Info - 1) end end function UIWarHorseBasePanel:ChangeTabShow(index, toggleClick, appearanceId) local isFromAppearance = CTL.WarHorse.IsWarHorseAppearanceTab(self.lastTabIndex) if self.lastTabIndex == index and not isFromAppearance and toggleClick then return end if self.lastTabIndex ~= index then self.lastTabIndex = index self.subView:CloseAll() if index == CTL.WarHorse.Horse_TabIndex.Info then self.rightPanel = self.subView:OpenView(GetViewClass(Const_UI_Lua.UIEnum.UIWarHorseInfo), self.CurHorseConfig) elseif index == CTL.WarHorse.Horse_TabIndex.Break then self.rightPanel = self.subView:OpenView(GetViewClass(Const_UI_Lua.UIEnum.UIWarHorseBreak), self.CurHorseConfig) elseif index == CTL.WarHorse.Horse_TabIndex.Appearance then self.rightPanel = self.subView:OpenView(GetViewClass(Const_UI_Lua.UIEnum.UIWarHorseSkin), { horseConfig = self.CurHorseConfig, parentView = self , appearanceId = appearanceId}) elseif index == CTL.WarHorse.Horse_TabIndex.HorseSoul then self.rightPanel = self.subView:OpenView(GetViewClass(Const_UI_Lua.UIEnum.UIHorseSoulMain), { horseConfig = self.CurHorseConfig, parentView = self }) elseif index == CTL.WarHorse.Horse_TabIndex.Equip then self.rightPanel = self.subView:OpenView(GetViewClass(Const_UI_Lua.UIEnum.UIHorseEquipMain), { horseConfig = self.CurHorseConfig, parentView = self }) end local isHorseSoulOrEquipToggle = index == CTL.WarHorse.Horse_TabIndex.HorseSoul or index == CTL.WarHorse.Horse_TabIndex.Equip UIUtils.SetActive(self.group_MiddleBottom, not isHorseSoulOrEquipToggle) UIUtils.SetActive(self.btn_Before.gameObject, not isHorseSoulOrEquipToggle and #self.PreviewHorseConfigList > 1) UIUtils.SetActive(self.btn_Next.gameObject, not isHorseSoulOrEquipToggle and #self.PreviewHorseConfigList > 1) self:UpdateHorseRelationLoop() if isFromAppearance then self:UpdateModelShow(true) end else -- true为切换新马 self.rightPanel:UpdateInfo(self.CurHorseConfig, true) end if MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.HorseSoul) and MDL.WarHorse.GetEquippedHeroIDByHorseID(self.CurHorseConfig.HorseID) > 0 then if index == CTL.WarHorse.Horse_TabIndex.HorseSoul or index == CTL.WarHorse.Horse_TabIndex.Equip then self:MoveModelToFar() else self:MoveModelToNear() end else self:MoveModelToNear() end end function UIWarHorseBasePanel:OnActiveHorseSuccess() self.toggles:SelectIndex(CTL.WarHorse.Horse_TabIndex.Break - 1) end function UIWarHorseBasePanel:RefreshPanel() if self.lastHeroID then local info = MDL.WarHorse.GetInfoByHeroID(self.lastHeroID) local isChangeHorse = true self.CurHorseConfig = info.ConfigInfo for i = 1, #self.PreviewHorseConfigList do if self.PreviewHorseConfigList[i].HorseID == info.ConfigInfo.HorseID then self.PreviewIndex = i isChangeHorse = false break end end if isChangeHorse then self:ResetPreviewHorseConfigList() end self:UpdateTabInfo(self.lastTabIndex) end self:UpdateInfo(true) self:UpdateHorseRelationLoop() end function UIWarHorseBasePanel:ResetPreviewHorseConfigList() self.PreviewHorseConfigList = {} local lineUpIds = MDL.Player.GetHeroLinUpIds() for i = 1, #lineUpIds do local equipHorse = MDL.WarHorse.GetInfoByHeroID(lineUpIds[i]) if equipHorse then table.insert(self.PreviewHorseConfigList, equipHorse.ConfigInfo) end end end function UIWarHorseBasePanel:UpdateInfo(isUpdate) if self.CurHorseConfig then --页签红点 self.toggles:SetRedPoint(1, CTL.WarHorse.CheckHorseIfEnableActive(self.CurHorseConfig)) self.toggles:SetRedPoint(1, CTL.HorseSoul.CheckIfHorseSoulHasRp(self.CurHorseConfig.HorseID)) self:RefreshHorseEquipToggleRedPoint() self.toggles:SetRedPoint(0, CTL.WarHorse.CheckIfWarHorseBreak(self.CurHorseConfig.HorseID)) --右边箭头红点 local rightArrowRed = false for i = self.PreviewIndex + 1, #self.PreviewHorseConfigList do local nextConfig = self.PreviewHorseConfigList[i] local nextInfo = MDL.WarHorse.GetInfoByID(nextConfig.HorseID) if CTL.WarHorse.CheckHorseIfEnableActive(nextConfig) or CTL.WarHorse.CheckIfWarHorseBreak(nextConfig.HorseID) or CTL.WarHorse.CheckHeroHorseIfReplace(nextInfo ~= nil and nextInfo.HeroID or 0, nextConfig.HorseID) then rightArrowRed = true break end end self.btn_Next:SetRedPoint(rightArrowRed) --左边箭头红点 local leftArrowRed = false for i = 1, self.PreviewIndex - 1 do local lastConfig = self.PreviewHorseConfigList[i] local leftInfo = MDL.WarHorse.GetInfoByID(lastConfig.horseID) if CTL.WarHorse.CheckHorseIfEnableActive(lastConfig) or CTL.WarHorse.CheckIfWarHorseBreak(lastConfig.HorseID) or CTL.WarHorse.CheckHeroHorseIfReplace(leftInfo ~= nil and leftInfo.HeroID or 0, lastConfig.HorseID) then leftArrowRed = true break end end self.btn_Before:SetRedPoint(leftArrowRed) --模型 self:UpdateModelShow(isUpdate == false) local activeInfo = MDL.WarHorse.GetInfoByID(self.CurHorseConfig.HorseID) if activeInfo and activeInfo.HeroID then self.lastHeroID = activeInfo.HeroID UIUtils.SetActive(self.btn_Change.gameObject, true) --替换红点 self.btn_Change:SetRedPoint(CTL.WarHorse.CheckHeroHorseIfReplace(activeInfo.HeroID, self.CurHorseConfig.HorseID)) UTL.Item.ItemSquareIconByHeroId(activeInfo.HeroID, self.img_Head, self.img_BgHead, nil, MDL.HeroAwaken.GetIsHeroAwaken(activeInfo.HeroID)) UIUtils.SetActive(self.group_RideHero.gameObject, true) else self.lastHeroID = nil UIUtils.SetActive(self.group_RideHero.gameObject, false) UIUtils.SetActive(self.btn_Change.gameObject, false) end self.context.tabIndex = self.lastTabIndex self.context.config = self.CurHorseConfig end end function UIWarHorseBasePanel:RefreshHorseEquipToggleRedPoint() self.toggles:SetRedPoint(2, CTL.HorseEquip.CheckIfHorseEquipHasRp(self.CurHorseConfig.HorseID)) end --大突破播动作 function UIWarHorseBasePanel:ForcePlayHorseAnim() if Const_NOIdlePosHorseDic[self.CurHorseConfig.HorseID] then return end self:ResetAnim() if self.CurModelPath then if GameAppInfo.IsVersionGreaterThan19000() then UTL.UIRender.HorsePlayAnim(self.modelComponentDataHandle, self.curShowHorseConfig.ModelShowAnim) else self.render:PlayHorseAnim(self.curShowHorseConfig.ModelShowAnim) end if self.RideState > 0 then self:PlayDriverAnim(DRIVER_SHOW_ANIM, 2) end else self:UpdateModelShow(true) end if self.curShowHorseConfig then self.soundId = CTL.Sound.PlayGameSound(self.curShowHorseConfig.HorseShowAudio) end end function UIWarHorseBasePanel:StopModelEffect() UTL.UIRender.StopModelPsEffect(self.modelComponentDataHandle) end --大小突破播特效 function UIWarHorseBasePanel:OnHorseBreakSuccess() if self.CurModelPath == nil then self:UpdateModelShow(false) end if GameAppInfo.IsVersionGreaterThan19000() then self:StopModelEffect() UTL.UIRender.PlayModelPsEffect(self.modelComponentDataHandle, ConstAssetPathConfig.Path42) else self.render:ShowHorseEffect(ConstAssetPathConfig.Path42, 10) end CTL.Sound.PlayGameSound("UI_zuoqi_shengji") end function UIWarHorseBasePanel:DisposeRider() if GameAppInfo.IsVersionGreaterThan19000() then UTL.UIRender.EndRideHorse(self.modelComponentDataHandle, self.CurHorseConfig.HorseID) elseif self.CurRiderModelPath ~= nil then self.render:DisposeRider() self.CurRiderModelPath = nil end end function UIWarHorseBasePanel:UpdateRiderShow(isAnim, isStandOn) self:StopHeroLightEffect() if self.RideState == 0 then --只有马 self:DisposeRider() else --人+马 --坐骑被装备,显示的武将模型为装备的武将,否则为主城武将的模型 if GameAppInfo.IsVersionGreaterThan19000() then UTL.UIRender.StartRideHorse(self.modelComponentDataHandle, self.CurHorseConfig.HorseID) if not isStandOn then UTL.UIRender.DriverEntityPlayAnim(self.modelComponentDataHandle, DRIVER_IDLE_ANIM) else UTL.UIRender.DriverEntityPlayAnim(self.modelComponentDataHandle, LuaConst.Animation_idle_loop) end else local heroID local activeInfo = MDL.WarHorse.GetInfoByID(self.CurHorseConfig.HorseID) if activeInfo and activeInfo.HeroID then heroID = activeInfo.HeroID else heroID = MDL.Player.GetCurShowId() end local modelPath, equipTable, modelScale, animCtrlPath, heroEffectPath, heroLightEffects = UTL.UIRender.LoadHorseHero(heroID, true) modelScale = self.CurHorseConfig.ModelScale if self.CurRiderModelPath == nil or (self.CurRiderModelPath and self.CurRiderModelPath ~= modelPath) then self.CurRiderModelPath = modelPath self.render:ShowHorseRider(modelPath, equipTable, modelScale, animCtrlPath, heroEffectPath) self.render:SetNodePos(CTL.WarHorse.GetHorseBattleAppearanceXYZ(self.CurHorseConfig)) self.render:SetNodeRot(0,self.CurHorseConfig.ModelRot,0) self.render:SetParentPos(0, 0, 0) if isStandOn then self.render:PlayDriverAnim(LuaConst.Animation_idle_loop) end end self:BeginHeroLightEffect(heroLightEffects) end if isAnim and not isStandOn then self:PlayDriverAnim(DRIVER_SHOW_ANIM, 2) end end end --模型处理 function UIWarHorseBasePanel:UpdateModelShow(isAnim, appearanceID) -- 保存预览模型数据,0为原始皮肤 if appearanceID then self.previewShowConfig = appearanceID > 0 and MDL.WarHorse.GetAppearanceInfoByID(appearanceID) or self.CurHorseConfig end if not CTL.WarHorse.IsWarHorseAppearanceTab(self.lastTabIndex) then self.curShowHorseConfig = CTL.WarHorse.GetCurRealHorseDataByHorseID(self.CurHorseConfig.HorseID) else self.curShowHorseConfig = self.previewShowConfig end local modelPath = UTL.UIRender.GetHorseModelPathAndEffect(self.curShowHorseConfig) if not CTL.HotFix.CanAssetLoad(modelPath) then --没下好就用默认模型 local defaultData = DataSheetManager.HorseData:GetDataByHorseID(1) self.curShowHorseConfig = defaultData self.CurHorseConfig = defaultData appearanceID = nil end self:ShowHorseModel(isAnim, self.curShowHorseConfig, appearanceID, self.CurHorseConfig.HorseID) --cheatLogic if self.cheatClearEff and self.cheatBgColor then if GameAppInfo.IsVersionGreaterThan19000() then UTL.UIRender.SetCheatGreenBg(self.modelComponentDataHandle, self.cheatBgColor, self.cheatClearEff) else self.render:SetCheatGreenBg(self.cheatBgColor, self.cheatClearEff) end end end function UIWarHorseBasePanel:ShowHorseModel(isAnim, horseConfig, horseAppearanceID, horseCfgId) local newModelPath , showEffect, isStandOn = UTL.UIRender.GetHorseModelPathAndEffect(horseConfig) self.isStandOn = isStandOn if self.CurModelPath == nil or (self.CurModelPath and self.CurModelPath ~= newModelPath) then self.CurModelPath = newModelPath --先把人销毁掉,防止大小更改 if GameAppInfo.IsVersionGreaterThan19000() then self:StopModelEffect() UTL.UIRender.CreateHorse3DModel(self.modelComponentDataHandle, horseCfgId, horseAppearanceID, UTL.UIRender.LayerActiveType.HorseShow) else self:DisposeRider() self.render:ShowHorse(UTL.UIRender.LoadShowHorse3DComponent(horseConfig, horseConfig.ModelRot, horseConfig.ModelScale)) self.render:SetModelPos(0, 0, 0) self.render:SetModelScale(UTL.UIRender.GetModelScale()) end self:InitMoveModelParam() end if isAnim then self:ResetAnim(isStandOn) if not Const_NOIdlePosHorseDic[self.CurHorseConfig.HorseID] then if GameAppInfo.IsVersionGreaterThan19000() then UTL.UIRender.HorsePlayAnim(self.modelComponentDataHandle, horseConfig.ModelShowAnim) else self.render:PlayHorseAnim(horseConfig.ModelShowAnim) end self.soundId = CTL.Sound.PlayGameSound(horseConfig.HorseShowAudio) end end self:UpdateRiderShow(isAnim, isStandOn) end function UIWarHorseBasePanel:SetCheatGreenBg(color, clearEffect) if GameAppInfo.IsVersionGreaterThan19000() then UTL.UIRender.SetCheatGreenBg(self.modelComponentDataHandle, color, clearEffect,true) else self.render:SetCheatGreenBg(color, clearEffect) self.render:SetSceneParam(0, 0) end self.cheatBgColor = color self.cheatClearEff = clearEffect end function UIWarHorseBasePanel:OnBackButtonPressed() self:OnButtonClicked(self.UITemplateTitlePanel.btn_close) end function UIWarHorseBasePanel:OnButtonClicked(comp) if comp == self.UITemplateTitlePanel.btn_close then self:CloseView(true) elseif comp == self.UITemplateTitlePanel.btn_Home then CTL.HomeMain.CloseViewBackHomeMain() elseif comp == self.UITemplateTitlePanel.btn_Info then -- 玩法说明 UIManager.OpenView(Const_UI_Lua.UIEnum.UICommonNoteView, { id = LuaConst.NoteID.Horse }) elseif comp == self.btn_Next then self:SwitchHorseShow(1) elseif comp == self.btn_Before then self:SwitchHorseShow(-1) elseif comp == self.btn_WarHorse then self.RideState = (self.RideState + 1) % 2 self.obj_state:SetState(self.RideState) self:UpdateModelShow(false) elseif comp == self.btn_Change then local activeInfo = MDL.WarHorse.GetInfoByID(self.CurHorseConfig.HorseID) if activeInfo and activeInfo.HeroID then CTL.WarHorse.OpenWearPanel(activeInfo.HeroID, activeInfo.HorseInfo) end elseif comp == self.group_Hero_Btn then UIManager.OpenView(Const_UI_Lua.UIEnum.UIWarHorseRelationPopUp, { horseID = self.CurHorseConfig.HorseID }) end end function UIWarHorseBasePanel:OnValueChanged(comp, index) if comp == self.toggles then if CTL.WarHorse.IsWarHorseAppearanceTab(self.lastTabIndex) then self:ChangeTabShow(index + 1, false) else self:ChangeTabShow(index + 1, true) end end end function UIWarHorseBasePanel:SwitchHorseShow(offset) self.PreviewIndex = self.PreviewIndex + offset if self.PreviewIndex > #self.PreviewHorseConfigList then self.PreviewIndex = 1 elseif self.PreviewIndex < 1 then self.PreviewIndex = #self.PreviewHorseConfigList end self.CurHorseConfig = self.PreviewHorseConfigList[self.PreviewIndex] self.curShowHorseConfig = CTL.WarHorse.GetCurRealHorseDataByHorseID(self.CurHorseConfig.HorseID) self:UpdateHorseRelationLoop() if CTL.WarHorse.IsWarHorseAppearanceTab(self.lastTabIndex) then self:UpdateTabInfo(CTL.WarHorse.Horse_TabIndex.Appearance) elseif self.lastTabIndex == CTL.WarHorse.Horse_TabIndex.HorseSoul and MDL.WarHorse.GetEquippedHeroIDByHorseID(self.CurHorseConfig.HorseID) > 0 then self:UpdateTabInfo(CTL.WarHorse.Horse_TabIndex.HorseSoul) elseif self.lastTabIndex == CTL.WarHorse.Horse_TabIndex.Equip and MDL.WarHorse.GetEquippedHeroIDByHorseID(self.CurHorseConfig.HorseID) > 0 then self:UpdateTabInfo(CTL.WarHorse.Horse_TabIndex.Equip) else self:UpdateTabInfo(CTL.WarHorse.Horse_TabIndex.Break) end self:UpdateInfo(false) end function UIWarHorseBasePanel:OnCellInit(scrollRect, index, cellTable, data) if scrollRect == self.loop_Hero then UTL.Item.ItemSquareIconByHeroId(data, cellTable.img_Hero, cellTable.bg_Hero, nil, MDL.HeroAwaken.GetIsHeroAwaken(data)) local hasHero = MDL.HeroSelect.IsHasHero(data) UIUtils.SetActive(cellTable.img_Gray, not hasHero) -- 只有当英雄和坐骑全都激活才不显示蒙版 local activeInfo = MDL.WarHorse.GetInfoByID(self.CurHorseConfig.HorseID) local equipHero = (activeInfo and activeInfo.HeroID) and activeInfo.HeroID or 0 UIUtils.SetActive(cellTable.effect_Active, equipHero == data) end end function UIWarHorseBasePanel:OnCellClicked(scrollRect, index, cellTable, target, data) if scrollRect == self.loop_Hero then if target == cellTable.btn_Click then UIManager.OpenView(Const_UI_Lua.UIEnum.UIWarHorseRelationPopUp, { horseID = self.CurHorseConfig.HorseID }) return end end end function UIWarHorseBasePanel:UpdateHorseRelationLoop() if self.lastTabIndex == CTL.WarHorse.Horse_TabIndex.Appearance or self.lastTabIndex == CTL.WarHorse.Horse_TabIndex.HorseSoul or self.lastTabIndex == CTL.WarHorse.Horse_TabIndex.Equip then UIUtils.SetActive(self.group_Hero_Btn, false) return end if not self.CurHorseConfig then return end -- 刷新英雄列表 if not self.HorseRelationHeroList then self.HorseRelationHeroList = {} end local index = 1 for _, v in CTL.WarHorse.GetHorseRelationHeroList(self.CurHorseConfig.HorseID) do self.HorseRelationHeroList[index] = v index = index + 1 end for i = #self.HorseRelationHeroList, index, -1 do table.remove(self.HorseRelationHeroList, i) end -- 若列表为空则清空loop if #self.HorseRelationHeroList == 0 then self.loop_Hero:ClearCells() UIUtils.SetActive(self.group_Hero_Btn.gameObject, false) return end UIUtils.SetActive(self.group_Hero_Btn.gameObject, true) self.loop_Hero:ReloadAll(self.HorseRelationHeroList) end function UIWarHorseBasePanel:StopHeroLightEffect(isDispose) UIHeroLightEffectTool.StopHeroLightEffect(self.heroLightEffectDatas) if isDispose then self.heroLightEffectDatas = nil end end function UIWarHorseBasePanel:BeginHeroLightEffect(heroLightEffects) for _, lightEffectID in ipairs(heroLightEffects) do if GameAppInfo.IsVersionGreaterThan19000() then UIHeroLightEffectTool.PlayHeroLightEffect(self.heroLightEffectDatas,self, 0, UIHeroLightEffectTool.PlayLightEffectFuncEnum.UI3DDriver,lightEffectID, nil) else UIHeroLightEffectTool.PlayHeroLightEffect(self.heroLightEffectDatas,self.render, 0, UIHeroLightEffectTool.PlayLightEffectFuncEnum.UI3DDriver,lightEffectID, nil) end end end function UIWarHorseBasePanel:PlayDriverModelEffect(effectPath) return UTL.UIRender.PlayPsEffect(self.modelComponentDataHandle, effectPath) end --region-------------------------------------------界面模型动画相关-------------------------------------------- local TargetNearPos = { x = 1600, y = 0, z = 1600, } local TargetFarPos = { x = 1600.18, y = 0.4, z = 1601, } local ModelAnimTime = 0.5 local ModelPos = { NotLoad = 0, FarPos = 1, NearPos = 2, } function UIWarHorseBasePanel:InitMoveModelParam() self.moveTarget = UnityEngine.GameObject.Find("HorseCamTarget").transform self:StopRepeatFunc(self.MoveModelNear) self:StopRepeatFunc(self.MoveModelFar) if self.lastTabIndex and self.lastTabIndex == CTL.WarHorse.Horse_TabIndex.HorseSoul then self:SetModelPos(TargetFarPos.x + self.fixedRatio, TargetFarPos.y, TargetFarPos.z) -- 远点 else self:SetModelPos(TargetNearPos.x + self.fixedRatio, TargetNearPos.y, TargetNearPos.z) -- 近点 end end function UIWarHorseBasePanel:MoveModelToNear() if self.modelPosType ~= ModelPos.NearPos then self:StopRepeatFunc(self.MoveModelNear) self:StopRepeatFunc(self.MoveModelFar) self:StartRepeatFunc(self.MoveModelNear, 0.02) self.modelPosType = ModelPos.NearPos end end function UIWarHorseBasePanel:MoveModelNear(deltaTime, timeSinceUpdate) if timeSinceUpdate > ModelAnimTime then self:StopRepeatFunc(self.MoveModelNear) timeSinceUpdate = ModelAnimTime end local ratio = timeSinceUpdate / ModelAnimTime local x = UTL.UIRender.GetLerpValue(self.modelPosX, TargetNearPos.x + self.fixedRatio, ratio) local y = UTL.UIRender.GetLerpValue(self.modelPosY, TargetNearPos.y, ratio) local z = UTL.UIRender.GetLerpValue(self.modelPosZ, TargetNearPos.z, ratio) self:SetModelPos(x, y, z) end function UIWarHorseBasePanel:MoveModelToFar() if self.modelPosType ~= ModelPos.FarPos then self:StopRepeatFunc(self.MoveModelNear) self:StopRepeatFunc(self.MoveModelFar) self:StartRepeatFunc(self.MoveModelFar, 0.02) self.modelPosType = ModelPos.FarPos end end function UIWarHorseBasePanel:MoveModelFar(deltaTime, timeSinceUpdate) if timeSinceUpdate > ModelAnimTime then self:StopRepeatFunc(self.MoveModelFar) timeSinceUpdate = ModelAnimTime end local ratio = timeSinceUpdate / ModelAnimTime local x = UTL.UIRender.GetLerpValue(self.modelPosX, TargetFarPos.x + self.fixedRatio, ratio) local y = UTL.UIRender.GetLerpValue(self.modelPosY, TargetFarPos.y, ratio) local z = UTL.UIRender.GetLerpValue(self.modelPosZ, TargetFarPos.z, ratio) self:SetModelPos(x, y, z) end function UIWarHorseBasePanel:SetModelPos(posX, posY, posZ) self.moveTarget:SetPosition(posX, posY, posZ) self.modelPosX = posX self.modelPosY = posY self.modelPosZ = posZ self.moveTarget:SetPosition(self.modelPosX, self.modelPosY, self.modelPosZ) end --endregion return UIWarHorseBasePanel