PGRData/Script/matrix/xentity/xcollectionwall/XCollectionWall.lua

148 lines
3.7 KiB
Lua
Raw Normal View History

local XCollectionWall = XClass(nil, "XCollectionWall")
--[[
XCollectionWall =
{
1Id, -- CollectionWall表的Id标识
2IsShow, -- 是否展示boolean值
3State, -- 墙的状态类型为XCollectionWallConfigs.EnumWallState(服务器不派发,需要客户端自己计算并更新)
4BackgroundId, -- 背景Id关联表CollectionWallDecoration
5PedestalId, -- 底座Id关联表CollectionWallDecoration
6CollectionSetInfos = -- 墙上摆放的收藏品
{
index = {
Id, -- 收藏品Id
X, -- 坐标X
Y, -- 坐标Y
SizeId -- 尺寸Id
}
},
-- 存储在config中的数据
7Rank, -- 排序值
8Name, -- 墙的名称
9Condition, -- 解锁条件
}
--]]
function XCollectionWall:Ctor(id)
self.Id = id
self.IsShow = true
self.State = XCollectionWallConfigs.EnumWallState.Lock
self.BackgroundId = 0
self.PedestalId = 0
self.CollectionSetInfos = {}
end
---
--- 根据'data'的内容来更新相应的属性
--- 需要注意的是key的名称和类型要与属性一致
---@param date table
function XCollectionWall:UpdateDate(date)
for key, value in pairs(date) do
self[key] = value
end
end
---
--- 1、获取Id
---@return number
function XCollectionWall:GetId()
return self.Id
end
---
--- 2、获取是否展示属性
---@return boolean
function XCollectionWall:GetIsShow()
return self.IsShow
end
---
--- 3、获取状态
---@return boolean
function XCollectionWall:GetState()
return self.State
end
---
--- 4、获取背景Id
---@return number
function XCollectionWall:GetBackgroundId()
if self.BackgroundId <= 0 then
XLog.Error("XCollectionWall:GeBackground函数错误BackgroundId数据未更新")
return self:GetCfg().InitBackgroundId
else
return self.BackgroundId
end
end
---
--- 5、获取底座Id
---@return number
function XCollectionWall:GetPedestalId()
if self.PedestalId <= 0 then
XLog.Error("XCollectionWall:GePedestal函数错误PedestalId数据未更新")
return self:GetCfg().InitPedestalId
else
return self.PedestalId
end
end
---
--- 6、获取摆放的收藏品数组,数据结构在开头的注释说明中有写明
---@return number
function XCollectionWall:GetCollectionSetInfos()
return self.CollectionSetInfos
end
function XCollectionWall:GetWallPicture(cb)
if not cb then
XLog.Error("The ScreenShot API Must Need CallBack")
return
end
local fileName = XDataCenter.CollectionWallManager.GetCaptureImgName(self.Id)
local textureCache = XDataCenter.CollectionWallManager.GetLocalCaptureCache(fileName)
if textureCache then
cb(textureCache)
return
end
CS.XTool.LoadLocalCaptureImgWithoutSuffix(fileName, function(texture)
XDataCenter.CollectionWallManager.SetLocalCaptureCache(fileName, texture)
cb(texture)
end)
end
-----------------------------------------------存储在config中的数据--------------------------------------------------------
function XCollectionWall:GetCfg()
return XCollectionWallConfigs.GetCollectionWallCfg(self.Id)
end
---
--- 7、从配表中获取排序值
---@return number
function XCollectionWall:GetRank()
return self:GetCfg().Rank
end
---
--- 8、从配表中获取名称
---@return string
function XCollectionWall:GetName()
return self:GetCfg().Name
end
---
--- 9、从配表中获取解锁条件
---@return number
function XCollectionWall:GetCondition()
return self:GetCfg().Condition
end
return XCollectionWall