local GodBeast_Controller = {} local EventSystem = require('Event/EventSystem') local private = {} local TIMER_REFRESH_ID_ARR = DataSheetManager.ConstData:GetDataByID("GodBeastParadiseTimeRefresh").IntListValue local LEVELUP_STEP_YEAR = 100 GodBeast_Controller.POLYGON_TYPE_ORDER = { 2, 9, 8, 1, 5, 4 } -- 喂养雷达图属性顺序 GodBeast_Controller.BREAK_ORDER_INDEX = { 2, 11, 10, 3, 7, 6 } -- 突破属性顺时针顺序 GodBeast_Controller.LATE_EXECUTE_SECOND = 1 -- 突破和喂养大延迟执行秒数 GodBeast_Controller.SuccessPanelType = { Break = 0, LevelUp = 1, } GodBeast_Controller.BaseViewType = { Detail = Const_UI_Lua.UIEnum.UIGodBeastInfo, -- 信息 LevelUp = Const_UI_Lua.UIEnum.UIGodBeastLevelUp, -- 喂养页签 Break = Const_UI_Lua.UIEnum.UIGodBeastBreak, -- 突破 Talent = Const_UI_Lua.UIEnum.UIGodBeastTalent,-- 天赋 } function GodBeast_Controller.OnStartup() EventSystem.Regist(EventID.UI_GodBeast_InitInfo, private.OnRefreshRed) EventSystem.Regist(EventID.BagItem_Update, private.OnRefreshRed) EventSystem.Regist(EventID.UI_GodBeast_RefreshDevelopRed, private.OnRefreshRed) EventSystem.Regist(EventID.UI_GodBeast_ParadiseRefresh, private.OnRefreshRed) EventSystem.Regist(EventID.UI_GodBeast_InitInfo, private.OnUpdateParadiseTimer) private.paradiseRefreshTimerHandle = nil end function GodBeast_Controller.OpenViewByItemId(itemID) local itemCfgData = DataSheetManager.ItemData:GetDataByID(itemID); local param = {} local godBeastID for i, v in DataSheetManager.GodBeastData:GetEnumerator() do if v.PieceItem == itemID then godBeastID = v.ID break end end if itemCfgData.SecondType == MDL.GodBeast.ItemType.GodBeastPiece then param.id = godBeastID param.toggleType = GodBeast_Controller.BaseViewType.Break elseif itemCfgData.SecondType == MDL.GodBeast.ItemType.LevelUpMaterial then param.toggleType = GodBeast_Controller.BaseViewType.LevelUp elseif itemCfgData.SecondType == MDL.GodBeast.ItemType.BreakMaterial then param.toggleType = GodBeast_Controller.BaseViewType.Break end UIManager.OpenAndPushAll(Const_UI_Lua.UIEnum.UIGodBeastBasePanel, param) end function GodBeast_Controller.SetParadiseFixedResolutionFov(modelHandle) local screenWidth, screenHeight = UIUtils.GetScreenSize(1, 1) local ratio = screenWidth/screenHeight if ratio <= 1.146 then UTL.UIRender.SetCameraParam(modelHandle, nil, nil, 53) elseif ratio <= 1.334 then UTL.UIRender.SetCameraParam(modelHandle, nil, nil, 45) elseif ratio <= 1.668 then UTL.UIRender.SetBgTextureFitScreen(modelHandle, 1.5) UTL.UIRender.SetCameraParam(modelHandle, nil, nil, 40) else UTL.UIRender.SetCameraParam(modelHandle, nil, nil, 35) end end function GodBeast_Controller.SetFormationResolutionFov(modelHandle) local screenWidth, screenHeight = UIUtils.GetScreenSize(1, 1) local ratio = screenWidth/screenHeight if ratio <= 1.146 then UTL.UIRender.SetCameraParam(modelHandle, nil, nil, 55) elseif ratio <= 1.668 then UTL.UIRender.SetBgTextureFitScreen(modelHandle, 1.5) UTL.UIRender.SetCameraParam(modelHandle, nil, nil, 45) else UTL.UIRender.SetCameraParam(modelHandle, nil, nil, 35) end end --- @return 养成界面3D模型展示所需参数 --- modelPath --- modelPreviewLight --- posArr --- rotVal --- scaleVal --- groundScale --- showEffectPath --- idleAnimationClip [optional] function GodBeast_Controller.GetDevelopModelData(godBeastID) local godBeastData = DataSheetManager.GodBeastData:GetDataByID(godBeastID) local godBeastModelData = DataSheetManager.MonsterModelData:GetDataByID(godBeastData.GodBeastModelID) return godBeastModelData.Path, godBeastData.GodBeastPreviewModelLight, godBeastData.ModelXYZ, godBeastData.ModelScale, godBeastData.ModelRot, godBeastData.GroundScale, godBeastData.GodBeastShowEffect, godBeastData.ModelIdleAnim end function GodBeast_Controller.GetFormationModelParam(godBeastID, index) local godBeastData = DataSheetManager.GodBeastData:GetDataByID(godBeastID) if index == 1 then return godBeastData.FormationModelPosOffset1, godBeastData.FormationModelRot1 elseif index == 2 then return godBeastData.FormationModelPosOffset2, godBeastData.FormationModelRot2 else return godBeastData.FormationModelPosOffset3, godBeastData.FormationModelRot3 end end function private.OnUpdateParadiseTimer() local leftTime = GodBeast_Controller.GetParadiseNextRefreshTimestamp() if private.paradiseRefreshTimerHandle then TimerUtil.Remove(private.paradiseRefreshTimerHandle) end private.paradiseRefreshTimerHandle = TimerUtil.Interval(private.OnTriggerParadiseTimer, leftTime + 1, 1) end function private.OnTriggerParadiseTimer() if MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.GodBeast) then MDL.GodBeast.UpdateParadiseDropInfoReq() end private.OnUpdateParadiseTimer() end ---@return 返回最近的一个午夜12点或者24点的秒数 function GodBeast_Controller.GetParadiseNextRefreshTimestamp() local midInterval, noonInterVal = UTL.Time.GetServerIntervalTimeByTimeId(TIMER_REFRESH_ID_ARR[1]), UTL.Time.GetServerIntervalTimeByTimeId(TIMER_REFRESH_ID_ARR[2]) local result = 0 if midInterval < 0 and noonInterVal < 0 then local firstTimeStamp = UTL.Time.GetConfigTimestampById(TIMER_REFRESH_ID_ARR[1]) firstTimeStamp = firstTimeStamp + UTL.Time.TotalSecondsOneDay result = firstTimeStamp - UTL.Time.GetServerTimestamp() elseif midInterval < 0 or noonInterVal < 0 then result = math.max(midInterval, noonInterVal) else result = math.min(midInterval, noonInterVal) end return result >= 0 and result or 0 end function GodBeast_Controller.SetStarLevelText(txt_BreakStar, starLevel) if GameAppInfo.IsChinesePackage() then UIUtils.SetLabel(txt_BreakStar, string.FormatByIdsId(Const_IDS.IDS_Godbeast_FateWheelLevel1, starLevel)) else if starLevel > 0 then UIUtils.SetLabel(txt_BreakStar, string.FormatByIdsId(Const_IDS.IDS_HeroFund_BreakNum, starLevel)) else UIUtils.SetLabel(txt_BreakStar, nil) end end end -- 打开技能预览弹窗 function GodBeast_Controller.OpenSkillPreviewPanel(beastID) UIManager.OpenView(Const_UI_Lua.UIEnum.UIGodBeastTalentSkillTips, { godBeastID = beastID }) end function GodBeast_Controller.SetGodBeastName(txt_Name, godBeastID) local godBeastData = DataSheetManager.GodBeastData:GetDataByID(godBeastID) if txt_Name then UIUtils.SetLabel(txt_Name, UTL.Color.FormatQualityText(UIUtils.GetLocalizedTxt(Const_IDS[godBeastData.GodBeastName]), godBeastData.GodBeastQuality)) end end -- 设置神兽技能信息 function GodBeast_Controller.SetSkillInfo(iconImg, txt_Name, txt_Desc, godBeastID) local godBeastData = DataSheetManager.GodBeastData:GetDataByID(godBeastID) if iconImg then UIUtils.SetImageByAssetBundle(iconImg, godBeastData.SkillIcon) end if txt_Name then -- 名称 UIUtils.SetLabelText(txt_Name, Const_IDS[godBeastData.SkillName]) end if txt_Desc then -- 描述 UIUtils.SetLabel(txt_Desc, UTL.String.FormatCombineTextByID(godBeastData.SkillDesc)) end end function GodBeast_Controller.GetLevelUpYearText(raiseLevel) return string.FormatByIdsId(Const_IDS.IDS_Godbeast_LevelUp9, (raiseLevel or 0) * LEVELUP_STEP_YEAR) end --region 神兽红点 function private.OnRefreshRed() -- 福地有掉落可领 private.RefreshDevelopRed() private.RefreshFormationRed() end function private.RefreshFormationRed() if MDL.GodBeast.IsParadiseHasDropItem() or GodBeast_Controller.IsFormationDevelopRed() or GodBeast_Controller.IsDevelopEntryRed() then CTL.RedPoint.AddRedPoint(CTL.RedPoint.RedPointKey.Formation_GodBeast) else CTL.RedPoint.RemoveRedPoint(CTL.RedPoint.RedPointKey.Formation_GodBeast) end end function private.RefreshDevelopRed() if GodBeast_Controller.IsDevelopEntryRed() then CTL.RedPoint.AddRedPoint(CTL.RedPoint.RedPointKey.GodBeast) else CTL.RedPoint.RemoveRedPoint(CTL.RedPoint.RedPointKey.GodBeast) end end -- 布阵界面中的神兽列表按钮是否显示红点 function GodBeast_Controller.IsFormationDevelopRed() for idx, slotInfo in ipairs(MDL.GodBeast.GetGodBeastSlotInfo()) do if slotInfo.godBeastId and slotInfo.godBeastId > 0 and GodBeast_Controller.IsBeastGodDevelopRed(slotInfo.godBeastId) then return true end end return false end -- 单个神兽是否有红点 function GodBeast_Controller.IsBeastGodDevelopRed(godBeastID) local activeBeastInfo = MDL.GodBeast.GetGodBeastInfoByID(godBeastID) if activeBeastInfo then if MDL.GodBeast.GetCurTalentPointBeastID(godBeastID) > 0 or MDL.GodBeast.CanRaiseUp(godBeastID) or MDL.GodBeast.CanBreak(godBeastID) then return true end else return false end end function GodBeast_Controller.IsDevelopEntryRed() local activeBeastDic = MDL.GodBeast.GetActiveBeastInfoDic() for i, godBeastData in ipairs(MDL.GodBeast.GetSortedList()) do local godBeastID = godBeastData.ID if MDL.GodBeast.IsBeastCanActive(godBeastID) or GodBeast_Controller.IsBeastGodDevelopRed(godBeastID) then return true end end return false end --endregion return GodBeast_Controller