43babcff
zhouhaihai
优化冒险结构 增加夹层功能
|
1
2
3
4
|
local Room = require "adv.AdvRoom"
local Passive = require "adv.AdvPassive"
local AdvCommon = require "adv.AdvCommon"
|
a0834e49
zhouhaihai
增加潜行 功能
|
5
6
|
local Buff = require "adv.AdvBuff"
|
43babcff
zhouhaihai
优化冒险结构 增加夹层功能
|
7
8
9
10
11
12
|
-- 一层地图
local Map = class("AdvMap")
-- 内部方法声明
local createMap, getEventLib
|
0e3ab88d
zhouhaihai
中继层
|
13
|
function Map:ctor(adv, mapIdx, mapInfo, isEnter, isNewRelay)
|
43babcff
zhouhaihai
优化冒险结构 增加夹层功能
|
14
|
self.adv = adv
|
23d9f086
zhouhaihai
展示房间
|
15
|
local isNew = type(mapInfo) == "number"
|
e59430d5
zhouhaihai
宝藏怪刷新,计数
|
16
|
self.mapIdx = mapIdx
|
23d9f086
zhouhaihai
展示房间
|
17
|
if isNew then -- mapInfo 传入 id
|
0e3ab88d
zhouhaihai
中继层
|
18
|
mapInfo = createMap(self, mapInfo, isEnter, isNewRelay) -- 生成地图
|
43babcff
zhouhaihai
优化冒险结构 增加夹层功能
|
19
20
21
|
end
if not mapInfo then return end
|
43babcff
zhouhaihai
优化冒险结构 增加夹层功能
|
22
|
self.mapId = mapInfo.mapId
|
4f0a5fae
zhouhaihai
营养剂
|
23
|
self.isShow = mapInfo.isShow -- 是否全部展示 -- 客户端用
|
43babcff
zhouhaihai
优化冒险结构 增加夹层功能
|
24
|
self.rooms = {}
|
23d9f086
zhouhaihai
展示房间
|
25
|
self:loadRooms(mapInfo.rooms, isNew, isNewRelay)
|
43babcff
zhouhaihai
优化冒险结构 增加夹层功能
|
26
27
|
end
|
23d9f086
zhouhaihai
展示房间
|
28
|
function Map:loadRooms(rooms, isNew, isNewRelay)
|
7ca46333
zhouhaihai
map 传参错误
|
29
30
|
local mapInfoCsv = csvdb["mapCsv"][self.mapId]
local mapData = csvdb["map_" .. mapInfoCsv["path"] .. "Csv"]
|
8c7272a5
zhouhaihai
冒险 地图刷新需求
|
31
|
|
43babcff
zhouhaihai
优化冒险结构 增加夹层功能
|
32
33
|
for roomId, roomName in pairs(mapData["rooms"]) do
if roomName == "path" then
|
7ca46333
zhouhaihai
map 传参错误
|
34
|
self.rooms[roomId] = Room.new(self, roomId, mapData["path"], rooms[roomId], true, isNewRelay, mapInfoCsv.type)
|
43babcff
zhouhaihai
优化冒险结构 增加夹层功能
|
35
36
|
else
roomName = roomName:gsub("/", "_")
|
7ca46333
zhouhaihai
map 传参错误
|
37
|
self.rooms[roomId] = Room.new(self, roomId, csvdb["room_" .. roomName .. "Csv"], rooms[roomId], false, isNewRelay, mapInfoCsv.type)
|
43babcff
zhouhaihai
优化冒险结构 增加夹层功能
|
38
39
|
end
end
|
23d9f086
zhouhaihai
展示房间
|
40
41
42
43
|
if mapInfoCsv.type == 2 and isNew then
self:showMap()
end
|
43babcff
zhouhaihai
优化冒险结构 增加夹层功能
|
44
45
|
end
|
1313eac0
zhouhaihai
冒险的一些bug
|
46
47
48
49
50
51
|
function Map:initBattleAfter()
for roomId, room in pairs(self.rooms) do
room:initBattleAfter()
end
end
|
7b2dc17c
zhouhaihai
地图 层 buff passive
|
52
53
54
55
56
|
function Map:getMapInfoCsv()
return csvdb["mapCsv"][self.mapId]
end
|
43babcff
zhouhaihai
优化冒险结构 增加夹层功能
|
57
58
59
|
function Map:getDB()
local map = {}
map.mapId = self.mapId
|
4f0a5fae
zhouhaihai
营养剂
|
60
|
map.isShow = self.isShow
|
43babcff
zhouhaihai
优化冒险结构 增加夹层功能
|
61
62
63
64
65
66
67
|
map.rooms = {}
for roomId, room in pairs(self.rooms) do
map.rooms[roomId] = room:getDB()
end
return map
end
|
4f0a5fae
zhouhaihai
营养剂
|
68
69
70
71
|
function Map:showMap()
self.isShow = true
end
|
7b64b6cd
zhouhaihai
中继层优化
|
72
73
74
75
76
77
78
79
80
81
82
|
function Map:isAllOpen()
for roomId, room in pairs(self.rooms) do
for blockId, block in pairs(room.blocks) do
if not block.isOpen then
return false
end
end
end
return true
end
|
43babcff
zhouhaihai
优化冒险结构 增加夹层功能
|
83
84
85
86
87
|
--结束本层的时候调用
function Map:checkOver()
local mapCsv = csvdb["mapCsv"][self.mapId]
if mapCsv.clearType == 1 then -- 消耗
|
4fa29210
zhouhaihai
bug
|
88
|
if self.adv:cost(mapCsv.clear:toNumMap(), {log = {desc = "overCost", int1 = self.mapId}}) then return true end
|
43babcff
zhouhaihai
优化冒险结构 增加夹层功能
|
89
90
91
92
|
elseif mapCsv.clearType == 2 then -- 杀光
if #self.adv.battle.player:getTeam(2) == 0 then return true end
elseif mapCsv.clearType == 3 then -- 持有
if self.adv:cost(mapCsv.clear:toNumMap(), {}, true) then return true end
|
1d45a501
zhouhaihai
增加新的退出类型
|
93
|
elseif mapCsv.clearType == 4 then
|
7b64b6cd
zhouhaihai
中继层优化
|
94
|
return self:isAllOpen()
|
43babcff
zhouhaihai
优化冒险结构 增加夹层功能
|
95
96
97
98
99
|
else
return true
end
end
|
e8762443
zhouhaihai
主动效果
|
100
101
102
103
104
105
106
107
108
109
110
111
112
113
|
function Map:randEmptyBlock()
local pool = {}
for _, room_ in pairs(self.rooms) do
for _, block_ in pairs(room_.blocks) do
if block_.isOpen and not block_.event then
table.insert(pool, {room_, block_})
end
end
end
if not next(pool) then return end
local idx = math.randomInt(1, #pool)
return pool[idx][1], pool[idx][2]
end
|
43babcff
zhouhaihai
优化冒险结构 增加夹层功能
|
114
115
116
117
118
119
|
--随机一个空的位置生成怪, 如果没有就没有
function Map:addNewMonsterRand(monsterId, where)
local room, block
if where then
room, block = where[1], where[2]
else
|
e8762443
zhouhaihai
主动效果
|
120
121
|
room, block = self:randEmptyBlock()
if not room then return end
|
43babcff
zhouhaihai
优化冒险结构 增加夹层功能
|
122
123
124
|
end
if not monsterId then
|
4faef572
zhouhaihai
冒险任务,冒险扫荡, 冒险中继
|
125
|
local eventLib = getEventLib(self, AdvEventType.Monster)
|
43babcff
zhouhaihai
优化冒险结构 增加夹层功能
|
126
127
128
129
|
if not next(eventLib[AdvEventType.Monster][0]) then return false end
monsterId = math.randWeight(eventLib[AdvEventType.Monster][0], "showup")
end
|
a0834e49
zhouhaihai
增加潜行 功能
|
130
|
local event = {
|
2d87caee
zhouhaihai
地块替换优化 新的效果类型
|
131
|
etype = AdvEventType.Monster,
|
a0834e49
zhouhaihai
增加潜行 功能
|
132
133
|
id = monsterId,
}
|
43babcff
zhouhaihai
优化冒险结构 增加夹层功能
|
134
135
|
block:updateEvent(event)
|
43babcff
zhouhaihai
优化冒险结构 增加夹层功能
|
136
137
138
|
return room, block
end
|
2d87caee
zhouhaihai
地块替换优化 新的效果类型
|
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
|
-- 在指定地块类型上 放置指定类型事件id
function Map:layEventToStage(eventType, eventId, count, stage)
local pool = {}
for _, room_ in pairs(self.rooms) do
for _, block_ in pairs(room_.blocks) do
if block_.isOpen and not block_.event and block_:getStageType() == stage then
table.insert(pool, {room_, block_})
end
end
end
if not next(pool) then return {} end
local change = {}
count = math.min(#pool, count)
for i = 1, count do
local idx = math.randomInt(1, #pool)
local room, block = pool[idx][1], pool[idx][2]
table.remove(pool, idx)
local event = {
etype = eventType,
id = eventId,
}
block:updateEvent(event)
table.insert(change, {room, block})
end
return change
end
-- 地图中指定事件 切换为另一个事件
function Map:eventChangeToOther(eventTypeF, eventIdF, eventTypeT, eventIdT, count)
count = count or 1
local pool = {}
for _, room_ in pairs(self.rooms) do
for _, block_ in pairs(room_.blocks) do
if block_.isOpen and block_:getEventType() == eventTypeF and block_.event.id == eventIdF then
table.insert(pool, {room_, block_})
end
end
end
if not next(pool) then return {} end
local change = {}
count = math.min(#pool, count)
for i = 1, count do
local idx = math.randomInt(1, #pool)
local room, block = pool[idx][1], pool[idx][2]
table.remove(pool, idx)
local event = {
etype = eventTypeT,
id = eventIdT,
}
block:updateEvent(event)
table.insert(change, {room, block})
end
return change
end
|
e1b26027
zhouhaihai
增加移除项目排除功能
|
196
|
function Map:clearEventById(eventType, eventId, count, exclude)
|
2d87caee
zhouhaihai
地块替换优化 新的效果类型
|
197
198
|
count = count or 0
eventId = eventId or 0
|
e1b26027
zhouhaihai
增加移除项目排除功能
|
199
|
exclude = exclude or {}
|
2d87caee
zhouhaihai
地块替换优化 新的效果类型
|
200
201
|
local pool = {}
|
e1b26027
zhouhaihai
增加移除项目排除功能
|
202
203
204
205
|
for roomId, room_ in pairs(self.rooms) do
exclude[roomId] = exclude[roomId] or {}
for blockId, block_ in pairs(room_.blocks) do
if not exclude[roomId][blockId] and block_.isOpen and block_:getEventType() == eventType and (eventId == 0 or block_.event.id == eventId) then
|
2d87caee
zhouhaihai
地块替换优化 新的效果类型
|
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
|
table.insert(pool, {room_, block_})
end
end
end
if not next(pool) then return {} end
local change = {}
if count == 0 then
count = #pool
else
count = math.min(#pool, count)
end
for i = 1, count do
local idx = math.randomInt(1, #pool)
local room, block = pool[idx][1], pool[idx][2]
table.remove(pool, idx)
block:updateEvent(nil)
table.insert(change, {room, block})
end
return change
end
|
43babcff
zhouhaihai
优化冒险结构 增加夹层功能
|
228
|
-- 随机翻开 num 个 以开放的房间的 地块
|
c8210d56
zhouhaihai
boss 房有入口
|
229
|
function Map:openBlockRand(num, isPlayer, ignoreBack)
|
43babcff
zhouhaihai
优化冒险结构 增加夹层功能
|
230
231
232
233
234
235
236
237
238
239
240
241
|
local pool = {}
for _, room in pairs(self.rooms) do
if room.isShow and not room.isPath then
for _, block in pairs(room.blocks) do
if not block.isOpen then
table.insert(pool, {room.roomId, block.blockId})
end
end
end
end
if #pool <= num then
for _, temp in ipairs(pool) do
|
c8210d56
zhouhaihai
boss 房有入口
|
242
|
self:openBlock(temp[1], temp[2], isPlayer, ignoreBack)
|
43babcff
zhouhaihai
优化冒险结构 增加夹层功能
|
243
244
245
246
|
end
else
for i = 1, num do
local idx = math.randomInt(1, #pool)
|
c8210d56
zhouhaihai
boss 房有入口
|
247
|
self:openBlock(pool[idx][1], pool[idx][2], isPlayer, ignoreBack)
|
43babcff
zhouhaihai
优化冒险结构 增加夹层功能
|
248
249
250
251
252
253
|
table.remove(pool, idx)
end
end
end
|
48962a74
zhouhaihai
路障系统提交
|
254
|
-- 打开一个地块 操作翻开地块的入口方法 !!!
|
8781e103
zhouhaihai
冒险 bug
|
255
|
function Map:openBlock(roomId, blockId, isPlayer, ignoreBack)
|
43babcff
zhouhaihai
优化冒险结构 增加夹层功能
|
256
257
258
259
|
local room = self.rooms[roomId]
if not room then return end
local block = room.blocks[blockId]
if not block then return end
|
c8210d56
zhouhaihai
boss 房有入口
|
260
261
262
263
|
local status = room:openBlock(block)
if status then
if isPlayer then
|
6826fdf6
zhouhaihai
被动触发
|
264
|
self.adv.battle:triggerPassive(Passive.OPEN_BLOCK, {roomId = roomId, blockId = blockId})
|
d677158e
zhouhaihai
调整打开地块位置
|
265
|
self.adv.owner:checkTaskEnter("AdvOpenBlock")
|
72d4fe84
zhouhaihai
翻开格子 加1sp
|
266
|
self.adv.battle.player:changeSp(1) -- 翻开格子 sp 加1
|
29fe5045
zhouhaihai
检查点修改
|
267
268
269
270
271
272
273
274
|
-- 潜行检查
local sneakBuff = self.adv.battle.player:hadBuff(Buff.SNEAK)
if sneakBuff then
local enemys = self:getEnemysBySize(roomId, blockId, 2)
if #enemys > 0 then
sneakBuff:uncover()
end
end
|
c8210d56
zhouhaihai
boss 房有入口
|
275
276
277
278
279
|
end
if not ignoreBack then
self.adv:backBlockChange(roomId, blockId)
end
|
ab4aa967
zhouhaihai
无论什么方式翻开中继层格子都给奖励
|
280
281
282
283
|
if self.adv.isRelay and self:isAllOpen() then -- 发放翻开的奖励
self.adv:passAdvRelay()
end
|
d3da3368
zhouhaihai
冒险地图被动技, buff 神器
|
284
|
end
|
b6a2b78b
zhouhaihai
冒险 buff 类型 34 35
|
285
|
return status
|
43babcff
zhouhaihai
优化冒险结构 增加夹层功能
|
286
287
|
end
|
c8210d56
zhouhaihai
boss 房有入口
|
288
|
function Map:openBlocksBySize(roomId, blockId, size, isPlayer, ignoreBack)
|
d3da3368
zhouhaihai
冒险地图被动技, buff 神器
|
289
290
|
local blocks = self:getBlocksBySize(roomId, blockId, size)
for _, block in pairs(blocks) do
|
c8210d56
zhouhaihai
boss 房有入口
|
291
|
self:openBlock(block.room.roomId, block.blockId, isPlayer, ignoreBack)
|
d3da3368
zhouhaihai
冒险地图被动技, buff 神器
|
292
293
294
|
end
end
|
c8210d56
zhouhaihai
boss 房有入口
|
295
|
function Map:openBlocksByRoom(roomId, isPlayer, ignoreBack)
|
d3da3368
zhouhaihai
冒险地图被动技, buff 神器
|
296
|
local room = self.rooms[roomId]
|
c8210d56
zhouhaihai
boss 房有入口
|
297
|
if not room then return end
|
d3da3368
zhouhaihai
冒险地图被动技, buff 神器
|
298
299
|
for blockId, block in pairs(room.blocks) do
|
c8210d56
zhouhaihai
boss 房有入口
|
300
|
self:openBlock(roomId, blockId, isPlayer, ignoreBack)
|
d3da3368
zhouhaihai
冒险地图被动技, buff 神器
|
301
302
303
|
end
end
|
6826fdf6
zhouhaihai
被动触发
|
304
|
function Map:openBlocksIsMonsterByRoom(roomId, count, isPlayer, ignoreBack)
|
b6a2b78b
zhouhaihai
冒险 buff 类型 34 35
|
305
306
307
|
local room = self.rooms[roomId]
if not room then return end
|
6826fdf6
zhouhaihai
被动触发
|
308
|
local allBlock = {}
|
b6a2b78b
zhouhaihai
冒险 buff 类型 34 35
|
309
|
for blockId, block in pairs(room.blocks) do
|
6826fdf6
zhouhaihai
被动触发
|
310
311
312
313
314
315
316
317
318
319
320
|
if block:isMonster() and not block.isOpen then
table.insert(allBlock, blockId)
end
end
local enemys = {}
local openBlock = function(blockId)
if self:openBlock(roomId, blockId, isPlayer, ignoreBack) then
local e = self.adv.battle:getEnemy(roomId, blockId)
if e then
table.insert(enemys, e)
|
b6a2b78b
zhouhaihai
冒险 buff 类型 34 35
|
321
322
323
|
end
end
end
|
6826fdf6
zhouhaihai
被动触发
|
324
|
|
fed94c7c
zhouhaihai
错误的函数
|
325
|
if not count or count == -1 or count >= #allBlock then
|
6826fdf6
zhouhaihai
被动触发
|
326
327
328
329
330
|
for _, blockId in ipairs(allBlock) do
openBlock(blockId)
end
else
for i = 1, count do
|
fed94c7c
zhouhaihai
错误的函数
|
331
|
local idx = math.randomInt(1, #allBlock)
|
6826fdf6
zhouhaihai
被动触发
|
332
333
334
335
|
openBlock(allBlock[idx])
table.remove(allBlock, idx)
end
end
|
b6a2b78b
zhouhaihai
冒险 buff 类型 34 35
|
336
337
338
|
return enemys
end
|
c8210d56
zhouhaihai
boss 房有入口
|
339
|
function Map:openAllBlocks(isPlayer, ignoreBack)
|
d3da3368
zhouhaihai
冒险地图被动技, buff 神器
|
340
|
for roomId, room in pairs(self.rooms) do
|
c8210d56
zhouhaihai
boss 房有入口
|
341
|
self:openBlocksByRoom(room.roomId, isPlayer, ignoreBack)
|
d3da3368
zhouhaihai
冒险地图被动技, buff 神器
|
342
343
344
|
end
end
|
43babcff
zhouhaihai
优化冒险结构 增加夹层功能
|
345
346
347
348
349
350
351
352
353
354
355
|
--获取,某个位置上的 room 和 block
function Map:getRBByPos(c, r)
for roomId, room in pairs(self.rooms) do
local block = room:getBByGPos(c, r)
if block then
return room, block
end
end
end
|
6826fdf6
zhouhaihai
被动触发
|
356
357
358
359
360
|
function Map:getDistance(froomId, fblockId, troomId, tblockId)
local distance = -1
local room1 = self.rooms[froomId]
local room2 = self.rooms[troomId]
if room1 and room2 then
|
e587a3aa
zhouhaihai
passive 距离生效bug
|
361
362
|
local block1 = room1.blocks[fblockId]
local block2 = room2.blocks[tblockId]
|
6826fdf6
zhouhaihai
被动触发
|
363
364
365
366
367
368
369
370
371
|
if block1 and block2 then
local c1, r1 = room1:tranLtoG(block1.col, block1.row)
local c2, r2 = room2:tranLtoG(block2.col, block2.row)
distance = math.max(math.abs(c1 - c2), math.abs(r1 - r2))
end
end
return distance
end
|
43babcff
zhouhaihai
优化冒险结构 增加夹层功能
|
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
|
function Map:getAroundBlocks(room, block)
local blocks = {}
local range = {1, -1}
local col, row = room:tranLtoG(block.col, block.row)
for _, add in ipairs(range) do
local rroom, rblock = self:getRBByPos(col + add, row)
if rroom then
table.insert(blocks, {rroom, rblock})
end
end
for _, add in ipairs(range) do
local rroom, rblock = self:getRBByPos(col, row + add)
if rroom then
table.insert(blocks, {rroom, rblock})
end
end
return blocks
end
|
be2bc68b
zhouhaihai
看守周围的格子
|
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
|
function Map:getAroundBlocksPlus(room, block)
local blocks = {}
local range = {1, 0, -1}
local col, row = room:tranLtoG(block.col, block.row)
for _, c in ipairs(range) do
for _, r in ipairs(range) do
if c == 0 and r == 0 then
else
local rroom, rblock = self:getRBByPos(col + c, row + r)
if rroom then
table.insert(blocks, {rroom, rblock})
end
end
end
end
return blocks
end
|
4f0a5fae
zhouhaihai
营养剂
|
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
|
function Map:getBlocksBySize(roomId, blockId, size)
local blocks = {}
local room = self.rooms[roomId]
if not room then return end
local block = room.blocks[blockId]
if not block then return end
local col, row = room:tranLtoG(block.col, block.row)
size = math.floor(size / 2)
for c = col - size, col + size do
for r = row - size, row + size do
local rroom, rblock = self:getRBByPos(c, r)
if rroom then
table.insert(blocks, rblock)
end
end
end
return blocks
end
|
9104a922
zhouhaihai
多重掉落
|
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
|
-- 找周围的空格子 最多 49 个
function Map:getEmptyBlocks(roomId, blockId, count)
local blocks = {}
if count == 0 then return blocks end
local room = self.rooms[roomId]
if not room then return end
local block = room.blocks[blockId]
if not block then return end
local col, row = room:tranLtoG(block.col, block.row)
-- 找周围49个格子
for range = 0, 3 do
if range == 0 then
if block.isOpen and not block:getEventType() then
blocks[#blocks + 1] = block
if #blocks >= count then
return blocks
end
end
else
for _, c in ipairs({col - range , col + range}) do
for r = row - range, row + range do
local rroom, rblock = self:getRBByPos(c, r)
if rroom and rblock.isOpen and not rblock:getEventType() then
blocks[#blocks + 1] = rblock
if #blocks >= count then
return blocks
end
end
end
end
for _, r in ipairs({row - range , row + range}) do
for c = col - range + 1, col + range - 1 do
local rroom, rblock = self:getRBByPos(c, r)
if rroom and rblock.isOpen and not rblock:getEventType() then
blocks[#blocks + 1] = rblock
if #blocks >= count then
return blocks
end
end
end
end
end
end
return blocks
end
|
a0834e49
zhouhaihai
增加潜行 功能
|
479
480
481
482
483
484
485
486
487
488
489
490
491
492
|
function Map:getEnemysBySize(roomId, blockId, size)
local blocks = self:getBlocksBySize(roomId, blockId, size)
local enemys = {}
for _, block in ipairs(blocks) do
if block:isMonster() then
local e = self.adv.battle:getEnemy(block.room.roomId, block.blockId)
if e then
table.insert(enemys, e)
end
end
end
return enemys
end
|
1e789624
zhouhaihai
新的 buff 效果
|
493
494
495
496
497
498
499
500
501
502
503
504
|
function Map:getEventTypeAllMap(eventType)
local blocks = {}
if not eventType then return blocks end
for roomId, room in pairs(self.rooms) do
for blockId, block in pairs(room.blocks) do
if block.isOpen and block:getEventType() == eventType then
table.insert(blocks, block)
end
end
end
return blocks
end
|
43babcff
zhouhaihai
优化冒险结构 增加夹层功能
|
505
506
|
-----------------------------随机地图-----------------------------
|
0e3ab88d
zhouhaihai
中继层
|
507
508
|
-- isEnter isNewRelay 区分中继层的类型 --是否是开始进入 是否是第一次进入
createMap = function(self, mapId, isEnter, isNewRelay)
|
43babcff
zhouhaihai
优化冒险结构 增加夹层功能
|
509
510
511
512
513
514
515
516
517
|
local mapInfo = {}
mapInfo.rooms = {}
mapInfo.mapId = mapId
local mapCsvData =csvdb["mapCsv"][mapId]
local mapData = csvdb["map_" .. mapCsvData["path"] .. "Csv"]
if not mapData then
error("mapId " .. mapId .. " dont exist!")
return
end
|
8c7272a5
zhouhaihai
冒险 地图刷新需求
|
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
|
local etypeToStr = {
[AdvEventType.Choose] = "choose",
[AdvEventType.Drop] = "drop",
[AdvEventType.Monster] = "monster",
[AdvEventType.Trader] = "trader",
[AdvEventType.Build] = "building",
[AdvEventType.Trap] = "trap",
[AdvEventType.Click] = "click",
}
local highLevelEvent = {}
for _etype, _str in pairs(etypeToStr) do
if mapCsvData[_str] ~= "" then
highLevelEvent[_etype] = {}
end
for _id, _count in pairs(mapCsvData[_str]:toNumMap()) do
local _curData = csvdb["event_" .. _str .. "Csv"][_id]
if _curData then
highLevelEvent[_etype][_curData.BlockEventType] = highLevelEvent[_etype][_curData.BlockEventType] or {}
|
51f42130
zhouhaihai
地图限制bug
|
538
|
highLevelEvent[_etype][_curData.BlockEventType][_id] = {showup = _curData.showup, limit = _count, dlimit = _curData.limit}
|
8c7272a5
zhouhaihai
冒险 地图刷新需求
|
539
540
541
542
|
end
end
end
|
43babcff
zhouhaihai
优化冒险结构 增加夹层功能
|
543
|
--事件随机
|
4faef572
zhouhaihai
冒险任务,冒险扫荡, 冒险中继
|
544
|
local eventLib = getEventLib(self) -- 同时记录出现次数
|
43babcff
zhouhaihai
优化冒险结构 增加夹层功能
|
545
546
|
local monsterEvents = {} --处理钥匙掉落
local haveBoss = false
|
7828ffd0
zhouhaihai
冒险 连续选择点 和 地图因子
|
547
|
local haveLChoose = false
|
43babcff
zhouhaihai
优化冒险结构 增加夹层功能
|
548
|
|
17d8d855
zhouhaihai
冒险 时间 limit 改为全局
|
549
|
local eventLimit = self.adv.owner:getProperty("advLimit")
|
43babcff
zhouhaihai
优化冒险结构 增加夹层功能
|
550
551
552
553
554
555
556
557
558
559
560
561
562
|
local function randomEvent(roomId, blockId, eventType)
if mapInfo.rooms[roomId]["event"][blockId] then return end --已经有事件了 不覆盖
local etype, especial = eventType, 0
if eventType > 100 then -- 特殊事件(固定)
etype = math.floor(eventType / 100)
especial = eventType % 100
end
local event = {etype = etype}
local randomFunc = {}
local function randomCommon()
|
8c7272a5
zhouhaihai
冒险 地图刷新需求
|
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
|
-- 刷新地图专属的
local function randomByLevelLib(lib)
-- 刷新通用的
if not lib[etype] or not next(lib[etype]) or not lib[etype][especial] then return false end
-- 清一下全关卡次数用完的
for _eid, _edata in pairs(lib[etype][especial]) do
if _edata.dlimit ~= 0 and ((eventLimit[etype] or {})[_eid] or 0) >= _edata.dlimit then
lib[etype][especial][_eid] = nil
end
end
if not next(lib[etype][especial]) then return false end
event.id = math.randWeight(lib[etype][especial], "showup")
if not event.id then return false end
-- 不是 0 才会记录
if lib[etype][especial][event.id].dlimit ~= 0 then
eventLimit[etype] = eventLimit[etype] or {}
eventLimit[etype][event.id] = (eventLimit[etype][event.id] or 0) + 1
end
-- 消除单层次数用完的
if lib[etype][especial][event.id].limit > 1 then
lib[etype][especial][event.id].limit = lib[etype][especial][event.id].limit - 1
elseif lib[etype][especial][event.id].limit == 1 then
lib[etype][especial][event.id] = nil
end
return true
|
17d8d855
zhouhaihai
冒险 时间 limit 改为全局
|
592
593
|
end
|
8c7272a5
zhouhaihai
冒险 地图刷新需求
|
594
595
596
|
local status = randomByLevelLib(highLevelEvent)
if not status then
status = randomByLevelLib(eventLib)
|
43babcff
zhouhaihai
优化冒险结构 增加夹层功能
|
597
|
end
|
8c7272a5
zhouhaihai
冒险 地图刷新需求
|
598
|
return status
|
43babcff
zhouhaihai
优化冒险结构 增加夹层功能
|
599
600
601
602
603
|
end
--入口
randomFunc[AdvEventType.In] = function()end
--出口
|
e51ff6d2
zhouhaihai
冒险~
|
604
605
606
607
608
609
|
randomFunc[AdvEventType.Out] = function()end
-- --中继点出口
-- randomFunc[AdvEventType.Exit] = function()
-- -- if not self.adv.isRelay or self.adv.owner:checkOverGuide(GuideStep.AdvRelay) then return false end
-- return false
-- end
|
0e3ab88d
zhouhaihai
中继层
|
610
611
612
613
614
|
--开放出口
randomFunc[AdvEventType.InOut] = function() end
--开放出口
randomFunc[AdvEventType.Diner] = function()
|
c85f5bd6
zhouhaihai
新中继的屏蔽删掉
|
615
|
-- if not self.adv.isRelay or isEnter or isNewRelay then return false end
|
ed20b43c
zhouhaihai
冒险bug
|
616
|
-- if not self.adv.isRelay or isEnter then return false end
|
0e3ab88d
zhouhaihai
中继层
|
617
618
|
end
|
43babcff
zhouhaihai
优化冒险结构 增加夹层功能
|
619
620
621
622
623
624
625
|
--boss
randomFunc[AdvEventType.BOSS] = function()
if haveBoss then return false end
if randomCommon() == false then
return false
end
haveBoss = true
|
e994ca55
zhouhaihai
任务 自动领取
|
626
|
self.haveBoss = true -- 刷新任务用的临时变量
|
43babcff
zhouhaihai
优化冒险结构 增加夹层功能
|
627
|
end
|
7828ffd0
zhouhaihai
冒险 连续选择点 和 地图因子
|
628
629
630
631
632
633
634
635
636
637
638
639
|
randomFunc[AdvEventType.LinkChoose] = function()
if haveLChoose then return false end
if self.adv.lchoose.ing then -- 有正在进行的
event.id = self.adv.lchoose.ing
self.adv.lchoose.ing = nil
else
if randomCommon() == false then
return false
end
end
haveLChoose = true
end
|
09be9059
zhouhaihai
冒险接口
|
640
|
|
43babcff
zhouhaihai
优化冒险结构 增加夹层功能
|
641
642
643
644
645
|
--怪物
randomFunc[AdvEventType.Monster] = function()
if randomCommon() == false then
return false
end
|
5de33f03
zhouhaihai
nokey
|
646
647
648
649
650
|
local curData = csvdb["event_monsterCsv"][event.id]
if curData.noKey and curData.noKey == 1 then
else
table.insert(monsterEvents, event)
end
|
43babcff
zhouhaihai
优化冒险结构 增加夹层功能
|
651
652
653
654
655
656
657
|
end
--选择点
randomFunc[AdvEventType.Choose] = randomCommon
--掉落点
randomFunc[AdvEventType.Drop] = randomCommon
--交易所
|
0e3ab88d
zhouhaihai
中继层
|
658
|
randomFunc[AdvEventType.Trader] = function()
|
c85f5bd6
zhouhaihai
新中继的屏蔽删掉
|
659
|
-- if self.adv.isRelay and isNewRelay then return false end
|
0e3ab88d
zhouhaihai
中继层
|
660
661
|
return randomCommon()
end
|
43babcff
zhouhaihai
优化冒险结构 增加夹层功能
|
662
|
--建筑
|
0e3ab88d
zhouhaihai
中继层
|
663
|
randomFunc[AdvEventType.Build] = function()
|
ed20b43c
zhouhaihai
冒险bug
|
664
|
-- if self.adv.isRelay and isEnter then return false end
|
0e3ab88d
zhouhaihai
中继层
|
665
666
|
return randomCommon()
end
|
43babcff
zhouhaihai
优化冒险结构 增加夹层功能
|
667
668
669
670
671
672
|
--陷阱
randomFunc[AdvEventType.Trap] = randomCommon
--点击生效
randomFunc[AdvEventType.Click] = randomCommon
--跨层点
randomFunc[AdvEventType.Layer] = randomCommon
|
43babcff
zhouhaihai
优化冒险结构 增加夹层功能
|
673
674
675
676
677
678
679
680
681
682
683
|
if randomFunc[etype] then
if randomFunc[etype]() ~= false then
if mapCsvData.clearType == 1 and etype == AdvEventType.BOSS then
event.item = mapCsvData.clear:toArray(true, "=")
end
mapInfo.rooms[roomId]["event"][blockId] = event
end
end
end
|
6dc482bb
zhouhaihai
中继层完成, 新增两个冒险物品使用效果
|
684
685
686
687
688
|
local function giveEvent(roomId, blockId, eventType, eventId)
local event = {etype = eventType, id = eventId}
mapInfo.rooms[roomId]["event"][blockId] = event
end
|
43babcff
zhouhaihai
优化冒险结构 增加夹层功能
|
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
|
local stagePool = {["global"] = {}}
for roomId, roomName in pairs(mapData["rooms"]) do
stagePool[roomId] = {}
mapInfo.rooms[roomId] = {event = {}, open = {}, trap = {}} -- 事件, open open == 1 房间内地块全部开放
local roomData
if roomName == "path" then
roomData = mapData["path"]
else
roomName = roomName:gsub("/", "_")
roomData = csvdb["room_" .. roomName .. "Csv"]
end
for blockId, stageType in pairs(roomData["blocks"]) do
if AdvSpecialStage[stageType] then
local eventType = AdvEventType[AdvSpecialStage[stageType]] -- 地块固定类型
randomEvent(roomId, blockId, eventType)
else
stagePool["global"][stageType] = stagePool["global"][stageType] or {}
stagePool[roomId][stageType] = stagePool[roomId][stageType] or {}
table.insert(stagePool["global"][stageType], {room = roomId, block = blockId})
stagePool[roomId][stageType][blockId] = 1
end
end
end
|
6dc482bb
zhouhaihai
中继层完成, 新增两个冒险物品使用效果
|
713
714
715
716
717
|
-- 随机功能需要强制随机的东西
if self.adv.isRelay and isNewRelay then
local relayData = self.adv:isHaveRelay()
if relayData then
|
7b64b6cd
zhouhaihai
中继层优化
|
718
719
|
-- choose
|
6dc482bb
zhouhaihai
中继层完成, 新增两个冒险物品使用效果
|
720
721
|
local choose = relayData.choose:toArray(true, "=")
local lastCount = stagePool["global"][AdvCodeRandomStage] and #stagePool["global"][AdvCodeRandomStage] or 0
|
6dc482bb
zhouhaihai
中继层完成, 新增两个冒险物品使用效果
|
722
|
for _, chooseId in pairs(choose) do
|
f60fc764
zhouhaihai
bug
|
723
|
if lastCount <= 0 then break end
|
6dc482bb
zhouhaihai
中继层完成, 新增两个冒险物品使用效果
|
724
725
726
727
728
729
730
|
local idx = math.randomInt(1, lastCount)
local cur = stagePool["global"][AdvCodeRandomStage][idx]
giveEvent(cur["room"], cur["block"], AdvEventType.Choose, chooseId)
table.remove(stagePool["global"][AdvCodeRandomStage], idx)
lastCount = lastCount - 1
|
6fe355d6
zhouhaihai
map bug
|
731
|
stagePool[cur["room"]][AdvCodeRandomStage][cur["block"]] = nil
|
6dc482bb
zhouhaihai
中继层完成, 新增两个冒险物品使用效果
|
732
|
end
|
7b64b6cd
zhouhaihai
中继层优化
|
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
|
-- 掉落
local drop = relayData.drop:toNumMap()
for dropId, dropCount in pairs(drop) do
for i = 1, dropCount do
if lastCount <= 0 then break end
local idx = math.randomInt(1, lastCount)
local cur = stagePool["global"][AdvCodeRandomStage][idx]
giveEvent(cur["room"], cur["block"], AdvEventType.Drop, dropId)
table.remove(stagePool["global"][AdvCodeRandomStage], idx)
lastCount = lastCount - 1
stagePool[cur["room"]][AdvCodeRandomStage][cur["block"]] = nil
end
end
|
6dc482bb
zhouhaihai
中继层完成, 新增两个冒险物品使用效果
|
749
750
751
|
end
end
|
9ced5432
zhouhaihai
冒险支援效果 保底事件
|
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
|
-- 低保事件
local exEvent = {}
-- 首层额外刷新
if isEnter then
local first = self.adv:supportFirstLayerAddEvent()
if first then
exEvent = first
end
end
-- 每层额外刷新
if not self.adv.isRelay then
local every = self.adv:supportEveryLayerAddEvent()
if every then
for etype, events in pairs(every) do
exEvent[etype] = exEvent[etype] or {}
for id, num in pairs(events) do
exEvent[etype][id] = (exEvent[etype][id] or 0) + num
end
end
end
end
local lastCount = stagePool["global"][AdvCodeRandomStage] and #stagePool["global"][AdvCodeRandomStage] or 0
for etype, events in pairs(exEvent) do
if lastCount <= 0 then break end
for id, num in pairs(events) do
if lastCount <= 0 then break end
for i = 1, num do
if lastCount <= 0 then break end
local idx = math.randomInt(1, lastCount)
local cur = stagePool["global"][AdvCodeRandomStage][idx]
giveEvent(cur["room"], cur["block"], etype, id)
table.remove(stagePool["global"][AdvCodeRandomStage], idx)
lastCount = lastCount - 1
stagePool[cur["room"]][AdvCodeRandomStage][cur["block"]] = nil
end
end
end
|
43babcff
zhouhaihai
优化冒险结构 增加夹层功能
|
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
|
-- 全地图事件 优先级高
for stageType, events in pairs(mapData["events"]) do
for _, event in ipairs(events) do
local lastCount = stagePool["global"][stageType] and #stagePool["global"][stageType] or 0
if lastCount <= 0 then break end
if math.randomFloat(0, 1) <= (event["rate"] or 1) then
local count = math.randomInt(math.min(lastCount, event["minc"]), math.min(lastCount, event["maxc"]))
for i = 1, count do
local idx = math.randomInt(1, lastCount)
local cur = stagePool["global"][stageType][idx]
randomEvent(cur["room"], cur["block"], event["event"])
table.remove(stagePool["global"][stageType], idx)
lastCount = lastCount - 1
stagePool[cur["room"]][stageType][cur["block"]] = nil
end
end
end
end
-- 随机单个房间的事件
for roomId, roomName in pairs(mapData["rooms"]) do
local roomData
if roomName == "path" then
roomData = mapData["path"]
else
roomName = roomName:gsub("/", "_")
roomData = csvdb["room_" .. roomName .. "Csv"]
end
for stageType, events in pairs(roomData["events"]) do
local bpool = {}
if stagePool[roomId][stageType] then
for block, _ in pairs(stagePool[roomId][stageType]) do
table.insert(bpool, block)
end
end
for _, event in ipairs(events) do
if #bpool <= 0 then break end
if math.randomFloat(0, 1) <= (event["rate"] or 1) then
local count = math.randomInt(math.min(#bpool, event["minc"]), math.min(#bpool, event["maxc"]))
for i = 1, count do
local idx = math.randomInt(1, #bpool)
randomEvent(roomId, bpool[idx], event["event"])
table.remove(bpool, idx)
end
end
end
end
end
|
36875ec5
zhouhaihai
宝藏怪
|
841
|
-- 宝藏怪刷新
|
e910c2dd
zhouhaihai
考场没有 宝藏怪
|
842
|
if self.mapIdx == 1 and not self.adv.isRelay and self.adv.chapterId ~= 100 then
|
e59430d5
zhouhaihai
宝藏怪刷新,计数
|
843
844
845
|
for idx = #(stagePool["global"][AdvCodeRandomStage] or {}), 1, -1 do
local c = stagePool["global"][AdvCodeRandomStage][idx] -- {room = roomId, block = blockId}
if mapInfo.rooms[c["room"]]["event"][c["block"]] then -- 存在
|
36875ec5
zhouhaihai
宝藏怪
|
846
|
table.remove(stagePool["global"][AdvCodeRandomStage], idx)
|
36875ec5
zhouhaihai
宝藏怪
|
847
848
|
end
end
|
e59430d5
zhouhaihai
宝藏怪刷新,计数
|
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
|
local ln = #(stagePool["global"][AdvCodeRandomStage] or {})
local advMine = self.adv.owner:getProperty("advMine")
advMine[1] = advMine[1] or {}
local mineCh = advMine[1].ch or globalCsv.adv_egg_treasureMonster_showup
local mineCo = advMine[1].co or {}
local had = false
if ln > 0 then
if math.randomInt(1, 100) <= mineCh then -- 刷出来了
local mpool = {}
for _, mid in ipairs(globalCsv.adv_egg_treasureMonster_id) do
local monster = csvdb["event_monsterCsv"][mid]
if (not mineCo[mid] or monster.limit == 0 or mineCo[mid] < monster.limit) and monster.showup > 0 then
mpool[mid] = {monster.showup}
end
end
if next(mpool) then
local idx = math.randomInt(1, ln)
local cur = stagePool["global"][AdvCodeRandomStage][idx]
giveEvent(cur["room"], cur["block"], AdvEventType.Monster, math.randWeight(mpool, 1))
table.remove(stagePool["global"][AdvCodeRandomStage], idx)
ln = ln - 1
had = true
end
end
end
|
fea3baab
zhouhaihai
宝藏怪bug
|
874
|
if had then
|
e59430d5
zhouhaihai
宝藏怪刷新,计数
|
875
|
mineCh = nil
|
fea3baab
zhouhaihai
宝藏怪bug
|
876
877
|
else
mineCh = math.min(mineCh + globalCsv.adv_egg_treasureMonster_showup_add, 100)
|
e59430d5
zhouhaihai
宝藏怪刷新,计数
|
878
879
880
|
end
advMine[1].ch = mineCh
self.adv.owner:setProperty("advMine", advMine)
|
36875ec5
zhouhaihai
宝藏怪
|
881
|
end
|
36875ec5
zhouhaihai
宝藏怪
|
882
883
|
|
43babcff
zhouhaihai
优化冒险结构 增加夹层功能
|
884
885
886
887
888
889
890
891
|
if mapCsvData.clearType == 1 and not haveBoss then
if not next(monsterEvents) then
error("这个地图没有钥匙!!! mapId : " .. mapId)
else
local event = monsterEvents[math.randomInt(1, #monsterEvents)]
event.item = mapCsvData.clear:toArray(true, "=") --掉落钥匙
end
end
|
17d8d855
zhouhaihai
冒险 时间 limit 改为全局
|
892
|
self.adv.owner:setProperty("advLimit", eventLimit)
|
43babcff
zhouhaihai
优化冒险结构 增加夹层功能
|
893
894
895
896
|
return mapInfo
end
--关卡事件库
|
4faef572
zhouhaihai
冒险任务,冒险扫荡, 冒险中继
|
897
898
|
getEventLib = function(self, needEventType) -- needEventType 需要的事件
local chapterId, level = self.adv.chapterId, self.adv.level
|
8da953a7
zhouhaihai
无尽模式
|
899
|
if AdvCommon.isEndless(chapterId) then
|
916096ed
zhouhaihai
神器效果
|
900
|
level = AdvCommon.getEndlessDataLv(chapterId, level)
|
8da953a7
zhouhaihai
无尽模式
|
901
|
end
|
43babcff
zhouhaihai
优化冒险结构 增加夹层功能
|
902
|
local libsToType = {
|
ff7cd89e
zhouhaihai
地图
|
903
|
["event_monsterCsv"] = {AdvEventType.Monster, AdvEventType.BOSS, AdvEventType.Monster, AdvEventType.Monster, AdvEventType.Monster},
|
43babcff
zhouhaihai
优化冒险结构 增加夹层功能
|
904
905
906
907
908
909
910
|
["event_chooseCsv"] = AdvEventType.Choose,
["event_dropCsv"] = AdvEventType.Drop,
["event_buildingCsv"] = AdvEventType.Build,
["event_traderCsv"] = AdvEventType.Trader,
["event_trapCsv"] = AdvEventType.Trap,
["event_clickCsv"] = AdvEventType.Click,
["event_layerCsv"] = AdvEventType.Layer,
|
7828ffd0
zhouhaihai
冒险 连续选择点 和 地图因子
|
911
|
["event_linkchooseCsv"] = AdvEventType.LinkChoose,
|
43babcff
zhouhaihai
优化冒险结构 增加夹层功能
|
912
913
|
}
local eventLib = {}
|
4faef572
zhouhaihai
冒险任务,冒险扫荡, 冒险中继
|
914
915
916
|
local advEventOpenStatus = self.adv.owner:advEventOpenStatus()
|
17d8d855
zhouhaihai
冒险 时间 limit 改为全局
|
917
918
|
local eventLimit = self.adv.owner:getProperty("advLimit")
|
43babcff
zhouhaihai
优化冒险结构 增加夹层功能
|
919
920
921
922
923
924
925
926
927
928
929
930
|
for lib, eventType in pairs(libsToType) do
-- init eventLib
if type(eventType) == "table" then
for _, temp in ipairs(eventType) do
eventLib[temp] = {}
end
else
eventLib[eventType] = {}
end
-- needEventType 只获取这个事件类型
if not needEventType or eventLib[needEventType] then
for id, data in pairs(csvdb[lib]) do
|
4faef572
zhouhaihai
冒险任务,冒险扫荡, 冒险中继
|
931
932
|
local etype = type(eventType) == "table" and eventType[data.type] or eventType
|
4d943586
zhouhaihai
直通 advt gm
|
933
|
if data.levelchapter == chapterId and (data.unlockType == 0 or (advEventOpenStatus[etype] or {})[data.unlockType]) then
|
7828ffd0
zhouhaihai
冒险 连续选择点 和 地图因子
|
934
935
936
937
938
939
|
local add = true
if etype == AdvEventType.LinkChoose then --link 只有起始任务并且还没完成的进入池子
if id % 10 ~= 1 or (data.limit ~= 0 and data.limit <= (self.adv.lchoose[id] or 0)) then
add = false
end
end
|
17d8d855
zhouhaihai
冒险 时间 limit 改为全局
|
940
|
|
8c7272a5
zhouhaihai
冒险 地图刷新需求
|
941
942
|
-- limit 单次上限 默认无限
local limit = 0
|
17d8d855
zhouhaihai
冒险 时间 limit 改为全局
|
943
944
945
946
|
if add and (etype == AdvEventType.LinkChoose or etype == AdvEventType.Choose) then --只能有一次
limit = 1
end
|
7828ffd0
zhouhaihai
冒险 连续选择点 和 地图因子
|
947
948
949
|
if add then
if AdvCommon.checkIsIn(level, data.leveltype, data.levellimit) then
eventLib[etype][data.BlockEventType] = eventLib[etype][data.BlockEventType] or {}
|
17d8d855
zhouhaihai
冒险 时间 limit 改为全局
|
950
|
eventLib[etype][data.BlockEventType][id] = {showup = data.showup, limit = limit, dlimit = data.limit}
|
7828ffd0
zhouhaihai
冒险 连续选择点 和 地图因子
|
951
|
end
|
43babcff
zhouhaihai
优化冒险结构 增加夹层功能
|
952
953
954
955
956
957
958
959
960
961
962
|
end
end
end
if needEventType then
break
end
end
end
return eventLib
end
|
43babcff
zhouhaihai
优化冒险结构 增加夹层功能
|
963
|
return Map
|