local GodBeast_Model = {} local god_beast_opt_pb = require('Proto.god_beast_opt_pb') local EventSystem = require('Event/EventSystem') local private = {} private.AllBeastList = {} private.talentSortedList = {} private.RequestBeastLineUp = {} GodBeast_Model.BreakState = { max = 0, -- 命轮突破满 smallBreak = 1, -- 当前小突破 bigBreak = 2 -- 当前大突破 } GodBeast_Model.ItemType = { GodBeastPiece = 1, LevelUpMaterial = 2, BreakMaterial = 3 } local IMPROVE_DENOMINATOR = 0.0001 function GodBeast_Model.OnStartup() NetManager.RegisterMsgCB(MessageEnums.MessageUpdateGodBeastLineUp, private.UpdateGodBeastLineUpResp) NetManager.RegisterMsgCB(MessageEnums.MessageGetParadiseDrop, private.GetParadiseDropResp) NetManager.RegisterMsgCB(MessageEnums.MessageUpdateParadiseDropInfo, private.UpdateParadiseDropInfoResp) NetManager.RegisterMsgCB(MessageEnums.MessageGodBeastActivate, private.GodBeastActivateResp) NetManager.RegisterMsgCB(MessageEnums.MessageGodBeastRaise, private.GodBeastRaiseResp) NetManager.RegisterMsgCB(MessageEnums.MessageGodBeastBreak, private.GodBeastBreakResp) NetManager.RegisterMsgCB(MessageEnums.MessageGodBeastLearnTalent, private.GodBeastLearnTalentResp) NetManager.RegisterMsgCB(MessageEnums.MessageGodBeastResetTalent, private.GodBeastResetTalentResp) NetManager.RegisterMsgCB(MessageEnums.MessageGodBeastSetBattleOrder, private.GodBeastSetBattleOrderRsp) for i, v in DataSheetManager.GodBeastData:GetEnumerator() do table.insert(private.AllBeastList, v) end private.CurSelectBeastID = nil -- 全部神兽数据 private.ActiveGodBeastDic = {} -- 已激活神兽 private.GodBeastSlotInfo = {} -- 神兽槽位信息 private.GodBeastParadiseInfo = {DropInfo = {}} -- 神兽福地信息 end --region ------------------------------ 基础数据接口 ------------------------------------------ -- 技能天赋升级排序规则 function private.TalentSortRule(talent1, talent2) return talent1.sortID < talent2.sortID end -- 主列表排序函数 function private.SortData(a, b) local canActiveA = GodBeast_Model.IsBeastCanActive(a.ID) local canActiveB = GodBeast_Model.IsBeastCanActive(b.ID) if (not canActiveA and not canActiveB) or (canActiveA and canActiveB) then return private.SortGodBeastOrderByLineUp(a, b) else return canActiveA end end function private.SortGodBeastOrderByLineUp(a, b) local isAInline = GodBeast_Model.IsBeastInLineup(a.ID) local isBInline = GodBeast_Model.IsBeastInLineup(b.ID) if isAInline and isBInline then return GodBeast_Model.GetFormationIndex(a.ID) < GodBeast_Model.GetFormationIndex(b.ID) elseif not isAInline and not isBInline then return private.SortBasicGodBeastOrder(a, b) else return isAInline end end function private.SortBasicGodBeastOrder(a, b) local godBeastInfoA = GodBeast_Model.GetGodBeastInfoByID(a.ID) local godBeastInfoB = GodBeast_Model.GetGodBeastInfoByID(b.ID) if (godBeastInfoA and godBeastInfoB) or (not godBeastInfoA and not godBeastInfoB)then return private.SortByQualityAndRank(a, b) else return godBeastInfoA ~= nil end end function private.SortByQualityAndRank(a, b) -- 按照品质排序 local qualityA = a.GodBeastQuality local qualityB = b.GodBeastQuality if qualityA ~= qualityB then return qualityA > qualityB else if a.SortId ~= b.SortId then return a.SortId > b.SortId else return a.ID < a.ID end end end -- 神兽槽位布阵List ---@param beastID option 根据神兽ID获取指定槽位信息 function GodBeast_Model.GetGodBeastSlotInfo(beastID) if beastID then for i, v in ipairs(private.GodBeastSlotInfo) do if v.godBeastId == beastID then return v end end else return private.GodBeastSlotInfo end end function private.SortBattleOrderBeastOrder(a, b) return a.battleOrder < b.battleOrder end --神兽出战顺序列表 function GodBeast_Model.GetGodBeastBattleOrderList() local godBeastBattleOrderList = {} for _, v in ipairs(private.GodBeastSlotInfo) do if v.godBeastId > 0 then table.insert(godBeastBattleOrderList, {battleOrder = v.battleOrder, info = v}) end end table.sort(godBeastBattleOrderList, private.SortBattleOrderBeastOrder) return godBeastBattleOrderList end -- 槽位是否有神兽 function GodBeast_Model.IsSlotHasGodBeast() for _, v in ipairs(private.GodBeastSlotInfo) do if v.godBeastId > 0 then return true end end return false end function GodBeast_Model.GetGodBeastDataByItemId(itemId) for i, v in ipairs(private.AllBeastList) do if v.PieceItem == itemId then return v end end end function GodBeast_Model.GetSlotRaiseStage(godBeastID) local slotInfo = GodBeast_Model.GetGodBeastSlotInfo(godBeastID) return slotInfo.raiseStage or 0 end function GodBeast_Model.GetSlotRaiseLevel(godBeastID) local slotInfo = GodBeast_Model.GetGodBeastSlotInfo(godBeastID) return slotInfo.raiseLevel or 0 end function GodBeast_Model.GetStarLevel(godBeastID) local godBeastInfo = GodBeast_Model.GetGodBeastInfoByID(godBeastID) return godBeastInfo ~= nil and godBeastInfo.starLevel or 0 end -- 获取已激活神兽信息 function GodBeast_Model.GetGodBeastInfoByID(beastID) return private.ActiveGodBeastDic[beastID] end -- 获取所有已激活神兽信息 function GodBeast_Model.GetActiveBeastInfoDic() return private.ActiveGodBeastDic end -- 获取神兽突破等级 function GodBeast_Model.GetGodBeastStarLevel(godBeastID) local godBeastInfo = private.ActiveGodBeastDic[godBeastID] return godBeastInfo == nil and 0 or godBeastInfo.starLevel end function GodBeast_Model.GetSortedList() table.sort(private.AllBeastList, private.SortData) return private.AllBeastList end function GodBeast_Model.GetFormationIndex(godBeastID) local slotInfo = GodBeast_Model.GetGodBeastSlotInfo(godBeastID) if not slotInfo.slotId then return 4 else return slotInfo.slotId end end function GodBeast_Model.IsBeastInLineup(beastID) for i, v in ipairs(private.GodBeastSlotInfo) do if v.godBeastId == beastID then return true end end return false end -- 是否为可激活状态 function GodBeast_Model.IsBeastCanActive(beastID) local beastActiveInfo = GodBeast_Model.GetGodBeastInfoByID(beastID) if not beastActiveInfo then local beastData = DataSheetManager.GodBeastData:GetDataByID(beastID) return MDL.Bag.GetItemCount(beastData.Item_Table[1].ItemID) >= beastData.Item_Table[1].ItemNum end return false end -- 获取神兽养成战力值(不含槽位) function GodBeast_Model.GetGodBeastDevelopGSByID(godBeastID) local activeBeastInfo = GodBeast_Model.GetGodBeastInfoByID(godBeastID) if activeBeastInfo then return private.GetProcessedGodBeastExtraFightVal(activeBeastInfo.godBeastExtraGS) + activeBeastInfo.godBeastAttrGS * 6 else local beastExcelData = DataSheetManager.GodBeastData:GetDataByID(godBeastID) return private.GetProcessedGodBeastExtraFightVal(beastExcelData.GodBeastSkillGS) + UTL.Attr.CalculateFight(beastExcelData.Attr_Table) * 6 end return 0 end -- 获取技能天赋提升加成信息 function GodBeast_Model.GetTalentSortedList(godbeastID) table.clearArray(private.talentSortedList) -- TODO 遍历获取天赋提升加成 if #private.talentSortedList > 0 then table.sort(private.talentSortedList, private.TalentSortRule) end return private.talentSortedList end -- 获取神兽AttrTableList function GodBeast_Model.GetBeastAttrList(beastID) local attrList = {} local excelData = DataSheetManager.GodBeastData:GetDataByID(beastID) for i, v in ipairs(excelData.Attr_Table) do attrList[v.AttrType] = v.AttrNum end return attrList end -- 是否是大喂养 function GodBeast_Model.IsBigLevelUp(godBeastID) local levelUpData, isSuccess, nextLevelUpData = GodBeast_Model.GetLastAndCurLevelUpData(godBeastID) local levelAttrData = DataSheetManager.GodBeastLevelUpAttr:GetDataByID(levelUpData.GodBeastAttrID) return GodBeast_Model.GetSlotRaiseStage(godBeastID) >= levelAttrData.ImproveTimes end -- 神兽当前是否可进修或喂养 function GodBeast_Model.CanRaiseUp(beastID) local slotInfo = GodBeast_Model.GetGodBeastSlotInfo(beastID) if not slotInfo then -- 未上阵 return false end local levelUpData, isSuccess, nextLevelUpData = GodBeast_Model.GetLastAndCurLevelUpData(beastID) if levelUpData.GodBeastAttrID == 0 then return false end local raiseStage = GodBeast_Model.GetSlotRaiseStage(beastID) local levelAttrData = DataSheetManager.GodBeastLevelUpAttr:GetDataByID(levelUpData.GodBeastAttrID) local isSmallRaiseUp = raiseStage < levelAttrData.ImproveTimes local costItemTb = isSmallRaiseUp and levelAttrData.Item_Table or levelUpData.Item_Table for i, item in ipairs(costItemTb) do local count = MDL.Bag.GetItemCount(item.ItemID) -- 材料不足 if count < item.ItemNum then return false end end if MDL.HeroSelect.GetTeamLevel() < levelUpData.HeroStarLimit then -- 没有达到下级要求的战队等级 return false end if not isSuccess and raiseStage >= levelAttrData.ImproveTimes then -- 最大档 return false end return true end -- 获取雷达图数据,策划需求雷达图有一个默认的小圈目前设置比率为0.2 ---@return 比例字符串 string ---@return +值数组 array local TOTAL_RAISE_COUNT = 6 function GodBeast_Model.GetPolygonData(godBeastID) local slotInfo = GodBeast_Model.GetGodBeastSlotInfo(godBeastID) local result, valResult = {}, {} local levelUpData = GodBeast_Model.GetLastAndCurLevelUpData(godBeastID) local levelUpAttData if levelUpData.GodBeastAttrID == 0 then local lastLevelUpData = DataSheetManager.GodBeastLevelUp:GetDataByLevelUpID_GodBeastLevel(levelUpData.LevelUpID, slotInfo.raiseLevel - 1) levelUpAttData = DataSheetManager.GodBeastLevelUpAttr:GetDataByID(lastLevelUpData.GodBeastAttrID) else levelUpAttData = DataSheetManager.GodBeastLevelUpAttr:GetDataByID(levelUpData.GodBeastAttrID) end local cacheRaiseDic = slotInfo.raiseAttrInfo or {} for i, typeID in ipairs(CTL.GodBeast.POLYGON_TYPE_ORDER) do for __, attr in ipairs(levelUpAttData.Attr_Table) do if attr.AttrType == typeID then -- 计算已经喂养增加过的属性,查询比例 local addCount = cacheRaiseDic[typeID] or 0 local addVal = addCount * attr.AttSingleAdd -- 比例 table.insert(result, (addCount + 2) / TOTAL_RAISE_COUNT * 5) -- 显示的值 local raiseCurVal = 0 if levelUpAttData.LastTimeID == 0 then raiseCurVal = 0 + addVal else local lastData = DataSheetManager.GodBeastLevelUpAttr:GetDataByID(levelUpAttData.LastTimeID) raiseCurVal = lastData.Attr_Table[i].AttTotal + addVal end valResult[typeID] = raiseCurVal end end end return table.concat(result, ","), valResult end --- 返回当前喂养数据, 是否有下级喂养数据, 下级喂养数据 --- @return levelUpData 返回当前喂养数据 --- @return isSuccess bool是否有下级喂养数据 --- @return nextData 下级喂养数据 function GodBeast_Model.GetLastAndCurLevelUpData(godBeastID) local raiseUpInfo = GodBeast_Model.GetGodBeastSlotInfo(godBeastID) local godBeastData = DataSheetManager.GodBeastData:GetDataByID(godBeastID) local raiseLevel = GodBeast_Model.GetSlotRaiseLevel(godBeastID) local isNextSuccess, nextData = DataSheetManager.GodBeastLevelUp:TryGetDataByLevelUpID_GodBeastLevel(godBeastData.LevelUpID, raiseLevel + 1) local levelUpData = DataSheetManager.GodBeastLevelUp:GetDataByLevelUpID_GodBeastLevel(godBeastData.LevelUpID, raiseLevel or 0) return levelUpData, isNextSuccess, nextData end --endregion --region ------------------------------ 命轮突破 ------------------------------------------ -- 获取突破当前阶段类型 -- BreakState.smallBreak -- BreakState.bigBreak -- BreakState.max function GodBeast_Model.GetBreakStateInfo(godbeastID) local breakState = GodBeast_Model.BreakState.smallBreak local beastInfo = GodBeast_Model.GetGodBeastInfoByID(godbeastID) if beastInfo then local starLevel = beastInfo.starLevel local breakStarData = DataSheetManager.GodBeastStar:GetDataByID_Star(godbeastID, starLevel) if breakStarData.WheelAttr == 0 then -- 突破到最大轮 return GodBeast_Model.BreakState.max else local isBigBreak = GodBeast_Model.GetCurBreakWheelCount(godbeastID) >= GodBeast_Model.GetBreakWheelCount(godbeastID, beastInfo.starLevel) return isBigBreak and GodBeast_Model.BreakState.bigBreak or GodBeast_Model.BreakState.smallBreak end end return breakState end -- 获取当前已突破次数 function GodBeast_Model.GetCurBreakWheelCount(godbeastID) local beastInfo = GodBeast_Model.GetGodBeastInfoByID(godbeastID) local totalCount = 0 if beastInfo then for i, v in ipairs(beastInfo.breakInfo) do totalCount = totalCount + v.pointNums end end return totalCount end -- 获取当前命轮可突破次数 function GodBeast_Model.GetBreakWheelCount(godbeastID, starLevel) local wheelAttrData = DataSheetManager.GodBeastStar:GetDataByID_Star(godbeastID, starLevel) local count = 0 for i, v in DataSheetManager.GodBeastWheelAttr:GetDataByID_AreaId_PointId(wheelAttrData.WheelAttr) do count = count + 1 end return count end -- 获取指定area的突破信息 function GodBeast_Model.GetBreakCountByArea(godBeastID, areaID) local beastInfo = GodBeast_Model.GetGodBeastInfoByID(godBeastID) if beastInfo then return beastInfo.breakInfo[areaID].pointNums end return 0 end function GodBeast_Model.CanBreak(godBeastID) local info = GodBeast_Model.GetGodBeastInfoByID(godBeastID) local breakState = GodBeast_Model.GetBreakStateInfo(godBeastID) local breakStarData = DataSheetManager.GodBeastStar:GetDataByID_Star(godBeastID, info.starLevel) if breakState > GodBeast_Model.BreakState.max then local activeItemTb if breakState == GodBeast_Model.BreakState.smallBreak then activeItemTb = DataSheetManager.GodBeastStarItemRepeat:GetDataByID(breakStarData.WheelCostRepeatID).Item_Table else activeItemTb = DataSheetManager.GodBeastStarItemRepeat:GetDataByID(breakStarData.StarCostRepeatID).Item_Table end local isEnough = true for i, item in ipairs(activeItemTb) do local count = MDL.Bag.GetItemCount(item.ItemID) if count < item.ItemNum then isEnough = false break end end return isEnough else return false end end --endregion --region ------------------------------ 布阵相关 ------------------------------------------ -- 神兽布阵界面总战力 function GodBeast_Model.GetSlotShowGS() local beastTotalGS = 0 for i = 1, 3 do beastTotalGS = beastTotalGS + private.GodBeastSlotInfo[i].showGS end return beastTotalGS end --endregion --region ------------------------------ 天赋相关 ------------------------------------------ -- 获取当前可用天赋点 function GodBeast_Model.GetCurTalentPointBeastID(godBeastID) local activeInfo = GodBeast_Model.GetGodBeastInfoByID(godBeastID) if activeInfo then return activeInfo.curTalentPoint end return 0 end -- 获取神兽当前天赋路线的学习进度 function GodBeast_Model.GetTalentPointProgress(godBeastID, levelID) local activeInfo = GodBeast_Model.GetGodBeastInfoByID(godBeastID) if activeInfo then for i, v in ipairs(activeInfo.talentInfo) do if v.talentId == levelID then return v.talentNums end end end return 0 end function GodBeast_Model.GetTalentInfo(godBeastID) local activeInfo = GodBeast_Model.GetGodBeastInfoByID(godBeastID) if activeInfo then return activeInfo.talentInfo end return nil end function GodBeast_Model.CanResetTalentPoint(godBeastID) local godBeastData = DataSheetManager.GodBeastData:GetDataByID(godBeastID) for i = 1, godBeastData.TalentCount do if GodBeast_Model.GetTalentPointProgress(godBeastID, i) >= 1 then return true end end return false end --endregion --region ------------------------------ 神兽福地相关 --------------------------------------- -- 获取神兽福地掉落 function GodBeast_Model.GetParadiseDropInfo() return private.GodBeastParadiseInfo.DropInfo end function private.SortParadiseDropByItemQuality(a, b) local itemDataA = DataSheetManager.ItemData:GetDataByID(a.ItemID) local itemDataB = DataSheetManager.ItemData:GetDataByID(b.ItemID) if itemDataA.Color == itemDataB.Color then return a.ItemID < b.ItemID else return itemDataA.Color > itemDataB.Color end end function GodBeast_Model.GetParadiseDropItemDic() local itemTbDic, itemList = {}, {} for godBeastID, info in pairs(MDL.GodBeast.GetActiveBeastInfoDic()) do local spaceData = DataSheetManager.GodBeastSpace:GetDataByGodBeastID_GodBeastStar(godBeastID, info.starLevel) for _, v in ipairs(spaceData.Item_Table) do if not itemTbDic[v.ItemID] then itemTbDic[v.ItemID] = v.ItemID table.insert(itemList, {ItemID = v.ItemID, possibility = v.ItemWeight}) end end end table.sort(itemList, private.SortParadiseDropByItemQuality) return itemList end function GodBeast_Model.IsParadiseHasDropItem() for godBeastID, itemList in pairs(private.GodBeastParadiseInfo.DropInfo) do if #itemList > 0 then return true end end return false end function GodBeast_Model.GetImproveRatio() local totalRatio = 0 for godBeastID, info in pairs(MDL.GodBeast.GetActiveBeastInfoDic()) do local spaceData = DataSheetManager.GodBeastSpace:GetDataByGodBeastID_GodBeastStar(godBeastID, info.starLevel) totalRatio = totalRatio + IMPROVE_DENOMINATOR * spaceData.AttrImprove end return totalRatio end --endregion --region ------------------------------ 辅助方法 ------------------------------------------ function private.GetBreakInfoList(breakInfo) local result = {} -- 初始化breakInfo for idx = 1, 6 do local targetInfo for _, v in ipairs(breakInfo) do if v.areaId == idx then targetInfo = v end end table.insert(result, targetInfo == nil and { areaId = idx, pointNums = 0 } or targetInfo) end return result end -- 养成信息设置辅助Function function private.SetActiveBeastInfo(developInfo) local singleBeastInfo = private.ActiveGodBeastDic[developInfo.godBeastId] UTL.Attr.ProcessProtoAttrTable(developInfo.attr.attrs) if singleBeastInfo then singleBeastInfo.godBeastId = developInfo.godBeastId singleBeastInfo.starLevel = developInfo.starLevel singleBeastInfo.curTalentPoint = developInfo.curTalentPoint singleBeastInfo.breakInfo = private.GetBreakInfoList(developInfo.breakInfo) singleBeastInfo.talentInfo = developInfo.talentInfo singleBeastInfo.godBeastAttrGS = developInfo.godBeastAttrGS singleBeastInfo.godBeastExtraGS = developInfo.godBeastExtraGS singleBeastInfo.pictorialLevel = developInfo.pictorialLevel singleBeastInfo.attr = developInfo.attr.attrs else private.ActiveGodBeastDic[developInfo.godBeastId] = { godBeastId = developInfo.godBeastId, starLevel = developInfo.starLevel, curTalentPoint = developInfo.curTalentPoint, breakInfo = private.GetBreakInfoList(developInfo.breakInfo), talentInfo = developInfo.talentInfo, godBeastAttrGS = developInfo.godBeastAttrGS, godBeastExtraGS = developInfo.godBeastExtraGS, pictorialLevel = developInfo.pictorialLevel, attr = developInfo.attr.attrs, } end end -- 槽位信息设置辅助Function function private.SetSlotInfo(info) if not private.GodBeastSlotInfo[info.slotId] then local raiseAttrInfo = {} -- 缓存属性数组 raiseAttrInfo : [attrID] = attrNum for i, v in ipairs(info.raiseAttrInfo) do raiseAttrInfo[v.attrId] = v.raiseNums end private.GodBeastSlotInfo[info.slotId] = { slotId = info.slotId, godBeastId = info.godBeastId, raiseLevel = info.raiseLevel, -- 喂养年限 raiseStage = info.raiseStage, -- 喂养次数 showGS = info.showGS, -- 槽位显示战力 raiseAttrInfo = raiseAttrInfo, -- 喂养属性养成查询字段 battleOrder = info.battleOrder, -- 出战顺序 } else local tempTb = private.GodBeastSlotInfo[info.slotId] tempTb.slotId = info.slotId tempTb.godBeastId = info.godBeastId tempTb.raiseLevel = info.raiseLevel tempTb.raiseStage = info.raiseStage tempTb.showGS = info.showGS tempTb.battleOrder = info.battleOrder if not tempTb.raiseAttrInfo then tempTb.raiseAttrInfo = {} end for i, v in ipairs(info.raiseAttrInfo) do tempTb.raiseAttrInfo[v.attrId] = v.raiseNums end end end -- 神兽福地设置辅助方法 function private.SetParadiseInfo(paradiseDropInfo) private.GodBeastParadiseInfo.dropRound = paradiseDropInfo.dropRound or 0 private.GodBeastParadiseInfo.DropInfo = {} for i, v in ipairs(paradiseDropInfo.dropInfo) do private.GodBeastParadiseInfo.DropInfo[v.godBeastId] = {} -- 该神兽掉落的多种物品 for idx, ID in ipairs(v.itemId) do table.insert(private.GodBeastParadiseInfo.DropInfo[v.godBeastId], { itemID = ID, itemNum = v.itemNum[idx] }) end end end -- 产宝轮次 function GodBeast_Model.GetDropRound() return private.GodBeastParadiseInfo.dropRound or 0 end -- 重置神兽福地掉落信息 function private.ClearParadiseDropInfo() private.GodBeastParadiseInfo.dropRound = 0 table.clear(private.GodBeastParadiseInfo.DropInfo) end -- 虚战力保持和服务器统一的战力计算值处理 function private.GetProcessedGodBeastExtraFightVal(extraVal) if extraVal == 0 or extraVal == nil then return 0 end return math.floor(extraVal / 6) * 6 end --endregion --region ------------------------------ 交互协议 ------------------------------------------ -- enterworld同步信息 function GodBeast_Model.SyncGodBeastInfo(godBeastInfo) for _, v in ipairs(godBeastInfo.developInfo) do private.SetActiveBeastInfo(v) end -- 同步神兽槽位 for i, v in ipairs(godBeastInfo.slotInfo) do private.SetSlotInfo(v) end -- 同步福地信息 private.SetParadiseInfo(godBeastInfo.paradiseInfo) MDL.Reborn.SyncRFMaterialDic(MDL.Reborn.RFMaterialType.GodBeast) EventSystem.Dispatch(EventID.UI_GodBeast_InitInfo) end -- playerChange同步更新养成信息(图鉴更新的时候会更新养成信息) function GodBeast_Model.PlayerChangeUpdateDevelopInfo(updatedDevelopInfo) for _, v in ipairs(updatedDevelopInfo) do private.SetActiveBeastInfo(v) end MDL.Reborn.SyncRFMaterialDic(MDL.Reborn.RFMaterialType.GodBeast) EventSystem.Dispatch(EventID.GodBeast_Pictorial_Update) end function GodBeast_Model.QueryGodBeastLineUp() local line = {0, 0, 0} for i, v in ipairs(GodBeast_Model.GetGodBeastSlotInfo()) do if v.godBeastId and v.godBeastId > 0 then line[i] = v.godBeastId end end GodBeast_Model.UpdateGodBeastLineUpReq(line, true) end -- 更改神兽上阵 function GodBeast_Model.UpdateGodBeastLineUpReq(beastLineup, needSave) local msg = god_beast_opt_pb.UpdateGodBeastLineUpReq() local isDirty = false for i, beastID in ipairs(beastLineup) do msg.lineUpGodBeastIds:append(beastID) end msg.needSave = needSave or false NetManager.SendMessage(MessageEnums.MessageUpdateGodBeastLineUp, msg) end function private.UpdateGodBeastLineUpResp(msg) if msg.Resp.Code == 0 then if msg.needSave then for index = 1, 3 do if not private.GodBeastSlotInfo[index] then private.GodBeastSlotInfo[index] = {} end private.GodBeastSlotInfo[index].showGS = msg.showGS[index] or 0 private.GodBeastSlotInfo[index].godBeastId = msg.lineUpGodBeastIds[index] or 0 end for i, v in ipairs(msg.slotBattleOrder) do private.GodBeastSlotInfo[v.key].battleOrder = v.value private.GodBeastSlotInfo[v.key].slotId = v.key end EventSystem.Dispatch(EventID.UI_GodBeast_FormationRefresh, msg.needSave) EventSystem.Dispatch(EventID.UI_GodBeast_RefreshDevelopRed) else EventSystem.Dispatch(EventID.UI_GodBeast_FormationRefresh, msg.needSave, msg.lineUpGodBeastIds, msg.showGS) end end end -- 神兽激活 function GodBeast_Model.GodBeastActivateReq(beastID) local msg = god_beast_opt_pb.GodBeastActivateReq() msg.godBeastId = beastID NetManager.SendMessage(MessageEnums.MessageGodBeastActivate, msg) end function private.GodBeastActivateResp(msg) if msg.Resp.Code == 0 then UIManager.OpenAndPushAll(Const_UI_Lua.UIEnum.UIGodBeastSuccess, { godBeastID = msg.developInfo.godBeastId }) private.SetActiveBeastInfo(msg.developInfo) if IsProtoDataNotNil(msg.lineUpGodBeastIds) then for index = 1, 3 do if not private.GodBeastSlotInfo[index] then private.GodBeastSlotInfo[index] = {} end private.GodBeastSlotInfo[index].showGS = msg.showGS[index] or 0 private.GodBeastSlotInfo[index].godBeastId = msg.lineUpGodBeastIds[index] or 0 end end EventSystem.Dispatch(EventID.UI_GodBeastRefresh) EventSystem.Dispatch(EventID.UI_GodBeast_RefreshDevelopRed) end end -- 领取福地掉落 function GodBeast_Model.GetParadiseDropReq() if not GodBeast_Model.IsParadiseHasDropItem() then return end local msg = god_beast_opt_pb.GetParadiseDropReq() NetManager.SendMessage(MessageEnums.MessageGetParadiseDrop, msg) end function private.GetParadiseDropResp(msg) if msg.Resp.Code == 0 then private.ClearParadiseDropInfo() EventSystem.Dispatch(EventID.UI_GodBeast_ParadiseRefresh) end end -- 刷新福地掉落信息 function GodBeast_Model.UpdateParadiseDropInfoReq() local msg = god_beast_opt_pb.UpdateParadiseDropInfoReq() NetManager.SendMessage(MessageEnums.MessageUpdateParadiseDropInfo, msg) end function private.UpdateParadiseDropInfoResp(msg) if msg.Resp.Code == 0 then private.SetParadiseInfo(msg.paradiseInfo) EventSystem.Dispatch(EventID.UI_GodBeast_ParadiseRefresh) end end -- 神兽喂养 function GodBeast_Model.GodBeastRaiseReq(ID) local msg = god_beast_opt_pb.GodBeastRaiseReq() msg.godBeastId = ID private.IsBigLevelUp = GodBeast_Model.IsBigLevelUp(ID) NetManager.SendMessage(MessageEnums.MessageGodBeastRaise, msg) end function private.GodBeastRaiseResp(msg) if msg.Resp.Code == 0 then private.SetSlotInfo(msg.slotInfo) if private.IsBigLevelUp then UIManager.OpenView( Const_UI_Lua.UIEnum.UIGodBeastBreakSuccess, { godBeastID = msg.slotInfo.godBeastId, panelType = CTL.GodBeast.SuccessPanelType.LevelUp }, Const_UI_Lua.UIEnum.UIHeroBreakSuccess ) end EventSystem.Dispatch(EventID.UI_GodBeastRefresh) EventSystem.Dispatch(EventID.UI_GodBeast_RefreshDevelopRed) end end -- 神兽聚灵(突破) function GodBeast_Model.GodBeastBreakReq(godBeastID, areaID) local msg = god_beast_opt_pb.GodBeastBreakReq() msg.godBeastId = godBeastID msg.areaId = areaID private.isBigBreakPanel = areaID == 0 NetManager.SendMessage(MessageEnums.MessageGodBeastBreak, msg) end function private.GodBeastBreakResp(msg) if msg.Resp.Code == 0 then private.SetActiveBeastInfo(msg.developInfo) if private.isBigBreakPanel then UIManager.OpenView( Const_UI_Lua.UIEnum.UIGodBeastBreakSuccess, { godBeastID = msg.developInfo.godBeastId, panelType = CTL.GodBeast.SuccessPanelType.Break }, Const_UI_Lua.UIEnum.UIHeroBreakSuccess ) MDL.Reborn.SyncRFMaterialDic(MDL.Reborn.RFMaterialType.GodBeast) CTL.Sound.PlayGameSound("UI_active_03") end EventSystem.Dispatch(EventID.UI_GodBeastRefresh) EventSystem.Dispatch(EventID.UI_GodBeast_RefreshDevelopRed) end end -- 学习天赋req ---@param levelID GodBeastTalent的levelID字段, 天赋方向 function GodBeast_Model.GodBeastLearnTalentReq(godBeastID, levelID) local msg = god_beast_opt_pb.GodBeastLearnTalentReq() msg.godBeastId = godBeastID msg.talentId = levelID NetManager.SendMessage(MessageEnums.MessageGodBeastLearnTalent, msg) end function private.GodBeastLearnTalentResp(msg) if msg.Resp.Code == 0 then private.SetActiveBeastInfo(msg.developInfo) CTL.Sound.PlayGameSound("UI_breakout_01") local isReset = false EventSystem.Dispatch(EventID.UI_GodBeastTalentRefresh, isReset) EventSystem.Dispatch(EventID.UI_GodBeast_RefreshDevelopRed) end end -- 重置天赋req function GodBeast_Model.GodBeastResetTalentReq(godBeastID) local msg = god_beast_opt_pb.GodBeastResetTalentReq() msg.godBeastId = godBeastID NetManager.SendMessage(MessageEnums.MessageGodBeastResetTalent, msg) end function private.GodBeastResetTalentResp(msg) if msg.Resp.Code == 0 then private.SetActiveBeastInfo(msg.developInfo) local isReset = true EventSystem.Dispatch(EventID.UI_GodBeastTalentRefresh, isReset) EventSystem.Dispatch(EventID.UI_GodBeast_RefreshDevelopRed) end end -- 设置出战req function GodBeast_Model.GodBeastSetBattleOrderReq(slotList) local msg = god_beast_opt_pb.GodBeastSetBattleOrderReq() for i, slotId in ipairs(slotList) do msg.order:append(slotId) -- 槽位id,下标从小到大为上阵顺序 end NetManager.SendMessage(MessageEnums.MessageGodBeastSetBattleOrder, msg) end function private.GodBeastSetBattleOrderRsp(msg) if msg.Resp.Code == 0 then for i, slotId in ipairs(msg.newSlotOrder) do private.GodBeastSlotInfo[slotId].battleOrder = i end end end --endregion ---------------------------------------------------------------------------------------------- return GodBeast_Model