Commit 7b64b6cd44d5980539c0f2b508c4993fda27c87f

Authored by zhouhaihai
1 parent f9acbb32

中继层优化

@@ -132,6 +132,7 @@ TimeReset = { @@ -132,6 +132,7 @@ TimeReset = {
132 132
133 GuideStep = { 133 GuideStep = {
134 AdvGuide = 1010, 134 AdvGuide = 1010,
  135 + AdvRelay = 1012,
135 } 136 }
136 137
137 --客户端不需要知道这个 138 --客户端不需要知道这个
@@ -183,7 +184,7 @@ AdvBackEventType = { @@ -183,7 +184,7 @@ AdvBackEventType = {
183 Dead = 11, --怪死亡 184 Dead = 11, --怪死亡
184 Trader = 12, -- 召唤商人 185 Trader = 12, -- 召唤商人
185 Monster = 13, -- 召唤怪物 186 Monster = 13, -- 召唤怪物
186 - 187 + RelayReward = 14, -- 中级层奖励
187 188
188 Cost = 16, -- 消耗道具 189 Cost = 16, -- 消耗道具
189 Trap = 17, --陷阱 190 Trap = 17, --陷阱
@@ -125,7 +125,7 @@ function Adv:initByChapter(chapterId, level, isToNext, notNotify, isRelay, isEnt @@ -125,7 +125,7 @@ function Adv:initByChapter(chapterId, level, isToNext, notNotify, isRelay, isEnt
125 isNewRelay = true 125 isNewRelay = true
126 advRelay[chapter] = advRelay[chapter] or {} 126 advRelay[chapter] = advRelay[chapter] or {}
127 advRelay[chapter][self.level] = 1 127 advRelay[chapter][self.level] = 1
128 - self.owner:updateProperty({field = advRelay, value = advRelay}) 128 + self.owner:updateProperty({field = "advRelay", value = advRelay})
129 end 129 end
130 end 130 end
131 131
@@ -1356,8 +1356,14 @@ function Adv:clickBlock(roomId, blockId, params) @@ -1356,8 +1356,14 @@ function Adv:clickBlock(roomId, blockId, params)
1356 end 1356 end
1357 1357
1358 if not block.isOpen then 1358 if not block.isOpen then
1359 - if checkAroundBlocks() then --开放 1359 + if self.isRelay or checkAroundBlocks() then --开放
1360 self:getCurMap():openBlock(roomId, blockId, true, true) 1360 self:getCurMap():openBlock(roomId, blockId, true, true)
  1361 + if self.isRelay and self:getCurMap():isAllOpen() then -- 发放翻开的奖励
  1362 + local relayData = self:isHaveRelay()
  1363 + if relayData and relayData.award ~= "" then
  1364 + self:pushBackEvent(AdvBackEventType.RelayReward, {items = self:award(relayData.award:toNumMap(), {log = {desc = "relayReward"}})})
  1365 + end
  1366 + end
1361 status = true 1367 status = true
1362 end 1368 end
1363 else 1369 else
src/adv/AdvMap.lua
@@ -19,17 +19,17 @@ function Map:ctor(adv, mapIdx, mapInfo, isEnter, isNewRelay) @@ -19,17 +19,17 @@ function Map:ctor(adv, mapIdx, mapInfo, isEnter, isNewRelay)
19 self.mapId = mapInfo.mapId 19 self.mapId = mapInfo.mapId
20 self.isShow = mapInfo.isShow -- 是否全部展示 -- 客户端用 20 self.isShow = mapInfo.isShow -- 是否全部展示 -- 客户端用
21 self.rooms = {} 21 self.rooms = {}
22 - self:loadRooms(mapInfo.rooms) 22 + self:loadRooms(mapInfo.rooms, isNewRelay)
23 end 23 end
24 24
25 -function Map:loadRooms(rooms) 25 +function Map:loadRooms(rooms, isNewRelay)
26 local mapData = csvdb["map_" .. csvdb["mapCsv"][self.mapId]["path"] .. "Csv"] 26 local mapData = csvdb["map_" .. csvdb["mapCsv"][self.mapId]["path"] .. "Csv"]
27 for roomId, roomName in pairs(mapData["rooms"]) do 27 for roomId, roomName in pairs(mapData["rooms"]) do
28 if roomName == "path" then 28 if roomName == "path" then
29 - self.rooms[roomId] = Room.new(self, roomId, mapData["path"], rooms[roomId], true) 29 + self.rooms[roomId] = Room.new(self, roomId, mapData["path"], rooms[roomId], true, isNewRelay)
30 else 30 else
31 roomName = roomName:gsub("/", "_") 31 roomName = roomName:gsub("/", "_")
32 - self.rooms[roomId] = Room.new(self, roomId, csvdb["room_" .. roomName .. "Csv"], rooms[roomId], false) 32 + self.rooms[roomId] = Room.new(self, roomId, csvdb["room_" .. roomName .. "Csv"], rooms[roomId], false, isNewRelay)
33 end 33 end
34 end 34 end
35 end 35 end
@@ -55,6 +55,17 @@ function Map:showMap() @@ -55,6 +55,17 @@ function Map:showMap()
55 self.isShow = true 55 self.isShow = true
56 end 56 end
57 57
  58 +function Map:isAllOpen()
  59 + for roomId, room in pairs(self.rooms) do
  60 + for blockId, block in pairs(room.blocks) do
  61 + if not block.isOpen then
  62 + return false
  63 + end
  64 + end
  65 + end
  66 + return true
  67 +end
  68 +
58 --结束本层的时候调用 69 --结束本层的时候调用
59 function Map:checkOver() 70 function Map:checkOver()
60 local mapCsv = csvdb["mapCsv"][self.mapId] 71 local mapCsv = csvdb["mapCsv"][self.mapId]
@@ -66,14 +77,7 @@ function Map:checkOver() @@ -66,14 +77,7 @@ function Map:checkOver()
66 elseif mapCsv.clearType == 3 then -- 持有 77 elseif mapCsv.clearType == 3 then -- 持有
67 if self.adv:cost(mapCsv.clear:toNumMap(), {}, true) then return true end 78 if self.adv:cost(mapCsv.clear:toNumMap(), {}, true) then return true end
68 elseif mapCsv.clearType == 4 then 79 elseif mapCsv.clearType == 4 then
69 - for roomId, room in pairs(self.rooms) do  
70 - for blockId, block in pairs(room.blocks) do  
71 - if not block.isOpen then  
72 - return false  
73 - end  
74 - end  
75 - return true  
76 - end 80 + return self:isAllOpen()
77 else 81 else
78 return true 82 return true
79 end 83 end
@@ -288,13 +292,13 @@ createMap = function(self, mapId, isEnter, isNewRelay) @@ -288,13 +292,13 @@ createMap = function(self, mapId, isEnter, isNewRelay)
288 randomFunc[AdvEventType.In] = function()end 292 randomFunc[AdvEventType.In] = function()end
289 --出口 293 --出口
290 randomFunc[AdvEventType.Out] = function() 294 randomFunc[AdvEventType.Out] = function()
291 - if not self.adv:isEndless() and isNewRelay then 295 + if not self.adv:isEndless() and self.adv.isRelay and not self.adv.owner:checkOverGuide(GuideStep.AdvRelay) then
292 return false 296 return false
293 end 297 end
294 end 298 end
295 --中继点出口 299 --中继点出口
296 randomFunc[AdvEventType.Exit] = function() 300 randomFunc[AdvEventType.Exit] = function()
297 - if not self.adv.isRelay or isEnter then return false end 301 + if not self.adv.isRelay or self.adv.owner:checkOverGuide(GuideStep.AdvRelay) then return false end
298 end 302 end
299 --开放出口 303 --开放出口
300 randomFunc[AdvEventType.InOut] = function() end 304 randomFunc[AdvEventType.InOut] = function() end
@@ -399,6 +403,8 @@ createMap = function(self, mapId, isEnter, isNewRelay) @@ -399,6 +403,8 @@ createMap = function(self, mapId, isEnter, isNewRelay)
399 if self.adv.isRelay and isNewRelay then 403 if self.adv.isRelay and isNewRelay then
400 local relayData = self.adv:isHaveRelay() 404 local relayData = self.adv:isHaveRelay()
401 if relayData then 405 if relayData then
  406 +
  407 + -- choose
402 local choose = relayData.choose:toArray(true, "=") 408 local choose = relayData.choose:toArray(true, "=")
403 local lastCount = stagePool["global"][AdvCodeRandomStage] and #stagePool["global"][AdvCodeRandomStage] or 0 409 local lastCount = stagePool["global"][AdvCodeRandomStage] and #stagePool["global"][AdvCodeRandomStage] or 0
404 for _, chooseId in pairs(choose) do 410 for _, chooseId in pairs(choose) do
@@ -412,6 +418,22 @@ createMap = function(self, mapId, isEnter, isNewRelay) @@ -412,6 +418,22 @@ createMap = function(self, mapId, isEnter, isNewRelay)
412 lastCount = lastCount - 1 418 lastCount = lastCount - 1
413 stagePool[cur["room"]][AdvCodeRandomStage][cur["block"]] = nil 419 stagePool[cur["room"]][AdvCodeRandomStage][cur["block"]] = nil
414 end 420 end
  421 +
  422 + -- 掉落
  423 + local drop = relayData.drop:toNumMap()
  424 + for dropId, dropCount in pairs(drop) do
  425 + for i = 1, dropCount do
  426 + if lastCount <= 0 then break end
  427 + local idx = math.randomInt(1, lastCount)
  428 + local cur = stagePool["global"][AdvCodeRandomStage][idx]
  429 +
  430 + giveEvent(cur["room"], cur["block"], AdvEventType.Drop, dropId)
  431 +
  432 + table.remove(stagePool["global"][AdvCodeRandomStage], idx)
  433 + lastCount = lastCount - 1
  434 + stagePool[cur["room"]][AdvCodeRandomStage][cur["block"]] = nil
  435 + end
  436 + end
415 end 437 end
416 end 438 end
417 439
src/adv/AdvRoom.lua
@@ -5,7 +5,7 @@ local Block = require &quot;adv.AdvBlock&quot; @@ -5,7 +5,7 @@ local Block = require &quot;adv.AdvBlock&quot;
5 local Passive = require "adv.AdvPassive" 5 local Passive = require "adv.AdvPassive"
6 6
7 local Room = class("AdvRoom") 7 local Room = class("AdvRoom")
8 -function Room:ctor(map, roomId, csvData, info, isPath) 8 +function Room:ctor(map, roomId, csvData, info, isPath, isNewRelay)
9 self.map = map 9 self.map = map
10 self.roomId = roomId 10 self.roomId = roomId
11 self.col, self.row = AdvCommon.getCrById(self.roomId) 11 self.col, self.row = AdvCommon.getCrById(self.roomId)
@@ -15,10 +15,10 @@ function Room:ctor(map, roomId, csvData, info, isPath) @@ -15,10 +15,10 @@ function Room:ctor(map, roomId, csvData, info, isPath)
15 self.battleAfterCall = {} 15 self.battleAfterCall = {}
16 16
17 self.blocks = {} 17 self.blocks = {}
18 - self:loadBlocks(csvData, info) 18 + self:loadBlocks(csvData, info, isNewRelay)
19 end 19 end
20 20
21 -function Room:loadBlocks(csvData, info) 21 +function Room:loadBlocks(csvData, info, isNewRelay)
22 local isFirstOpen = false 22 local isFirstOpen = false
23 for blockId, _ in pairs(csvData["blocks"]) do 23 for blockId, _ in pairs(csvData["blocks"]) do
24 self.blocks[blockId] = Block.new(self, blockId, info.event[blockId], info.open == 1 or info.open[blockId], info.trap[blockId]) 24 self.blocks[blockId] = Block.new(self, blockId, info.event[blockId], info.open == 1 or info.open[blockId], info.trap[blockId])
@@ -38,7 +38,7 @@ function Room:loadBlocks(csvData, info) @@ -38,7 +38,7 @@ function Room:loadBlocks(csvData, info)
38 end 38 end
39 end 39 end
40 --中继层全部开放 boss 房间 开启所有的地块 40 --中继层全部开放 boss 房间 开启所有的地块
41 - if self.map.adv.isRelay or (self.isBossRoom and self.isShow and isFirstOpen) then 41 + if (self.map.adv.isRelay and not isNewRelay) or (self.isBossRoom and self.isShow and isFirstOpen) then
42 table.insert(self.battleAfterCall, function() 42 table.insert(self.battleAfterCall, function()
43 for _, block in pairs(self.blocks) do 43 for _, block in pairs(self.blocks) do
44 self:openBlock(block) 44 self:openBlock(block)