877 lines
40 KiB
Lua
877 lines
40 KiB
Lua
|
|
local skynet = require "skynet"
|
|||
|
|
local oo = require "Class"
|
|||
|
|
local log = require "Log"
|
|||
|
|
local pb = require "pb"
|
|||
|
|
local dataType = require "DataType"
|
|||
|
|
local errorInfo = require "ErrorInfo"
|
|||
|
|
local House = oo.class()
|
|||
|
|
|
|||
|
|
House.OPType_House = 1 --放房间
|
|||
|
|
House.OPType_Bag = 2 --放背包
|
|||
|
|
House.OPType_Move = 3 --移动
|
|||
|
|
House.OPType_Operate = 4 --家具原地操作
|
|||
|
|
|
|||
|
|
House.DecorateStatus_Suc = 1 --成功装修
|
|||
|
|
House.DecorateStatus_Failed = 2 --部分装修
|
|||
|
|
|
|||
|
|
House.Status_Lock = 1 --未解锁
|
|||
|
|
House.Status_NoBuy = 2 --未购买
|
|||
|
|
House.Status_AlreadyBuy = 3 --已购买
|
|||
|
|
House.Status_Live = 4 --正在居住
|
|||
|
|
|
|||
|
|
House.SchemeStatus_NoBuy = 1 --装修方案未购买
|
|||
|
|
House.SchemeStatus_AlreadyBuy = 2 --装修方案已购买
|
|||
|
|
House.SchemeStatus_Use = 3 --装修方案正在使用
|
|||
|
|
|
|||
|
|
--检查一下是否有新的房子
|
|||
|
|
function House:CheckNew( player )
|
|||
|
|
local houseId = 0
|
|||
|
|
--检查房子是否有新配置
|
|||
|
|
local cfgHouse = skynet.server.gameConfig.House
|
|||
|
|
for k, houseInfo in pairs( cfgHouse ) do
|
|||
|
|
local houseId = houseInfo.id
|
|||
|
|
if not player.gameData.house[ houseId ] then
|
|||
|
|
player.gameData.house[ houseId ] = {}
|
|||
|
|
player.gameData.house[ houseId ].id = houseId
|
|||
|
|
if 4 == houseId then
|
|||
|
|
player.gameData.house[ houseId ].status = self.Status_NoBuy
|
|||
|
|
else
|
|||
|
|
player.gameData.house[ houseId ].status = self.Status_Lock
|
|||
|
|
end
|
|||
|
|
player.gameData.house[ houseId ].unlockAreaList = {}
|
|||
|
|
player.gameData.house[ houseId ].curSchemeId = 0
|
|||
|
|
player.gameData.house[ houseId ].scheme = {}
|
|||
|
|
player.gameData.house[ houseId ].isFirstEnter = true
|
|||
|
|
else
|
|||
|
|
--等级够后就解锁可以购买
|
|||
|
|
if player.gameData.level >= houseInfo.level and self.Status_Lock == player.gameData.house[ houseId ].status then
|
|||
|
|
player.gameData.house[ houseId ].status = self.Status_NoBuy
|
|||
|
|
skynet.server.msgTips:Add( player , 14 )
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
--检查该房子下有不有新方案
|
|||
|
|
for k, v in pairs( skynet.server.gameConfig.Scheme ) do
|
|||
|
|
local houseId = v.value
|
|||
|
|
local schemeId = v.combineID
|
|||
|
|
if not self:IsExistScheme( player , houseId , schemeId ) then
|
|||
|
|
local status = self.SchemeStatus_NoBuy --未购买
|
|||
|
|
local moneyType , moneyCount = skynet.server.gameConfig:GetBuyMoney("Scheme" , v.id )
|
|||
|
|
if dataType.MoneyType_No == moneyType and 0 == moneyCount then
|
|||
|
|
--if dataType.MoneyType_No == v.costType and 0 == v.price then
|
|||
|
|
status = self.SchemeStatus_Use
|
|||
|
|
player.gameData.house[ houseId ].curSchemeId = schemeId
|
|||
|
|
end
|
|||
|
|
--将方案信息加载进去
|
|||
|
|
local decorate = self:InitDecorate( player , houseId )
|
|||
|
|
table.insert( player.gameData.house[ houseId ].scheme , { id = schemeId , name = v.defaultName , status = status , furniture = {} , decorate = decorate })
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
--展示
|
|||
|
|
function House:Show( player , c2sData , s2cData )
|
|||
|
|
c2sData.data = assert(pb.decode("C2SHouseShow", c2sData.data ))
|
|||
|
|
|
|||
|
|
local data = {}
|
|||
|
|
data.houseId = player.gameData.curHouseID
|
|||
|
|
data.showInfo = {}
|
|||
|
|
for k, v in pairs( player.gameData.house ) do
|
|||
|
|
table.insert( data.showInfo , { id = v.id , status = v.status })
|
|||
|
|
end
|
|||
|
|
skynet.server.msgTips:ReduceAll( player , 14 )
|
|||
|
|
s2cData.cmd = pb.enum("MsgType","CMD_S2C_HouseShow")
|
|||
|
|
s2cData.data = assert(pb.encode("S2CHouseShow", data))
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
--房子购买
|
|||
|
|
function House:Buy( player , c2sData , s2cData )
|
|||
|
|
c2sData.data = assert(pb.decode("C2SHouseBuy", c2sData.data ))
|
|||
|
|
local houseId = c2sData.data.houseId
|
|||
|
|
local data = {}
|
|||
|
|
data.houseId = houseId
|
|||
|
|
|
|||
|
|
if not houseId then
|
|||
|
|
s2cData.code = errorInfo.ErrorCode.ErrRequestParam
|
|||
|
|
else
|
|||
|
|
if self:Add( player , houseId , s2cData) then
|
|||
|
|
if player.gameData.level>=skynet.server.gameConfig.SValue.storeUnlockLvl then
|
|||
|
|
skynet.server.store:InitData(player)
|
|||
|
|
end
|
|||
|
|
log.info(string.format("玩家 %d 购买房子成功 房间ID %d " , player.basicInfo.userID , houseId ))
|
|||
|
|
else
|
|||
|
|
log.info(string.format("玩家 %d 购买房子失败 房间ID %d " , player.basicInfo.userID , houseId ))
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
s2cData.cmd = pb.enum("MsgType","CMD_S2C_HouseBuy")
|
|||
|
|
s2cData.data = assert(pb.encode("S2CHouseBuy", data))
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
--搬家
|
|||
|
|
function House:Move( player , c2sData , s2cData )
|
|||
|
|
c2sData.data = assert(pb.decode("C2SHouseMove", c2sData.data ))
|
|||
|
|
local houseId = c2sData.data.houseId
|
|||
|
|
local data = {}
|
|||
|
|
if not houseId then
|
|||
|
|
s2cData.code = errorInfo.ErrorCode.ErrRequestParam
|
|||
|
|
else
|
|||
|
|
data.houseId = houseId
|
|||
|
|
|
|||
|
|
for k1, v1 in pairs( player.gameData.house ) do
|
|||
|
|
--找到对应的房间ID并且是购买了
|
|||
|
|
if houseId == v1.id and self.Status_AlreadyBuy == v1.status then
|
|||
|
|
--将上一次房间状态改为已购买
|
|||
|
|
local lastHouseId = player.gameData.curHouseID
|
|||
|
|
local srcSchemeId = player.gameData.house[ lastHouseId ].curSchemeId
|
|||
|
|
player.gameData.house[ lastHouseId ].status = self.Status_AlreadyBuy
|
|||
|
|
--将该房间状态改为正在居住
|
|||
|
|
v1.status = self.Status_Live
|
|||
|
|
--找到对应的房间
|
|||
|
|
player.gameData.curHouseID = houseId
|
|||
|
|
--获取下该房间的花盆
|
|||
|
|
skynet.server.flowerpot:CheckExistFlowerpot( player )
|
|||
|
|
--找到该房间的方案ID
|
|||
|
|
data.schemeId = v1.curSchemeId
|
|||
|
|
--当前房子下所有方案信息
|
|||
|
|
data.schemeInfo = self:GetAllSchemeInfo( player , houseId )
|
|||
|
|
|
|||
|
|
--3号房间第一次搬进来,要给家具
|
|||
|
|
if 3 == houseId and player.gameData.house[ houseId ].isFirstEnter then
|
|||
|
|
player.gameData.house[ houseId ].isFirstEnter = false
|
|||
|
|
local goodsType = dataType.GoodsType_Furniture
|
|||
|
|
skynet.server.bag:AddGoods( player , goodsType , 199 , 1)
|
|||
|
|
skynet.server.bag:AddGoods( player , goodsType , 199 , 1)
|
|||
|
|
skynet.server.bag:AddGoods( player , goodsType , 197 , 1)
|
|||
|
|
skynet.server.bag:AddGoods( player , goodsType , 343 , 1)
|
|||
|
|
skynet.server.bag:AddGoods( player , goodsType , 197 , 1)
|
|||
|
|
skynet.server.bag:AddGoods( player , goodsType , 344 , 1)
|
|||
|
|
skynet.server.bag:AddGoods( player , goodsType , 342 , 1)
|
|||
|
|
skynet.server.bag:AddGoods( player , goodsType , 341 , 1)
|
|||
|
|
|
|||
|
|
self:AddFurniture( player , { type = goodsType , id = 199 , nowPos ={ x= -20.089 , y= 10.166} , rotateType = 0 } , 1 )
|
|||
|
|
self:AddFurniture( player , { type = goodsType , id = 199 , nowPos ={ x= 11.028 , y= 16.179} , rotateType = 0 } , 1 )
|
|||
|
|
self:AddFurniture( player , { type = goodsType , id = 197 , nowPos ={ x= 17.573 , y= 7.48} , rotateType = 0 } , 1 )
|
|||
|
|
self:AddFurniture( player , { type = goodsType , id = 343 , nowPos ={ x= 16.054 , y= 15.179} , rotateType = 0 } , 1 )
|
|||
|
|
self:AddFurniture( player , { type = goodsType , id = 197 , nowPos ={ x= -18.272 , y= 3.28} , rotateType = 0 } , 1 )
|
|||
|
|
self:AddFurniture( player , { type = goodsType , id = 344 , nowPos ={ x= 14.893 , y= 9.88} , rotateType = 1 } , 1 )
|
|||
|
|
self:AddFurniture( player , { type = goodsType , id = 342 , nowPos ={ x= -20.617 , y= 5.88} , rotateType = 0 } , 1 )
|
|||
|
|
self:AddFurniture( player , { type = goodsType , id = 341 , nowPos ={ x= -16.932 , y= 8.08} , rotateType = 0 } , 1 )
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
--当前房子和当前方案下的家具信息
|
|||
|
|
data.furnitureInfo = self:GetCurSchemeFurniture( player , houseId , v1.curSchemeId )
|
|||
|
|
data.decorateInfo = self:GetCurSchemeDecorate( player , houseId , v1.curSchemeId )
|
|||
|
|
|
|||
|
|
--根据房间ID不同,完成的任务不同
|
|||
|
|
if 1 == houseId then
|
|||
|
|
skynet.server.levelTask:Modify( player , dataType.GeneralTaskType_MoveHouse , 1 , 3)
|
|||
|
|
elseif 2 == houseId then
|
|||
|
|
skynet.server.levelTask:Modify( player , dataType.GeneralTaskType_MoveHouse , 1 , 4)
|
|||
|
|
elseif 3 == houseId then
|
|||
|
|
skynet.server.levelTask:Modify( player , dataType.GeneralTaskType_MoveHouse , 1 , 5)
|
|||
|
|
elseif 5 == houseId then
|
|||
|
|
skynet.server.levelTask:Modify( player , dataType.GeneralTaskType_MoveHouse , 1 , 6)
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
skynet.server.passCheck:Modify( player , 23 , 1 )
|
|||
|
|
--发送已经解锁的区域
|
|||
|
|
data.areaId ={}
|
|||
|
|
for areaId, v in pairs( player.gameData.house[ houseId ].unlockAreaList ) do
|
|||
|
|
if true == v then
|
|||
|
|
table.insert( data.areaId , areaId )
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
s2cData.cmd = pb.enum("MsgType","CMD_S2C_HouseMove")
|
|||
|
|
s2cData.data = assert(pb.encode("S2CHouseMove", data))
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
--购买方案
|
|||
|
|
function House:BuyScheme( player , c2sData , s2cData )
|
|||
|
|
c2sData.data = assert(pb.decode("C2SHouseBuyScheme", c2sData.data ))
|
|||
|
|
local schemeId = c2sData.data.schemeId
|
|||
|
|
local data = {}
|
|||
|
|
if not schemeId then
|
|||
|
|
s2cData.code = errorInfo.ErrorCode.ErrRequestParam
|
|||
|
|
else
|
|||
|
|
local houseId = player.gameData.curHouseID
|
|||
|
|
local houseInfo = player.gameData.house[ houseId ]
|
|||
|
|
local isExist = false
|
|||
|
|
for k, v in pairs( houseInfo.scheme ) do
|
|||
|
|
--找到对应的方案ID和已经购买的方案
|
|||
|
|
if schemeId == v.id and self.SchemeStatus_NoBuy == v.status then
|
|||
|
|
isExist = true
|
|||
|
|
--根据方案ID找到配置的ID
|
|||
|
|
local curCfgId = 0
|
|||
|
|
local cfgScheme = skynet.server.gameConfig.Scheme
|
|||
|
|
for k, v in pairs(cfgScheme) do
|
|||
|
|
if schemeId == v.combineID then
|
|||
|
|
curCfgId = v.id
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
local moneyType , moneyCount = skynet.server.gameConfig:GetBuyMoney("Scheme" , curCfgId )
|
|||
|
|
if player:MoneyChange( moneyType , -moneyCount ) then
|
|||
|
|
v.status = self.SchemeStatus_AlreadyBuy
|
|||
|
|
--v.decorate = self:InitDecorate( player , houseId , schemeId )
|
|||
|
|
--找到该房间的方案ID
|
|||
|
|
data.schemeId = schemeId
|
|||
|
|
--当前房子下所有方案信息
|
|||
|
|
data.schemeInfo = self:GetAllSchemeInfo( player , houseId )
|
|||
|
|
log.info(string.format("玩家 %d 购买方案成功 房间ID %d 方案ID %d" , player.basicInfo.userID , houseId , schemeId ))
|
|||
|
|
else
|
|||
|
|
log.info(string.format("玩家 %d 购买方案失败 货币不足 房间ID %d 方案ID %d" , player.basicInfo.userID , houseId , schemeId ))
|
|||
|
|
end
|
|||
|
|
break
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
if not isExist then
|
|||
|
|
s2cData.code = errorInfo.ErrorCode.ErrRequestParam
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
s2cData.cmd = pb.enum("MsgType","CMD_S2C_HouseBuyScheme")
|
|||
|
|
s2cData.data = assert(pb.encode("S2CHouseBuyScheme", data))
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
--切换方案
|
|||
|
|
function House:SwitchScheme( player , c2sData , s2cData )
|
|||
|
|
c2sData.data = assert(pb.decode("C2SHouseSwitchScheme", c2sData.data ))
|
|||
|
|
local schemeId = c2sData.data.schemeId
|
|||
|
|
local data = {}
|
|||
|
|
if not schemeId then
|
|||
|
|
s2cData.code = errorInfo.ErrorCode.ErrRequestParam
|
|||
|
|
else
|
|||
|
|
local houseId = player.gameData.curHouseID
|
|||
|
|
local houseInfo = player.gameData.house[ houseId ]
|
|||
|
|
if houseInfo then
|
|||
|
|
for k, v in pairs( houseInfo.scheme ) do
|
|||
|
|
--如果是使用使用状态就改为购买状态
|
|||
|
|
if self.SchemeStatus_Use == v.status then
|
|||
|
|
v.status = self.SchemeStatus_AlreadyBuy
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
--找到对应的方案ID和已经购买的方案
|
|||
|
|
if schemeId == v.id and self.SchemeStatus_AlreadyBuy == v.status then
|
|||
|
|
local srcSchemeId = player.gameData.house[ houseId ].curSchemeId
|
|||
|
|
player.gameData.house[ houseId ].curSchemeId = schemeId
|
|||
|
|
v.status = self.SchemeStatus_Use
|
|||
|
|
skynet.server.flowerpot:CheckExistFlowerpot( player )
|
|||
|
|
--找到该房间的方案ID
|
|||
|
|
data.schemeId = schemeId
|
|||
|
|
--当前房子下所有方案信息
|
|||
|
|
data.schemeInfo = self:GetAllSchemeInfo( player , houseId )
|
|||
|
|
--当前房子和当前方案下的家具信息
|
|||
|
|
data.furnitureInfo = self:GetCurSchemeFurniture( player , houseId , schemeId )
|
|||
|
|
data.decorateInfo = self:GetCurSchemeDecorate( player , houseId , schemeId )
|
|||
|
|
log.info(string.format("玩家 %d 切换方案成功 房间ID %d 方案ID %d" , player.basicInfo.userID , houseId , schemeId ))
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
else
|
|||
|
|
s2cData.code = errorInfo.ErrorCode.ErrRequestParam
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
s2cData.cmd = pb.enum("MsgType","CMD_S2C_HouseSwitchScheme")
|
|||
|
|
s2cData.data = assert(pb.encode("S2CHouseSwitchScheme", data))
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
--修改方案名称
|
|||
|
|
function House:SchemeName( player , c2sData , s2cData )
|
|||
|
|
c2sData.data = assert(pb.decode("C2SHouseSchemeName", c2sData.data ))
|
|||
|
|
local schemeId = c2sData.data.schemeId
|
|||
|
|
local name = c2sData.data.name
|
|||
|
|
local data = {}
|
|||
|
|
if not schemeId or not name or #name > 21 then
|
|||
|
|
s2cData.code = errorInfo.ErrorCode.ErrRequestParam
|
|||
|
|
else
|
|||
|
|
local isExist = false
|
|||
|
|
local houseId = player.gameData.curHouseID
|
|||
|
|
local houseInfo = player.gameData.house[ houseId ]
|
|||
|
|
if houseInfo then
|
|||
|
|
for k, v in pairs( houseInfo.scheme ) do
|
|||
|
|
--找到对应的方案ID和已经购买的方案
|
|||
|
|
if schemeId == v.id and (self.SchemeStatus_AlreadyBuy == v.status or self.SchemeStatus_Use == v.status) then
|
|||
|
|
data.schemeId = schemeId
|
|||
|
|
data.name = name
|
|||
|
|
v.name = name
|
|||
|
|
isExist = true
|
|||
|
|
log.info(string.format("玩家 %d 房子 修改方案名称 方案ID %d 修改方案名称 %s" , player.basicInfo.userID , schemeId, name))
|
|||
|
|
break
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
else
|
|||
|
|
s2cData.code = errorInfo.ErrorCode.NoExistHouse
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
if not isExist then
|
|||
|
|
s2cData.code = errorInfo.ErrorCode.NoExistSchemeID
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
s2cData.cmd = pb.enum("MsgType","CMD_S2C_HouseSchemeName")
|
|||
|
|
s2cData.data = assert(pb.encode("S2CHouseSchemeName", data))
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
--房屋摆放家具
|
|||
|
|
function House:PutFurniture( player , c2sData , s2cData )
|
|||
|
|
c2sData.data = assert(pb.decode("C2SHousePutFurniture", c2sData.data ))
|
|||
|
|
local houseId = player.gameData.curHouseID
|
|||
|
|
local funitureOp = c2sData.data.funitureOp --操作家具信息
|
|||
|
|
local data = {}
|
|||
|
|
data.houseId = houseId
|
|||
|
|
data.funitureOp = {}
|
|||
|
|
local isSuc = nil
|
|||
|
|
for k, v in pairs( funitureOp ) do
|
|||
|
|
isSuc = false
|
|||
|
|
log.info(string.format("玩家 %d 房屋摆放家具 操作类型 %d" , player.basicInfo.userID , v.opType))
|
|||
|
|
if self.OPType_House == v.opType and self:AddFurnitureToHouse( player , houseId , v.furnitureInfo ) then --新增家具到房间
|
|||
|
|
isSuc = true
|
|||
|
|
elseif self.OPType_Bag == v.opType and self:RemoveFurnitureFromHouse( player , houseId , v.furnitureInfo ) then --从房间中移出家具
|
|||
|
|
isSuc = true
|
|||
|
|
elseif self.OPType_Move == v.opType and v.lastPos and self:MoveFurnitureFromHouse( player , houseId , v.furnitureInfo , v.lastPos ) then --移动家具
|
|||
|
|
isSuc = true
|
|||
|
|
elseif self.OPType_Operate == v.opType and self:OperateFurnitureFromHouse( player , houseId , v.furnitureInfo , v.lastPos ) then --家具原地操作
|
|||
|
|
isSuc = true
|
|||
|
|
end
|
|||
|
|
if isSuc then
|
|||
|
|
table.insert( data.funitureOp , v )
|
|||
|
|
else
|
|||
|
|
log.info(string.format("玩家 %d 装修失败家具信息 操作类型 %d 家具类型 %d 家具ID %d " , player.basicInfo.userID , v.opType , v.furnitureInfo.type , v.furnitureInfo.id ))
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
s2cData.cmd = pb.enum("MsgType","CMD_S2C_HousePutFurniture")
|
|||
|
|
s2cData.data = assert(pb.encode("S2CHousePutFurniture", data))
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
--装修
|
|||
|
|
function House:Decorate( player , c2sData , s2cData )
|
|||
|
|
c2sData.data = assert(pb.decode("C2SHouseDecorate", c2sData.data ))
|
|||
|
|
local houseId = player.gameData.curHouseID
|
|||
|
|
local decorateInfo = c2sData.data.decorateInfo --装修信息
|
|||
|
|
local data = {}
|
|||
|
|
data.houseId = houseId
|
|||
|
|
data.decorateInfo = {}
|
|||
|
|
|
|||
|
|
--装修信息
|
|||
|
|
for k, v in pairs( decorateInfo ) do
|
|||
|
|
self:AddDecorate( player , v , s2cData )
|
|||
|
|
table.insert( data.decorateInfo , v )
|
|||
|
|
end
|
|||
|
|
s2cData.cmd = pb.enum("MsgType","CMD_S2C_HouseDecorate")
|
|||
|
|
s2cData.data = assert(pb.encode("S2CHouseDecorate", data))
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
--解锁区域
|
|||
|
|
function House:UnlockArea( player , c2sData , s2cData )
|
|||
|
|
c2sData.data = assert(pb.decode("C2SHouseUnlockArea", c2sData.data ))
|
|||
|
|
local data = {}
|
|||
|
|
data.areaId = {}
|
|||
|
|
local houseId = player.gameData.curHouseID
|
|||
|
|
local areaId = c2sData.data.areaId --这里的areaId需要与客户端对一下,传过来是1开始没问题,传过来是0,就需要减一
|
|||
|
|
if not areaId or areaId <= 0 then
|
|||
|
|
s2cData.code = errorInfo.ErrorCode.ErrRequestParam
|
|||
|
|
else
|
|||
|
|
s2cData.code = errorInfo.ErrorCode.AlreadyUnlock
|
|||
|
|
local cfgOneHouse = skynet.server.gameConfig:GetCurCfg("House" , houseId)
|
|||
|
|
for k, v in pairs( cfgOneHouse.unlockArearID ) do
|
|||
|
|
if v == areaId then
|
|||
|
|
if player:MoneyChange( cfgOneHouse.currencyBuy , -cfgOneHouse.unlockAreaPrice[k] ) then
|
|||
|
|
player.gameData.house[ houseId ].unlockAreaList[ areaId ] = true
|
|||
|
|
s2cData.code = errorInfo.Suc
|
|||
|
|
if 3 == houseId and 1 == areaId then --1-卫浴间 2-厨房间
|
|||
|
|
skynet.server.levelTask:Modify( player , dataType.GeneralTaskType_UnlockArea , 1 , 1 )
|
|||
|
|
elseif 3 == houseId and 2 == areaId then
|
|||
|
|
skynet.server.levelTask:Modify( player , dataType.GeneralTaskType_UnlockArea , 1 , 2 )
|
|||
|
|
end
|
|||
|
|
log.info(string.format("玩家 %d 解锁区域成功 房间ID %d 区域ID %d" , player.basicInfo.userID , houseId , areaId ))
|
|||
|
|
else
|
|||
|
|
s2cData.code = errorInfo.ErrorCode.NoEnoughMoney
|
|||
|
|
end
|
|||
|
|
break
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
--发送角已经解锁的区域
|
|||
|
|
for areaId, v in pairs( player.gameData.house[ houseId ].unlockAreaList ) do
|
|||
|
|
if true == v then
|
|||
|
|
table.insert( data.areaId , areaId )
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
s2cData.cmd = pb.enum("MsgType","CMD_S2C_HouseUnlockArea")
|
|||
|
|
s2cData.data = assert(pb.encode("S2CHouseUnlockArea", data))
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
--新增家具到房间
|
|||
|
|
function House:AddFurnitureToHouse( player , houseId , furnitureInfo )
|
|||
|
|
local type = furnitureInfo.type
|
|||
|
|
local id = furnitureInfo.id
|
|||
|
|
local isExistFlowerpot = false
|
|||
|
|
for k, v in pairs( player.gameData.bag ) do
|
|||
|
|
if type == v.type and id == v.id then
|
|||
|
|
--该家具在当前房间的数量要小于背包的数量
|
|||
|
|
local count = self:GetCurFurnitureCount( player , type , id )
|
|||
|
|
if count < v.count then
|
|||
|
|
--放到房间中
|
|||
|
|
if self:AddFurniture( player , furnitureInfo , count ) then
|
|||
|
|
isExistFlowerpot = true
|
|||
|
|
log.info(string.format("玩家 %d 增加家具到房间成功 房间ID %d 家具类型 %d 家具ID %d" , player.basicInfo.userID , houseId , type , v.id ))
|
|||
|
|
return true
|
|||
|
|
else
|
|||
|
|
log.info(string.format("玩家 %d 增加家具到房间失败 房间ID %d 家具类型 %d 家具ID %d" , player.basicInfo.userID , houseId , type , v.id ))
|
|||
|
|
return false
|
|||
|
|
end
|
|||
|
|
else
|
|||
|
|
--[[
|
|||
|
|
if dataType.GoodsType_Flowerpot == type then
|
|||
|
|
local nowPos = furnitureInfo.nowPos
|
|||
|
|
local schemeId = player.gameData.house[ houseId ].curSchemeId
|
|||
|
|
local curScheme = self:GetCurScheme( player )
|
|||
|
|
skynet.server.flowerpot:UpdateFlowerpotPos( player , houseId , schemeId , id , furnitureInfo.nowPos.x , furnitureInfo.nowPos.y)
|
|||
|
|
log.info(string.format("玩家 %d 可能已经种了花,又来新增花盆信息,所以只更新位置 房间ID %d " , player.basicInfo.userID , houseId ))
|
|||
|
|
return true
|
|||
|
|
else
|
|||
|
|
return false
|
|||
|
|
end]]
|
|||
|
|
return false
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
return false
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
--从房间中移出家具
|
|||
|
|
function House:RemoveFurnitureFromHouse( player , houseId , furnitureInfo )
|
|||
|
|
local id = furnitureInfo.id
|
|||
|
|
local type = furnitureInfo.type
|
|||
|
|
local nowPos = furnitureInfo.nowPos
|
|||
|
|
local schemeId = player.gameData.house[ houseId ].curSchemeId
|
|||
|
|
if dataType.GoodsType_Flowerpot == type then --花盆移除
|
|||
|
|
return skynet.server.flowerpot:PutBag( player , furnitureInfo )
|
|||
|
|
elseif dataType.GoodsType_Furniture == type then --家具的移除
|
|||
|
|
for k1, v1 in pairs( player.gameData.house[ houseId ].scheme ) do
|
|||
|
|
--找到对应的方案
|
|||
|
|
if schemeId == v1.id then
|
|||
|
|
--该方案下的家具
|
|||
|
|
for k2, v2 in pairs( v1.furniture ) do
|
|||
|
|
if type == v2.type and id == v2.id and skynet.server.common:Distance( nowPos.x , nowPos.y , v2.nowPos.x , v2.nowPos.y) <= 0.1 then
|
|||
|
|
table.remove( v1.furniture , k2 )
|
|||
|
|
log.info(string.format("玩家 %d 家具从房间中移出成功 房间ID %d 家具类型 %d 家具ID %d" , player.basicInfo.userID , houseId , type ,v2.id ))
|
|||
|
|
return true
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
return false
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
--在房间中移动家具
|
|||
|
|
function House:MoveFurnitureFromHouse( player , houseId , furnitureInfo , lastPos )
|
|||
|
|
local type = furnitureInfo.type
|
|||
|
|
local id = furnitureInfo.id
|
|||
|
|
local nowPos = furnitureInfo.nowPos
|
|||
|
|
local schemeId = player.gameData.house[ houseId ].curSchemeId
|
|||
|
|
local curScheme = self:GetCurScheme( player )
|
|||
|
|
log.info("MoveFurnitureFromHouse" , type,furnitureInfo.isPutInFurniture)
|
|||
|
|
--该方案下的家具
|
|||
|
|
if dataType.GoodsType_Flowerpot == type then
|
|||
|
|
return skynet.server.flowerpot:UpdateFlowerpotPos( player , houseId , schemeId , id , nowPos.x , nowPos.y , furnitureInfo.isPutInFurniture )
|
|||
|
|
elseif dataType.GoodsType_Furniture == type then
|
|||
|
|
for k, v in pairs( curScheme.furniture ) do
|
|||
|
|
local srcPosDistance = skynet.server.common:Distance( lastPos.x , lastPos.y , v.nowPos.x , v.nowPos.y) --原位置距离
|
|||
|
|
local dstPosDistance = skynet.server.common:Distance( nowPos.x , nowPos.y , v.nowPos.x , v.nowPos.y) --目标位置距离
|
|||
|
|
if type == v.type and id == v.id and srcPosDistance <= 0.1 and dstPosDistance >= 0.1 then
|
|||
|
|
v.nowPos = furnitureInfo.nowPos
|
|||
|
|
v.rotateType = furnitureInfo.rotateType
|
|||
|
|
v.isPutInFurniture = furnitureInfo.isPutInFurniture
|
|||
|
|
log.info(string.format("玩家 %d 家具从房间中移动成功 房间ID %d 家具类型 %d 家具ID %d" , player.basicInfo.userID , houseId , type ,v.id ))
|
|||
|
|
return true
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
return false
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
--家具原地操作
|
|||
|
|
function House:OperateFurnitureFromHouse( player , houseId , furnitureInfo )
|
|||
|
|
local type = furnitureInfo.type
|
|||
|
|
local id = furnitureInfo.id
|
|||
|
|
local nowPos = furnitureInfo.nowPos
|
|||
|
|
local schemeId = player.gameData.house[ houseId ].curSchemeId
|
|||
|
|
|
|||
|
|
for k1, v1 in pairs( player.gameData.house[ houseId ].scheme ) do
|
|||
|
|
--找到对应的方案
|
|||
|
|
if schemeId == v1.id then
|
|||
|
|
--该方案下的家具
|
|||
|
|
for k2, v2 in pairs( v1.furniture ) do
|
|||
|
|
if type == v2.type and id == v2.id and skynet.server.common:Distance( nowPos.x , nowPos.y , v2.nowPos.x , v2.nowPos.y) <= 0.1 then
|
|||
|
|
v2.nowPos = furnitureInfo.nowPos
|
|||
|
|
v2.rotateType = furnitureInfo.rotateType
|
|||
|
|
v2.isPutInFurniture = furnitureInfo.isPutInFurniture
|
|||
|
|
v2.clickType = furnitureInfo.clickType
|
|||
|
|
log.info(string.format("玩家 %d 家具 原地操作成功 房间ID %d 家具类型 %d 家具ID %d" , player.basicInfo.userID , houseId , type ,v2.id ))
|
|||
|
|
return true
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
return false
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
--获取当前房间该家具数量
|
|||
|
|
function House:GetCurFurnitureCount( player , type , id )
|
|||
|
|
local houseId = player.gameData.curHouseID --当前房间ID
|
|||
|
|
local schemeId = player.gameData.house[ houseId ].curSchemeId
|
|||
|
|
local count = 0
|
|||
|
|
|
|||
|
|
skynet.server.flowerpot:GetAllFlowerpot( player )
|
|||
|
|
local furnitureInfo = self:GetCurSchemeFurniture( player , houseId , schemeId )
|
|||
|
|
for k, v in pairs( furnitureInfo ) do
|
|||
|
|
if type == v.type and id == v.id then
|
|||
|
|
count = count +1
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
return count
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
--获取当前家具在所有房间所有房间最大数量
|
|||
|
|
function House:GetCurFurnitureMaxCount( player , goodsType , goodsId )
|
|||
|
|
local maxCount = 0
|
|||
|
|
--遍历所有房间
|
|||
|
|
for k1, house in pairs( player.gameData.house ) do
|
|||
|
|
--遍历该房间下所有方案
|
|||
|
|
for k2, scheme in pairs( house.scheme ) do
|
|||
|
|
--当前家具在该方案下的数量
|
|||
|
|
local count = 0
|
|||
|
|
for k3, furniture in pairs( scheme.furniture ) do
|
|||
|
|
if goodsType == furniture.type and goodsId == furniture.id then
|
|||
|
|
count = count + 1
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
--其它房间方案数量比该房间方案少,就赋值
|
|||
|
|
if maxCount < count then
|
|||
|
|
maxCount = count
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
return maxCount
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
--新增房间
|
|||
|
|
function House:Add( player , houseId , s2cData )
|
|||
|
|
local curHouse = player.gameData.house[ houseId ]
|
|||
|
|
if self.Status_NoBuy ~= curHouse.status then
|
|||
|
|
s2cData.code = errorInfo.ErrorCode.AlreadyGet
|
|||
|
|
return false
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
--只有没购买才会走这里
|
|||
|
|
local cfgHouse = skynet.server.gameConfig.House
|
|||
|
|
for k1, v1 in pairs( cfgHouse ) do
|
|||
|
|
if houseId == v1.id and player.gameData.level >= v1.level then --找到对应的房间ID和等级足购
|
|||
|
|
if player:MoneyChange( v1.currencyBuy , -v1.coin ) then
|
|||
|
|
--修改为购买状态
|
|||
|
|
player.gameData.house[ houseId ].status = self.Status_AlreadyBuy
|
|||
|
|
--赠送一些基本装修
|
|||
|
|
for k2, v2 in pairs( v1.unlockDecorate ) do
|
|||
|
|
skynet.server.bag:AddGoods( player , dataType.GoodsType_Decorate , v2 , 1 )
|
|||
|
|
end
|
|||
|
|
if 1 == houseId then
|
|||
|
|
skynet.server.levelTask:Modify( player , dataType.GeneralTaskType_UnlockHouse , 1 )
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
if 4 == houseId then --新手默认房间是居住状态
|
|||
|
|
player.gameData.house[ houseId ].status = self.Status_Live
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
if 2 == houseId or 3 == houseId then
|
|||
|
|
--解锁户型2和3才刷出阳台
|
|||
|
|
skynet.server.decorateShop:Refresh2And3Deco( player , dataType.ShopType_Decorate , {} , {} )
|
|||
|
|
elseif 5 == houseId then
|
|||
|
|
--解锁户型5才刷出阶梯和扶手
|
|||
|
|
skynet.server.decorateShop:Refresh5Deco( player , dataType.ShopType_Decorate , {} , {} )
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
return true
|
|||
|
|
else
|
|||
|
|
s2cData.code = errorInfo.ErrorCode.NoEnoughMoney
|
|||
|
|
return false
|
|||
|
|
end
|
|||
|
|
break
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
s2cData.code = errorInfo.ErrorCode.NoExistHouse
|
|||
|
|
return false
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
--初始化方案信息
|
|||
|
|
function House:InitScheme( player , houseId )
|
|||
|
|
for k, v in pairs( skynet.server.gameConfig.Scheme ) do
|
|||
|
|
if houseId == v.value then
|
|||
|
|
local status = self.SchemeStatus_NoBuy --未购买
|
|||
|
|
local moneyType , moneyCount = skynet.server.gameConfig:GetBuyMoney("Scheme" , v.id )
|
|||
|
|
if dataType.MoneyType_No == moneyType and 0 == moneyCount then
|
|||
|
|
status = self.SchemeStatus_Use
|
|||
|
|
player.gameData.house[ houseId ].curSchemeId = v.combineID
|
|||
|
|
end
|
|||
|
|
table.insert( player.gameData.house[ houseId ].scheme , { id = v.combineID , name = v.defaultName , status = status , furniture = {} })
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
--是否存在方案
|
|||
|
|
function House:IsExistScheme( player , houseId , schemeId )
|
|||
|
|
for k, v in pairs( player.gameData.house[ houseId ].scheme ) do
|
|||
|
|
if schemeId == v.id then
|
|||
|
|
return true
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
return false
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
--获取方案信息
|
|||
|
|
function House:GetAllSchemeInfo( player , houseId )
|
|||
|
|
local data = {}
|
|||
|
|
for k, v in pairs( player.gameData.house[ houseId ].scheme ) do
|
|||
|
|
table.insert( data , { id = v.id , name = v.name , status = v.status })
|
|||
|
|
end
|
|||
|
|
return data
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
--获取当前方案下的家具和花盆
|
|||
|
|
function House:GetCurSchemeFurniture( player , houseId , schemeId )
|
|||
|
|
local furnitureInfo = {}
|
|||
|
|
local curScheme = self:GetCurScheme( player )
|
|||
|
|
|
|||
|
|
--将家具和花盆打包在一起发给客户端
|
|||
|
|
for k, v in pairs( curScheme.furniture ) do
|
|||
|
|
table.insert( furnitureInfo , v )
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
for k, v in pairs( player.gameData.flowerpot ) do
|
|||
|
|
--从花盆列表中找到当前方案下的位置信息
|
|||
|
|
local flowerpotInfo = skynet.server.flowerpot:GetFlowerpot( player , v )
|
|||
|
|
if flowerpotInfo then
|
|||
|
|
table.insert( furnitureInfo , flowerpotInfo )
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
return furnitureInfo
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
--获取当前方案下的装修
|
|||
|
|
function House:GetCurSchemeDecorate( player , houseId , schemeId )
|
|||
|
|
local furnitureInfo = {}
|
|||
|
|
for k1, v1 in pairs( player.gameData.house[ houseId ].scheme ) do
|
|||
|
|
if schemeId == v1.id then
|
|||
|
|
return v1.decorate
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
return nil
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
--获取当前方案
|
|||
|
|
function House:GetCurScheme( player )
|
|||
|
|
local houseId = player.gameData.curHouseID
|
|||
|
|
local schemeId = player.gameData.house[ houseId ].curSchemeId
|
|||
|
|
for k, v in pairs( player.gameData.house[ houseId ].scheme ) do
|
|||
|
|
if schemeId == v.id then
|
|||
|
|
return v
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
return nil
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
--获取当前方案下的家具
|
|||
|
|
function House:AddFurniture( player , furnitureInfo , count )
|
|||
|
|
if dataType.GoodsType_Flowerpot == furnitureInfo.type then --花盆
|
|||
|
|
log.info("AddFurniture 摆放花盆 ", skynet.server.common:TableToString(furnitureInfo) )
|
|||
|
|
skynet.server.flowerpot:PutHouse( player , furnitureInfo.id , furnitureInfo )
|
|||
|
|
return true
|
|||
|
|
elseif dataType.GoodsType_Furniture == furnitureInfo.type then --家具
|
|||
|
|
--找到当前的方案ID
|
|||
|
|
local curScheme = self:GetCurScheme( player )
|
|||
|
|
table.insert( curScheme.furniture , self:InitFurniture( furnitureInfo ))
|
|||
|
|
--修改任务
|
|||
|
|
local cfgGoods = skynet.server.gameConfig:GetCurFurnitureCfg( furnitureInfo.id )
|
|||
|
|
if skynet.server.shop.FurnitureType_Cinnabar == cfgGoods.type then
|
|||
|
|
skynet.server.levelTask:Modify( player , 7 , 1 , nil , furnitureInfo.id)
|
|||
|
|
skynet.server.dailyTask:Modify( player , 7 , 1 , furnitureInfo.id)
|
|||
|
|
else
|
|||
|
|
skynet.server.levelTask:Modify( player , 6 , 1 , nil , furnitureInfo.id)
|
|||
|
|
skynet.server.dailyTask:Modify( player , 6 , 1 , furnitureInfo.id)
|
|||
|
|
end
|
|||
|
|
return true
|
|||
|
|
end
|
|||
|
|
return false
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
--新增装修到房间
|
|||
|
|
function House:AddDecorate( player , decorateInfo , s2cData )
|
|||
|
|
local houseId = player.gameData.curHouseID --当前房间ID
|
|||
|
|
local schemeId = player.gameData.house[ houseId ].curSchemeId
|
|||
|
|
local isSuc = false
|
|||
|
|
|
|||
|
|
--先检查玩家是否有该商品
|
|||
|
|
if not player:IsBuyGoods( dataType.GoodsType_Decorate , decorateInfo.decoId ) then
|
|||
|
|
s2cData.code = errorInfo.ErrorCode.NoExistGoodsInBag
|
|||
|
|
else
|
|||
|
|
--更新装修任务
|
|||
|
|
local cfgGoods = skynet.server.gameConfig:GetCurDecorationCfg( decorateInfo.decoId )
|
|||
|
|
skynet.server.levelTask:Modify( player , dataType.GeneralTaskType_UpdateDecorate , 1 )
|
|||
|
|
|
|||
|
|
--获取当前房间当前方案
|
|||
|
|
local schemeInfo = self:GetCurScheme( player )
|
|||
|
|
if schemeInfo then
|
|||
|
|
local isExist = false
|
|||
|
|
for k, v in pairs( schemeInfo.decorate ) do
|
|||
|
|
if v.facilityType == cfgGoods.type and decorateInfo.facilityId == v.facilityId then
|
|||
|
|
v.decoId = decorateInfo.decoId
|
|||
|
|
isExist = true
|
|||
|
|
break
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
--不存在就新增进来
|
|||
|
|
if not isExist then
|
|||
|
|
table.insert( schemeInfo.decorate , decorateInfo )
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
log.info(string.format("玩家 %d 家具 装修 房间ID %d 设施类型 %d 设施ID %d 装修ID %d" , player.basicInfo.userID , houseId , cfgGoods.type , decorateInfo.facilityId , decorateInfo.decoId))
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
--初始化家具
|
|||
|
|
function House:InitFurniture( furnitureInfo )
|
|||
|
|
local data = {}
|
|||
|
|
data.type = furnitureInfo.type
|
|||
|
|
data.id = furnitureInfo.id
|
|||
|
|
data.nowPos = furnitureInfo.nowPos
|
|||
|
|
data.rotateType = furnitureInfo.rotateType
|
|||
|
|
data.isPutInFurniture = furnitureInfo.isPutInFurniture
|
|||
|
|
data.clickType = furnitureInfo.clickType
|
|||
|
|
return data
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
--获取拥有房子的数量
|
|||
|
|
function House:GetOwnCount( player )
|
|||
|
|
local count = 0
|
|||
|
|
for k, v in pairs(player.gameData.house ) do
|
|||
|
|
if self.Status_AlreadyBuy == v.status or self.Status_Live == v.status then
|
|||
|
|
count = count + 1
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
return count
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
--从当前房间移出
|
|||
|
|
function House:RemoveFurniture( player , goodsType , goodsId )
|
|||
|
|
--获取当前房间当前方案
|
|||
|
|
local schemeInfo = self:GetCurScheme( player )
|
|||
|
|
for k, v in pairs( schemeInfo.furniture ) do
|
|||
|
|
if goodsType == v.type and goodsId == v.id then
|
|||
|
|
table.remove( schemeInfo.furniture , k )
|
|||
|
|
break
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
--初始化装修
|
|||
|
|
function House:InitDecorate( player , houseId )
|
|||
|
|
local goodsType = dataType.GoodsType_Decorate
|
|||
|
|
local decorate = {}
|
|||
|
|
if 1 == houseId then
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_WallPaper , facilityId = 1 , decoId = 23 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_WallPaper , facilityId = 2 , decoId = 23 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_Floor , facilityId = 1 , decoId = 24 })
|
|||
|
|
elseif 2 == houseId then
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_WallPaper , facilityId = 1 , decoId = 23 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_WallPaper , facilityId = 2 , decoId = 23 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_Floor , facilityId = 1 , decoId = 24 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_Floor , facilityId = 2 , decoId = 25 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_Door , facilityId = 1 , decoId = 26 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_Bar , facilityId = 1 , decoId = 27 })
|
|||
|
|
elseif 3 == houseId then
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_WallPaper , facilityId = 1 , decoId = 23 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_WallPaper , facilityId = 2 , decoId = 23 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_WallPaper , facilityId = 3 , decoId = 23 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_WallPaper , facilityId = 4 , decoId = 23 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_WallPaper , facilityId = 5 , decoId = 23 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_Floor , facilityId = 1 , decoId = 24 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_Floor , facilityId = 2 , decoId = 24 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_Floor , facilityId = 3 , decoId = 24 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_Floor , facilityId = 4 , decoId = 24 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_Bar , facilityId = 1 , decoId = 27 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_Door , facilityId = 1 , decoId = 26 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_Door , facilityId = 2 , decoId = 26 })
|
|||
|
|
elseif 4 == houseId then
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_WallPaper , facilityId = 1 , decoId = 23 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_WallPaper , facilityId = 2 , decoId = 23 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_Floor , facilityId = 1 , decoId = 24 })
|
|||
|
|
elseif 5 == houseId then
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_Floor , facilityId = 1 , decoId = 24 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_Floor , facilityId = 2 , decoId = 24 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_Floor , facilityId = 3 , decoId = 25 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_Floor , facilityId = 4 , decoId = 25 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_Floor , facilityId = 5 , decoId = 24 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_WallPaper , facilityId = 1 , decoId = 23 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_WallPaper , facilityId = 2 , decoId = 23 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_WallPaper , facilityId = 3 , decoId = 23 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_WallPaper , facilityId = 4 , decoId = 23 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_WallPaper , facilityId = 5 , decoId = 23 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_Door , facilityId = 1 , decoId = 26 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_Door , facilityId = 2 , decoId = 26 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_Stair , facilityId = 1 , decoId = 163 })
|
|||
|
|
table.insert( decorate , { facilityType = dataType.DecorateType_HandRail , facilityId = 1 , decoId = 164 })
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
--赠送装修到背包
|
|||
|
|
local cfgHouse = skynet.server.gameConfig.House
|
|||
|
|
for k1, v1 in pairs(cfgHouse) do
|
|||
|
|
if houseId == v1.id then
|
|||
|
|
for k2, v2 in pairs(v1.unlockDecorate) do
|
|||
|
|
if not player:IsBuyGoods( dataType.GoodsType_Decorate , v2 ) then
|
|||
|
|
skynet.server.bag:AddGoods( player , dataType.GoodsType_Decorate , v2 , 1 )
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
break
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
return decorate
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
--是否解锁户型2和3
|
|||
|
|
function House:IsUnlockHouse( player , houseId )
|
|||
|
|
for k, v in pairs( player.gameData.house ) do
|
|||
|
|
if houseId == v.id and v.status > self.Status_Lock then
|
|||
|
|
return true
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
return false
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
--获取当前拥有的房子数量
|
|||
|
|
function House:GetHouseCount( player )
|
|||
|
|
local count = 0
|
|||
|
|
for k, v in pairs( player.gameData.house ) do
|
|||
|
|
if self.Status_Live == v.status or self.Status_AlreadyBuy == v.status then
|
|||
|
|
count = count + 1
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
return count
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
skynet.server.house = House
|
|||
|
|
return House
|