PGRData/Script/matrix/xentity/xgoldenminer/settle/XGoldenMinerSettlementInfo.lua

176 lines
5.7 KiB
Lua
Raw Normal View History

local XGoldenMinerGrabDataInfo = require("XEntity/XGoldenMiner/Settle/XGoldenMinerGrabDataInfo")
2024-09-01 22:49:41 +02:00
local XGoldenMinerHideTaskInfo = require("XEntity/XGoldenMiner/Settle/XGoldenMinerHideTaskInfo")
local type = type
--关卡结算数据
2024-09-01 22:49:41 +02:00
---@class XGoldenMinerSettlementInfo
local XGoldenMinerSettlementInfo = XClass(nil, "XGoldenMinerSettlementInfo")
local Default = {
_Scores = 0, --当前关卡得分
_SettlementItems = {}, --结算后的道具产出消耗状态
_LaunchingClawCount = 0, --发射钩爪次数
_CostTime = 0, --消耗的时间
_GrabDataInfos = {}, --抓取物获取数
2024-09-01 22:49:41 +02:00
_MoveCount = 0, --玩家移动次数2.0运营提出的记录需求
_HideTaskInfoList = {}, --隐藏任务3.0运营提出的记录需求
}
function XGoldenMinerSettlementInfo:Ctor()
self:Init()
end
function XGoldenMinerSettlementInfo:Init()
for key, value in pairs(Default) do
if type(value) == "table" then
self[key] = {}
else
self[key] = value
end
end
end
2024-09-01 22:49:41 +02:00
--region Setter
function XGoldenMinerSettlementInfo:SetScores(scores)
self._Scores = scores
end
2024-09-01 22:49:41 +02:00
---@param itemChangeInfo XGoldenMinerItemChangeInfo
function XGoldenMinerSettlementInfo:InsertSettlementItem(itemChangeInfo)
table.insert(self._SettlementItems, itemChangeInfo)
end
function XGoldenMinerSettlementInfo:AddLaunchingClawCount()
self._LaunchingClawCount = self._LaunchingClawCount + 1
end
function XGoldenMinerSettlementInfo:SetCostTime(costTime)
self._CostTime = costTime
end
2024-09-01 22:49:41 +02:00
function XGoldenMinerSettlementInfo:SetMoveCount(moveCount)
self._MoveCount = moveCount
end
--goldenMinerObjectList当前地图拉回物品列表
function XGoldenMinerSettlementInfo:UpdateGrabDataInfos(goldenMinerObjectList)
local grabDataInfo
local stoneId
for i, goldenMinerObj in ipairs(goldenMinerObjectList) do
stoneId = goldenMinerObj:GetId()
grabDataInfo = self._GrabDataInfos[stoneId]
if not grabDataInfo then
grabDataInfo = XGoldenMinerGrabDataInfo.New(stoneId)
self._GrabDataInfos[stoneId] = grabDataInfo
end
grabDataInfo:AddData(goldenMinerObj)
end
end
2024-09-01 22:49:41 +02:00
---@param grabbedStoneEntityList XGoldenMinerEntityStone[]
function XGoldenMinerSettlementInfo:UpdateGrabDataInfosByEntityList(grabbedStoneEntityList)
if XTool.IsTableEmpty(grabbedStoneEntityList) then
return
end
---@type XGoldenMinerGrabDataInfo
local grabDataInfo
local stoneId
for i, stoneEntity in ipairs(grabbedStoneEntityList) do
stoneId = stoneEntity.Data:GetId()
grabDataInfo = self._GrabDataInfos[stoneId]
if not grabDataInfo then
grabDataInfo = XGoldenMinerGrabDataInfo.New(stoneId)
self._GrabDataInfos[stoneId] = grabDataInfo
end
grabDataInfo:AddDataByStoneEntity(stoneEntity)
end
end
---@param hideTaskInfoList XGoldenMinerHideTaskInfo[]
function XGoldenMinerSettlementInfo:UpdateHideTaskInfoList(hideTaskInfoList)
---@type XGoldenMinerHideTaskInfo[]
self._HideTaskInfoList = {}
if XTool.IsTableEmpty(hideTaskInfoList) then
return
end
for _, hideTaskInfo in ipairs(hideTaskInfoList) do
---@type XGoldenMinerHideTaskInfo[]
local info = XGoldenMinerHideTaskInfo.New(hideTaskInfo:GetId())
info:SetCurProgress(hideTaskInfo:GetCurProgress())
self._HideTaskInfoList[#self._HideTaskInfoList + 1] = info
end
end
--endregion
--region Getter
function XGoldenMinerSettlementInfo:GetScores()
return math.floor(self._Scores)
end
2024-09-01 22:49:41 +02:00
---@return XGoldenMinerItemChangeInfo[]
function XGoldenMinerSettlementInfo:GetSettlementItems()
return self._SettlementItems
end
function XGoldenMinerSettlementInfo:GetLaunchingClawCount()
return self._LaunchingClawCount
end
function XGoldenMinerSettlementInfo:GetCostTime()
return self._CostTime
end
function XGoldenMinerSettlementInfo:GetGrabDataInfos()
return self._GrabDataInfos
end
2024-09-01 22:49:41 +02:00
function XGoldenMinerSettlementInfo:GetHideTaskInfoList()
return self._HideTaskInfoList
end
function XGoldenMinerSettlementInfo:GetMoveCount()
return self._MoveCount
end
--获得转换后发给后端的数据
function XGoldenMinerSettlementInfo:GetReqServerData()
local settlementInfoTemp = {}
settlementInfoTemp.Scores = self:GetScores()
settlementInfoTemp.LaunchingClawCount = self:GetLaunchingClawCount()
settlementInfoTemp.CostTime = self:GetCostTime()
2024-09-01 22:49:41 +02:00
settlementInfoTemp.MoveCount = self:GetMoveCount()
settlementInfoTemp.SettlementItems = {}
for i, itemChangeInfo in ipairs(self:GetSettlementItems()) do
settlementInfoTemp.SettlementItems[i] = {}
settlementInfoTemp.SettlementItems[i].ItemId = itemChangeInfo:GetItemId()
settlementInfoTemp.SettlementItems[i].Status = itemChangeInfo:GetStatus()
settlementInfoTemp.SettlementItems[i].GridIndex = itemChangeInfo:GetGridIndex()
end
settlementInfoTemp.GrabDataInfos = {}
for _, grabDataInfo in pairs(self:GetGrabDataInfos()) do
local grabDataInfoTemp = {}
grabDataInfoTemp.ItemId = grabDataInfo:GetItemId()
grabDataInfoTemp.Scores = grabDataInfo:GetScores()
grabDataInfoTemp.Count = grabDataInfo:GetCount()
grabDataInfoTemp.AdditionalItem = grabDataInfo:GetAdditionalItem()
table.insert(settlementInfoTemp.GrabDataInfos, grabDataInfoTemp)
end
2024-09-01 22:49:41 +02:00
settlementInfoTemp.UpdateTaskInfo = {}
for _, hideTaskInfo in pairs(self:GetHideTaskInfoList()) do
local taskInfo = {}
taskInfo.Id = hideTaskInfo:GetId()
taskInfo.Progress = hideTaskInfo:GetCurProgress()
table.insert(settlementInfoTemp.UpdateTaskInfo, taskInfo)
end
return settlementInfoTemp
end
2024-09-01 22:49:41 +02:00
--endregion
return XGoldenMinerSettlementInfo