43babcff
zhouhaihai
优化冒险结构 增加夹层功能
|
1
2
3
4
5
6
7
8
9
10
|
local Room = require "adv.AdvRoom"
local Passive = require "adv.AdvPassive"
local AdvCommon = require "adv.AdvCommon"
-- 一层地图
local Map = class("AdvMap")
-- 内部方法声明
local createMap, getEventLib
|
0e3ab88d
zhouhaihai
中继层
|
11
|
function Map:ctor(adv, mapIdx, mapInfo, isEnter, isNewRelay)
|
43babcff
zhouhaihai
优化冒险结构 增加夹层功能
|
12
13
|
self.adv = adv
if type(mapInfo) == "number" then -- mapInfo 传入 id
|
0e3ab88d
zhouhaihai
中继层
|
14
|
mapInfo = createMap(self, mapInfo, isEnter, isNewRelay) -- 生成地图
|
43babcff
zhouhaihai
优化冒险结构 增加夹层功能
|
15
16
17
18
19
|
end
if not mapInfo then return end
self.mapIdx = mapIdx
self.mapId = mapInfo.mapId
|
4f0a5fae
zhouhaihai
营养剂
|
20
|
self.isShow = mapInfo.isShow -- 是否全部展示 -- 客户端用
|
43babcff
zhouhaihai
优化冒险结构 增加夹层功能
|
21
|
self.rooms = {}
|
7b64b6cd
zhouhaihai
中继层优化
|
22
|
self:loadRooms(mapInfo.rooms, isNewRelay)
|
43babcff
zhouhaihai
优化冒险结构 增加夹层功能
|
23
24
|
end
|
7b64b6cd
zhouhaihai
中继层优化
|
25
|
function Map:loadRooms(rooms, isNewRelay)
|
43babcff
zhouhaihai
优化冒险结构 增加夹层功能
|
26
27
28
|
local mapData = csvdb["map_" .. csvdb["mapCsv"][self.mapId]["path"] .. "Csv"]
for roomId, roomName in pairs(mapData["rooms"]) do
if roomName == "path" then
|
7b64b6cd
zhouhaihai
中继层优化
|
29
|
self.rooms[roomId] = Room.new(self, roomId, mapData["path"], rooms[roomId], true, isNewRelay)
|
43babcff
zhouhaihai
优化冒险结构 增加夹层功能
|
30
31
|
else
roomName = roomName:gsub("/", "_")
|
7b64b6cd
zhouhaihai
中继层优化
|
32
|
self.rooms[roomId] = Room.new(self, roomId, csvdb["room_" .. roomName .. "Csv"], rooms[roomId], false, isNewRelay)
|
43babcff
zhouhaihai
优化冒险结构 增加夹层功能
|
33
34
35
36
|
end
end
end
|
1313eac0
zhouhaihai
冒险的一些bug
|
37
38
39
40
41
42
|
function Map:initBattleAfter()
for roomId, room in pairs(self.rooms) do
room:initBattleAfter()
end
end
|
43babcff
zhouhaihai
优化冒险结构 增加夹层功能
|
43
44
45
|
function Map:getDB()
local map = {}
map.mapId = self.mapId
|
4f0a5fae
zhouhaihai
营养剂
|
46
|
map.isShow = self.isShow
|
43babcff
zhouhaihai
优化冒险结构 增加夹层功能
|
47
48
49
50
51
52
53
|
map.rooms = {}
for roomId, room in pairs(self.rooms) do
map.rooms[roomId] = room:getDB()
end
return map
end
|
4f0a5fae
zhouhaihai
营养剂
|
54
55
56
57
|
function Map:showMap()
self.isShow = true
end
|
7b64b6cd
zhouhaihai
中继层优化
|
58
59
60
61
62
63
64
65
66
67
68
|
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
优化冒险结构 增加夹层功能
|
69
70
71
72
73
|
--结束本层的时候调用
function Map:checkOver()
local mapCsv = csvdb["mapCsv"][self.mapId]
if mapCsv.clearType == 1 then -- 消耗
|
4fa29210
zhouhaihai
bug
|
74
|
if self.adv:cost(mapCsv.clear:toNumMap(), {log = {desc = "overCost", int1 = self.mapId}}) then return true end
|
43babcff
zhouhaihai
优化冒险结构 增加夹层功能
|
75
76
77
78
|
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
增加新的退出类型
|
79
|
elseif mapCsv.clearType == 4 then
|
7b64b6cd
zhouhaihai
中继层优化
|
80
|
return self:isAllOpen()
|
43babcff
zhouhaihai
优化冒险结构 增加夹层功能
|
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
else
return true
end
end
--随机一个空的位置生成怪, 如果没有就没有
function Map:addNewMonsterRand(monsterId, where)
local room, block
if where then
room, block = where[1], where[2]
else
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)
room, block = pool[idx][1], pool[idx][2]
end
if not monsterId then
|
4faef572
zhouhaihai
冒险任务,冒险扫荡, 冒险中继
|
106
|
local eventLib = getEventLib(self, AdvEventType.Monster)
|
43babcff
zhouhaihai
优化冒险结构 增加夹层功能
|
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
|
if not next(eventLib[AdvEventType.Monster][0]) then return false end
monsterId = math.randWeight(eventLib[AdvEventType.Monster][0], "showup")
end
local event = {etype = AdvEventType.Monster, mId = self.adv.lastEnemyId}
self.adv.lastEnemyId = self.adv.lastEnemyId + 1
event.id = monsterId
block:updateEvent(event)
self.adv.battle:addEnemy(room, block):triggerPassive(Passive.BORN_ONCE)
return room, block
end
-- 随机翻开 num 个 以开放的房间的 地块
|
c8210d56
zhouhaihai
boss 房有入口
|
122
|
function Map:openBlockRand(num, isPlayer, ignoreBack)
|
43babcff
zhouhaihai
优化冒险结构 增加夹层功能
|
123
124
125
126
127
128
129
130
131
132
133
134
|
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 房有入口
|
135
|
self:openBlock(temp[1], temp[2], isPlayer, ignoreBack)
|
43babcff
zhouhaihai
优化冒险结构 增加夹层功能
|
136
137
138
139
|
end
else
for i = 1, num do
local idx = math.randomInt(1, #pool)
|
c8210d56
zhouhaihai
boss 房有入口
|
140
|
self:openBlock(pool[idx][1], pool[idx][2], isPlayer, ignoreBack)
|
43babcff
zhouhaihai
优化冒险结构 增加夹层功能
|
141
142
143
144
145
146
|
table.remove(pool, idx)
end
end
end
|
48962a74
zhouhaihai
路障系统提交
|
147
|
-- 打开一个地块 操作翻开地块的入口方法 !!!
|
8781e103
zhouhaihai
冒险 bug
|
148
|
function Map:openBlock(roomId, blockId, isPlayer, ignoreBack)
|
43babcff
zhouhaihai
优化冒险结构 增加夹层功能
|
149
150
151
152
|
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 房有入口
|
153
154
155
156
157
|
local status = room:openBlock(block)
if status then
if isPlayer then
self.adv.battle.player:triggerPassive(Passive.OPEN_BLOCK)
|
d677158e
zhouhaihai
调整打开地块位置
|
158
|
self.adv.owner:checkTaskEnter("AdvOpenBlock")
|
c8210d56
zhouhaihai
boss 房有入口
|
159
160
161
162
163
|
end
if not ignoreBack then
self.adv:backBlockChange(roomId, blockId)
end
|
d3da3368
zhouhaihai
冒险地图被动技, buff 神器
|
164
|
end
|
43babcff
zhouhaihai
优化冒险结构 增加夹层功能
|
165
166
|
end
|
c8210d56
zhouhaihai
boss 房有入口
|
167
|
function Map:openBlocksBySize(roomId, blockId, size, isPlayer, ignoreBack)
|
d3da3368
zhouhaihai
冒险地图被动技, buff 神器
|
168
169
|
local blocks = self:getBlocksBySize(roomId, blockId, size)
for _, block in pairs(blocks) do
|
c8210d56
zhouhaihai
boss 房有入口
|
170
|
self:openBlock(block.room.roomId, block.blockId, isPlayer, ignoreBack)
|
d3da3368
zhouhaihai
冒险地图被动技, buff 神器
|
171
172
173
|
end
end
|
c8210d56
zhouhaihai
boss 房有入口
|
174
|
function Map:openBlocksByRoom(roomId, isPlayer, ignoreBack)
|
d3da3368
zhouhaihai
冒险地图被动技, buff 神器
|
175
|
local room = self.rooms[roomId]
|
c8210d56
zhouhaihai
boss 房有入口
|
176
|
if not room then return end
|
d3da3368
zhouhaihai
冒险地图被动技, buff 神器
|
177
178
|
for blockId, block in pairs(room.blocks) do
|
c8210d56
zhouhaihai
boss 房有入口
|
179
|
self:openBlock(roomId, blockId, isPlayer, ignoreBack)
|
d3da3368
zhouhaihai
冒险地图被动技, buff 神器
|
180
181
182
|
end
end
|
c8210d56
zhouhaihai
boss 房有入口
|
183
|
function Map:openAllBlocks(isPlayer, ignoreBack)
|
d3da3368
zhouhaihai
冒险地图被动技, buff 神器
|
184
|
for roomId, room in pairs(self.rooms) do
|
c8210d56
zhouhaihai
boss 房有入口
|
185
|
self:openBlocksByRoom(room.roomId, isPlayer, ignoreBack)
|
d3da3368
zhouhaihai
冒险地图被动技, buff 神器
|
186
187
188
|
end
end
|
43babcff
zhouhaihai
优化冒险结构 增加夹层功能
|
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
|
--获取,某个位置上的 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
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
|
4f0a5fae
zhouhaihai
营养剂
|
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
|
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
|
43babcff
zhouhaihai
优化冒险结构 增加夹层功能
|
240
241
|
-----------------------------随机地图-----------------------------
|
0e3ab88d
zhouhaihai
中继层
|
242
243
|
-- isEnter isNewRelay 区分中继层的类型 --是否是开始进入 是否是第一次进入
createMap = function(self, mapId, isEnter, isNewRelay)
|
43babcff
zhouhaihai
优化冒险结构 增加夹层功能
|
244
245
246
247
248
249
250
251
252
253
|
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
--事件随机
|
4faef572
zhouhaihai
冒险任务,冒险扫荡, 冒险中继
|
254
|
local eventLib = getEventLib(self) -- 同时记录出现次数
|
43babcff
zhouhaihai
优化冒险结构 增加夹层功能
|
255
256
|
local monsterEvents = {} --处理钥匙掉落
local haveBoss = false
|
7828ffd0
zhouhaihai
冒险 连续选择点 和 地图因子
|
257
|
local haveLChoose = false
|
43babcff
zhouhaihai
优化冒险结构 增加夹层功能
|
258
|
|
17d8d855
zhouhaihai
冒险 时间 limit 改为全局
|
259
|
local eventLimit = self.adv.owner:getProperty("advLimit")
|
43babcff
zhouhaihai
优化冒险结构 增加夹层功能
|
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
|
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()
if not eventLib[etype] or not next(eventLib[etype]) or not eventLib[etype][especial] or not next(eventLib[etype][especial]) then return false end
event.id = math.randWeight(eventLib[etype][especial], "showup")
if not event.id then return false end
|
17d8d855
zhouhaihai
冒险 时间 limit 改为全局
|
276
277
278
|
-- 不是 0 才会记录
if eventLib[etype][especial][event.id].dlimit ~= 0 then
|
b09f4672
zhouhaihai
bug
|
279
|
eventLimit[etype] = eventLimit[etype] or {}
|
17d8d855
zhouhaihai
冒险 时间 limit 改为全局
|
280
281
282
283
|
eventLimit[etype][event.id] = (eventLimit[etype][event.id] or 0) + 1
end
-- 消除
|
43babcff
zhouhaihai
优化冒险结构 增加夹层功能
|
284
285
286
287
288
289
290
291
292
293
|
if eventLib[etype][especial][event.id].limit > 1 then
eventLib[etype][especial][event.id].limit = eventLib[etype][especial][event.id].limit - 1
elseif eventLib[etype][especial][event.id].limit == 1 then
eventLib[etype][especial][event.id] = nil
end
end
--入口
randomFunc[AdvEventType.In] = function()end
--出口
|
e51ff6d2
zhouhaihai
冒险~
|
294
295
296
297
298
299
|
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
中继层
|
300
301
302
303
304
305
306
307
|
--开放出口
randomFunc[AdvEventType.InOut] = function() end
--开放出口
randomFunc[AdvEventType.Diner] = function()
if not self.adv.isRelay or isEnter or isNewRelay then return false end
end
|
43babcff
zhouhaihai
优化冒险结构 增加夹层功能
|
308
309
310
311
312
313
314
|
--boss
randomFunc[AdvEventType.BOSS] = function()
if haveBoss then return false end
if randomCommon() == false then
return false
end
haveBoss = true
|
e994ca55
zhouhaihai
任务 自动领取
|
315
|
self.haveBoss = true -- 刷新任务用的临时变量
|
43babcff
zhouhaihai
优化冒险结构 增加夹层功能
|
316
|
end
|
7828ffd0
zhouhaihai
冒险 连续选择点 和 地图因子
|
317
318
319
320
321
322
323
324
325
326
327
328
|
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
冒险接口
|
329
|
|
43babcff
zhouhaihai
优化冒险结构 增加夹层功能
|
330
331
332
333
334
335
336
337
338
339
340
341
342
|
--怪物
randomFunc[AdvEventType.Monster] = function()
if randomCommon() == false then
return false
end
table.insert(monsterEvents, event)
end
--选择点
randomFunc[AdvEventType.Choose] = randomCommon
--掉落点
randomFunc[AdvEventType.Drop] = randomCommon
--交易所
|
0e3ab88d
zhouhaihai
中继层
|
343
344
345
346
|
randomFunc[AdvEventType.Trader] = function()
if self.adv.isRelay and isNewRelay then return false end
return randomCommon()
end
|
43babcff
zhouhaihai
优化冒险结构 增加夹层功能
|
347
|
--建筑
|
0e3ab88d
zhouhaihai
中继层
|
348
349
350
351
|
randomFunc[AdvEventType.Build] = function()
if self.adv.isRelay and isEnter then return false end
return randomCommon()
end
|
43babcff
zhouhaihai
优化冒险结构 增加夹层功能
|
352
353
354
355
356
357
|
--陷阱
randomFunc[AdvEventType.Trap] = randomCommon
--点击生效
randomFunc[AdvEventType.Click] = randomCommon
--跨层点
randomFunc[AdvEventType.Layer] = randomCommon
|
43babcff
zhouhaihai
优化冒险结构 增加夹层功能
|
358
359
360
361
362
363
364
365
366
367
368
|
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
中继层完成, 新增两个冒险物品使用效果
|
369
370
371
372
373
|
local function giveEvent(roomId, blockId, eventType, eventId)
local event = {etype = eventType, id = eventId}
mapInfo.rooms[roomId]["event"][blockId] = event
end
|
43babcff
zhouhaihai
优化冒险结构 增加夹层功能
|
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
|
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
中继层完成, 新增两个冒险物品使用效果
|
398
399
400
401
402
|
-- 随机功能需要强制随机的东西
if self.adv.isRelay and isNewRelay then
local relayData = self.adv:isHaveRelay()
if relayData then
|
7b64b6cd
zhouhaihai
中继层优化
|
403
404
|
-- choose
|
6dc482bb
zhouhaihai
中继层完成, 新增两个冒险物品使用效果
|
405
406
|
local choose = relayData.choose:toArray(true, "=")
local lastCount = stagePool["global"][AdvCodeRandomStage] and #stagePool["global"][AdvCodeRandomStage] or 0
|
6dc482bb
zhouhaihai
中继层完成, 新增两个冒险物品使用效果
|
407
|
for _, chooseId in pairs(choose) do
|
f60fc764
zhouhaihai
bug
|
408
|
if lastCount <= 0 then break end
|
6dc482bb
zhouhaihai
中继层完成, 新增两个冒险物品使用效果
|
409
410
411
412
413
414
415
|
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
|
416
|
stagePool[cur["room"]][AdvCodeRandomStage][cur["block"]] = nil
|
6dc482bb
zhouhaihai
中继层完成, 新增两个冒险物品使用效果
|
417
|
end
|
7b64b6cd
zhouhaihai
中继层优化
|
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
|
-- 掉落
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
中继层完成, 新增两个冒险物品使用效果
|
434
435
436
|
end
end
|
9ced5432
zhouhaihai
冒险支援效果 保底事件
|
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
|
-- 低保事件
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
优化冒险结构 增加夹层功能
|
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
|
-- 全地图事件 优先级高
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
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 改为全局
|
535
|
self.adv.owner:setProperty("advLimit", eventLimit)
|
43babcff
zhouhaihai
优化冒险结构 增加夹层功能
|
536
537
538
539
|
return mapInfo
end
--关卡事件库
|
4faef572
zhouhaihai
冒险任务,冒险扫荡, 冒险中继
|
540
541
|
getEventLib = function(self, needEventType) -- needEventType 需要的事件
local chapterId, level = self.adv.chapterId, self.adv.level
|
8da953a7
zhouhaihai
无尽模式
|
542
|
if AdvCommon.isEndless(chapterId) then
|
916096ed
zhouhaihai
神器效果
|
543
|
level = AdvCommon.getEndlessDataLv(chapterId, level)
|
8da953a7
zhouhaihai
无尽模式
|
544
|
end
|
43babcff
zhouhaihai
优化冒险结构 增加夹层功能
|
545
546
547
548
549
550
551
552
553
|
local libsToType = {
["event_monsterCsv"] = {AdvEventType.Monster, AdvEventType.BOSS, AdvEventType.Monster},
["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
冒险 连续选择点 和 地图因子
|
554
|
["event_linkchooseCsv"] = AdvEventType.LinkChoose,
|
43babcff
zhouhaihai
优化冒险结构 增加夹层功能
|
555
556
|
}
local eventLib = {}
|
4faef572
zhouhaihai
冒险任务,冒险扫荡, 冒险中继
|
557
558
559
|
local advEventOpenStatus = self.adv.owner:advEventOpenStatus()
|
17d8d855
zhouhaihai
冒险 时间 limit 改为全局
|
560
561
|
local eventLimit = self.adv.owner:getProperty("advLimit")
|
43babcff
zhouhaihai
优化冒险结构 增加夹层功能
|
562
563
564
565
566
567
568
569
570
571
572
573
|
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
冒险任务,冒险扫荡, 冒险中继
|
574
575
|
local etype = type(eventType) == "table" and eventType[data.type] or eventType
|
4d943586
zhouhaihai
直通 advt gm
|
576
|
if data.levelchapter == chapterId and (data.unlockType == 0 or (advEventOpenStatus[etype] or {})[data.unlockType]) then
|
7828ffd0
zhouhaihai
冒险 连续选择点 和 地图因子
|
577
578
579
580
581
582
|
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 改为全局
|
583
584
585
586
587
588
589
590
591
592
593
594
595
596
|
-- data.limit 改为 整个冒险全程
local limit = data.limit
if data.limit ~= 0 then
limit = data.limit - ((eventLimit[etype] or {})[id] or 0)
if limit <= 0 then
add = false
end
end
if add and (etype == AdvEventType.LinkChoose or etype == AdvEventType.Choose) then --只能有一次
limit = 1
end
|
7828ffd0
zhouhaihai
冒险 连续选择点 和 地图因子
|
597
598
599
|
if add then
if AdvCommon.checkIsIn(level, data.leveltype, data.levellimit) then
eventLib[etype][data.BlockEventType] = eventLib[etype][data.BlockEventType] or {}
|
17d8d855
zhouhaihai
冒险 时间 limit 改为全局
|
600
|
eventLib[etype][data.BlockEventType][id] = {showup = data.showup, limit = limit, dlimit = data.limit}
|
7828ffd0
zhouhaihai
冒险 连续选择点 和 地图因子
|
601
|
end
|
43babcff
zhouhaihai
优化冒险结构 增加夹层功能
|
602
603
604
605
606
607
608
609
610
611
612
|
end
end
end
if needEventType then
break
end
end
end
return eventLib
end
|
43babcff
zhouhaihai
优化冒险结构 增加夹层功能
|
613
|
return Map
|