Commit 48962a743d4a88b6510fee51ef13336bfb0541f8
1 parent
26e6dd8b
路障系统提交
Showing
3 changed files
with
68 additions
and
11 deletions
Show diff stats
src/adv/Adv.lua
... | ... | @@ -1038,20 +1038,29 @@ function Adv:clickBlock(roomId, blockId, params) |
1038 | 1038 | |
1039 | 1039 | local status, errorCode = false, nil |
1040 | 1040 | local clickEvent = false |
1041 | - if not block.isOpen then | |
1041 | + | |
1042 | + local function checkAroundBlocks(ignoreGuard) | |
1042 | 1043 | local canOpen = false --如果未开放是否可以开放 |
1043 | - local hadMonster = false -- 周围是否有解锁的怪未击败 | |
1044 | 1044 | for _, one in ipairs(map:getAroundBlocks(room, block)) do |
1045 | 1045 | local _room, _block = one[1], one[2] |
1046 | - if _block.isOpen then canOpen = true end | |
1047 | - if _block.isOpen and _block:isMonster() then | |
1048 | - local enemy = self.battle:getEnemy(_room.roomId, _block.blockId) | |
1049 | - if not enemy:hadBuff(Buff.DONT_DEFEND) then | |
1050 | - hadMonster = true | |
1046 | + if not ignoreGuard and _block:isGuard() then | |
1047 | + if _block:isMonster() then | |
1048 | + local enemy = self.battle:getEnemy(_room.roomId, _block.blockId) | |
1049 | + if not enemy:hadBuff(Buff.DONT_DEFEND) then | |
1050 | + return false | |
1051 | + end | |
1052 | + else | |
1053 | + return false | |
1051 | 1054 | end |
1055 | + elseif _block:isWalk() then | |
1056 | + canOpen = true | |
1052 | 1057 | end |
1053 | 1058 | end |
1054 | - if canOpen and not hadMonster then --开放 | |
1059 | + return canOpen | |
1060 | + end | |
1061 | + | |
1062 | + if not block.isOpen then | |
1063 | + if checkAroundBlocks() then --开放 | |
1055 | 1064 | self:getCurMap():openBlock(roomId, blockId, true, true) |
1056 | 1065 | status = true |
1057 | 1066 | end |
... | ... | @@ -1061,6 +1070,10 @@ function Adv:clickBlock(roomId, blockId, params) |
1061 | 1070 | if not block.event then |
1062 | 1071 | return |
1063 | 1072 | end |
1073 | + | |
1074 | + if block:isHinder() then | |
1075 | + if not checkAroundBlocks(true) then return end | |
1076 | + end | |
1064 | 1077 | --可点击的事件 |
1065 | 1078 | if not room.isBossRoom or block:isBoss() then |
1066 | 1079 | if eventCallFunc[block.event.etype] then | ... | ... |
src/adv/AdvBlock.lua
... | ... | @@ -11,7 +11,7 @@ function Block:ctor(room, blockId, event, isOpen, trapId) |
11 | 11 | self.isOpen = isOpen and true or false |
12 | 12 | self.trapId = trapId |
13 | 13 | |
14 | - self:updateEvent(event) | |
14 | + self:updateEvent(event, true) | |
15 | 15 | end |
16 | 16 | function Block:isBoss() |
17 | 17 | return self:getEventType() == AdvEventType.BOSS |
... | ... | @@ -29,7 +29,7 @@ function Block:getEventType() |
29 | 29 | return self.event and self.event.etype |
30 | 30 | end |
31 | 31 | |
32 | -function Block:updateEvent(event) | |
32 | +function Block:updateEvent(event, isInit) | |
33 | 33 | self.event = event |
34 | 34 | end |
35 | 35 | |
... | ... | @@ -181,6 +181,29 @@ function Block:randomEvent() |
181 | 181 | end |
182 | 182 | end |
183 | 183 | |
184 | +-- 获取event 数据 | |
185 | +function Block:getEventData() | |
186 | + local typToCsv = { | |
187 | + [AdvEventType.Monster] = "event_monsterCsv", | |
188 | + [AdvEventType.BOSS] = "event_monsterCsv", | |
189 | + [AdvEventType.Choose] = "event_chooseCsv", | |
190 | + [AdvEventType.Drop] = "event_dropCsv", | |
191 | + [AdvEventType.Build] = "event_buildingCsv", | |
192 | + [AdvEventType.Trader] = "event_traderCsv", | |
193 | + [AdvEventType.Trap] = "event_trapCsv", | |
194 | + [AdvEventType.Click] = "event_clickCsv", | |
195 | + [AdvEventType.Layer] = "event_layerCsv", | |
196 | + [AdvEventType.Task] = "event_questCsv", | |
197 | + [AdvEventType.LinkChoose] = "event_linkchooseCsv", | |
198 | + } | |
199 | + | |
200 | + local etype = self:getEventType() | |
201 | + if not etype then return end | |
202 | + if not self.event.id then return end | |
203 | + if not typToCsv[etype] then return end | |
204 | + | |
205 | + return csvdb[typToCsv[etype]][self.event.id] | |
206 | +end | |
184 | 207 | |
185 | 208 | --事件有需要额外处理的部分 |
186 | 209 | function Block:open() |
... | ... | @@ -193,4 +216,25 @@ function Block:open() |
193 | 216 | return true |
194 | 217 | end |
195 | 218 | |
219 | +function Block:getObstacle() | |
220 | + local data = self:getEventData() | |
221 | + if not data then return 0 end | |
222 | + return data.obstacle or 0 | |
223 | +end | |
224 | + | |
225 | +-- 是否看守周围地板 | |
226 | +function Block:isGuard() | |
227 | + return self.isOpen and self:getObstacle() == 2 | |
228 | +end | |
229 | + | |
230 | +-- 是否是路障 | |
231 | +function Block:isHinder() | |
232 | + return self.isOpen and self:getObstacle() == 1 | |
233 | +end | |
234 | + | |
235 | +-- 玩家是否经过 -- 已经翻开 并且 不是路障 | |
236 | +function Block:isWalk() | |
237 | + return self.isOpen and not self:isHinder() | |
238 | +end | |
239 | + | |
196 | 240 | return Block |
197 | 241 | \ No newline at end of file | ... | ... |
src/adv/AdvMap.lua
... | ... | @@ -125,7 +125,7 @@ function Map:openBlockRand(num, isPlayer, ignoreBack) |
125 | 125 | end |
126 | 126 | |
127 | 127 | |
128 | --- 打开一个地块 翻开地块的入口方法 !!! | |
128 | +-- 打开一个地块 操作翻开地块的入口方法 !!! | |
129 | 129 | function Map:openBlock(roomId, blockId, isPlayer, ignoreBack) |
130 | 130 | local room = self.rooms[roomId] |
131 | 131 | if not room then return end | ... | ... |