2023-07-14 19:35:33 +00:00
|
|
|
|
local XRpgMakerGameObject = require("XEntity/XRpgMakerGame/Object/XRpgMakerGameObject")
|
|
|
|
|
|
|
|
|
|
local type = type
|
|
|
|
|
local pairs = pairs
|
|
|
|
|
|
|
|
|
|
local Default = {
|
|
|
|
|
_OpenStatus = 0, --状态,1开启,0关闭
|
|
|
|
|
}
|
|
|
|
|
|
2024-09-01 20:49:41 +00:00
|
|
|
|
---推箱子终点对象
|
|
|
|
|
---@class XRpgMakerGameEndPoint : XRpgMakerGameObject
|
2023-07-14 19:35:33 +00:00
|
|
|
|
local XRpgMakerGameEndPoint = XClass(XRpgMakerGameObject, "XRpgMakerGameEndPoint")
|
|
|
|
|
|
|
|
|
|
function XRpgMakerGameEndPoint:Ctor(id)
|
|
|
|
|
for key, value in pairs(Default) do
|
|
|
|
|
if type(value) == "table" then
|
|
|
|
|
self[key] = {}
|
|
|
|
|
else
|
|
|
|
|
self[key] = value
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2024-09-01 20:49:41 +00:00
|
|
|
|
function XRpgMakerGameEndPoint:InitData(mapObjData)
|
2023-07-14 19:35:33 +00:00
|
|
|
|
self.StatusIsChange = false --新的状态是否和旧的不同
|
2024-09-01 20:49:41 +00:00
|
|
|
|
-- local endPointId = XRpgMakerGameConfigs.GetRpgMakerGameEndPointId(mapId)
|
|
|
|
|
-- local pointX = XRpgMakerGameConfigs.GetRpgMakerGameEndPointX(endPointId)
|
|
|
|
|
-- local pointY = XRpgMakerGameConfigs.GetRpgMakerGameEndPointY(endPointId)
|
|
|
|
|
-- local endPointType = XRpgMakerGameConfigs.GetRpgMakerGameEndPointType(endPointId)
|
|
|
|
|
-- self:SetId(endPointId)
|
|
|
|
|
|
|
|
|
|
self.MapObjData = mapObjData
|
|
|
|
|
local pointX = mapObjData:GetX()
|
|
|
|
|
local pointY = mapObjData:GetY()
|
|
|
|
|
local endPointType = mapObjData:GetParams()[1]
|
2023-07-14 19:35:33 +00:00
|
|
|
|
|
|
|
|
|
self:UpdatePosition({PositionX = pointX, PositionY = pointY})
|
|
|
|
|
self:UpdateData({OpenStatus = endPointType})
|
|
|
|
|
end
|
|
|
|
|
|
2024-09-01 20:49:41 +00:00
|
|
|
|
---@return XMapObjectData
|
|
|
|
|
function XRpgMakerGameEndPoint:GetMapObjData()
|
|
|
|
|
return self.MapObjData
|
|
|
|
|
end
|
|
|
|
|
|
2023-07-14 19:35:33 +00:00
|
|
|
|
function XRpgMakerGameEndPoint:UpdateData(data)
|
|
|
|
|
self:SetStatusIsChange(self._OpenStatus ~= data.OpenStatus)
|
|
|
|
|
self._OpenStatus = data.OpenStatus
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function XRpgMakerGameEndPoint:SetStatusIsChange(isChange)
|
|
|
|
|
self.StatusIsChange = isChange
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function XRpgMakerGameEndPoint:IsOpen()
|
|
|
|
|
return self._OpenStatus == XRpgMakerGameConfigs.XRpgMakerGameEndPointType.DefaultOpen
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function XRpgMakerGameEndPoint:EndPointOpen()
|
|
|
|
|
self:SetStatusIsChange(true)
|
|
|
|
|
self._OpenStatus = XRpgMakerGameConfigs.XRpgMakerGameEndPointType.DefaultOpen
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function XRpgMakerGameEndPoint:UpdateObjStatus()
|
|
|
|
|
self:PlayEndPointStatusChangeAction()
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function XRpgMakerGameEndPoint:PlayEndPointStatusChangeAction(action, cb)
|
|
|
|
|
local modelKey = self:IsOpen() and XRpgMakerGameConfigs.ModelKeyMaps.GoldOpen or XRpgMakerGameConfigs.ModelKeyMaps.GoldClose
|
|
|
|
|
local modelPath = XRpgMakerGameConfigs.GetRpgMakerGameModelPath(modelKey)
|
|
|
|
|
local sceneObjRoot = self:GetGameObjModelRoot()
|
|
|
|
|
self:LoadModel(modelPath, sceneObjRoot, nil, modelKey)
|
|
|
|
|
|
|
|
|
|
if self.StatusIsChange then
|
|
|
|
|
XSoundManager.PlaySoundByType(XSoundManager.UiBasicsMusic.RpgMakerGame_EndPointOpen, XSoundManager.SoundType.Sound)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
if cb then
|
|
|
|
|
cb()
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
return XRpgMakerGameEndPoint
|