43babcff
zhouhaihai
优化冒险结构 增加夹层功能
|
1
2
3
4
5
6
7
8
9
10
11
12
13
|
--块类型
local AdvCommon = require "adv.AdvCommon"
local Passive = require "adv.AdvPassive"
local Block = class("AdvBlock")
function Block:ctor(room, blockId, event, isOpen, trapId)
self.room = room
self.blockId = blockId
self.col, self.row = AdvCommon.getCrById(self.blockId)
self.isOpen = isOpen and true or false
self.trapId = trapId
|
48962a74
zhouhaihai
路障系统提交
|
14
|
self:updateEvent(event, true)
|
43babcff
zhouhaihai
优化冒险结构 增加夹层功能
|
15
16
17
18
19
20
21
22
23
|
end
function Block:isBoss()
return self:getEventType() == AdvEventType.BOSS
end
function Block:isMonster()
return (self:getEventType() == AdvEventType.BOSS or self:getEventType() == AdvEventType.Monster)
end
|
9687f887
zhouhaihai
建筑被动
|
24
25
26
27
|
function Block:isBuild()
return self:getEventType() == AdvEventType.Build
end
|
cb071e8d
zhouhaihai
多条件选项
|
28
29
30
31
|
function Block:isChoose()
return self:getEventType() == AdvEventType.Choose
end
|
43babcff
zhouhaihai
优化冒险结构 增加夹层功能
|
32
33
34
35
|
function Block:getEventType()
return self.event and self.event.etype
end
|
2d87caee
zhouhaihai
地块替换优化 新的效果类型
|
36
37
38
39
|
function Block:getStageType()
return self.room:getStageType(self.blockId)
end
|
48962a74
zhouhaihai
路障系统提交
|
40
|
function Block:updateEvent(event, isInit)
|
2d87caee
zhouhaihai
地块替换优化 新的效果类型
|
41
42
43
44
45
|
if not isInit then
-- 有些事件删除 需要处理
if self:isBuild() then
self.room.map.adv.battle:removeBuildByPos(self.room.roomId, self.blockId)
elseif self:isMonster() then
|
739cf86a
zhouhaihai
字段名错误
|
46
47
|
if self.event.mId then
self.room.map.adv.battle:removeEnemyById(self.event.mId)
|
2d87caee
zhouhaihai
地块替换优化 新的效果类型
|
48
49
50
|
end
end
end
|
1e789624
zhouhaihai
新的 buff 效果
|
51
52
|
local oldet = self:getEventType()
|
43babcff
zhouhaihai
优化冒险结构 增加夹层功能
|
53
|
self.event = event
|
2d87caee
zhouhaihai
地块替换优化 新的效果类型
|
54
55
|
if not isInit and self.event then
-- 判断下类型是不是错的
|
7dbd787a
zhouhaihai
bug
|
56
|
if not self:getEventData() and (self:getEventType() ~= AdvEventType.Drop or not self.event.item) then
|
2d87caee
zhouhaihai
地块替换优化 新的效果类型
|
57
58
59
60
61
62
|
self:clear()
assert(false, "updateEvent error, : event " .. (event.etype or "nil"))
return
end
self:randomEvent()
end
|
1e789624
zhouhaihai
新的 buff 效果
|
63
64
|
if not isInit and self.isOpen then
|
47c6253a
zhouhaihai
bugfix
|
65
|
self:quickDrop()
|
1e789624
zhouhaihai
新的 buff 效果
|
66
67
68
69
70
71
72
|
local newet = self:getEventType()
if oldet ~= newet then
local em = {}
if oldet then
em[oldet] =1
end
if newet then
|
a55177a3
zhouhaihai
bug
|
73
|
em[newet] =1
|
1e789624
zhouhaihai
新的 buff 效果
|
74
75
76
77
78
79
80
81
82
|
end
local player = self.room.map.adv.battle.player
player:attrChangeCondBuffCheck(4, em)
for _, monster in pairs(player:getTeam(2)) do
monster:attrChangeCondBuffCheck(4, em)
end
end
end
|
43babcff
zhouhaihai
优化冒险结构 增加夹层功能
|
83
84
85
|
end
function Block:clear()
|
1e789624
zhouhaihai
新的 buff 效果
|
86
87
|
local et = self:getEventType()
if et == AdvEventType.Trap then
|
43babcff
zhouhaihai
优化冒险结构 增加夹层功能
|
88
|
self.trapId = self.event.id
|
1e789624
zhouhaihai
新的 buff 效果
|
89
|
elseif et == AdvEventType.Build then
|
44dd6cae
zhouhaihai
建筑消失删除建筑角色
|
90
91
92
93
|
local build = self.room.map.adv.battle:getBuild(self.room.roomId, self.blockId, self.room.map.mapIdx)
if build then
build.isDead = true
end
|
43babcff
zhouhaihai
优化冒险结构 增加夹层功能
|
94
95
|
end
self.event = nil
|
1e789624
zhouhaihai
新的 buff 效果
|
96
97
98
99
100
101
102
103
104
105
|
if et then
local em = {[et] = 1}
local player = self.room.map.adv.battle.player
player:attrChangeCondBuffCheck(4, em)
for _, monster in pairs(player:getTeam(2)) do
monster:attrChangeCondBuffCheck(4, em)
end
end
|
43babcff
zhouhaihai
优化冒险结构 增加夹层功能
|
106
107
|
end
|
4f0a5fae
zhouhaihai
营养剂
|
108
109
|
function Block:randomEvent()
|
43babcff
zhouhaihai
优化冒险结构 增加夹层功能
|
110
111
112
113
114
115
116
|
local room = self.room
local map = room.map
local adv = map.adv
--如果翻开有数据处理在这里处理
local randomFunc = {}
--怪
randomFunc[AdvEventType.Monster] = function()
|
43babcff
zhouhaihai
优化冒险结构 增加夹层功能
|
117
118
|
local enemy = adv.battle:getEnemy(room.roomId, self.blockId, map.mapIdx)
if enemy then
|
a0834e49
zhouhaihai
增加潜行 功能
|
119
|
enemy:unlock()
|
43babcff
zhouhaihai
优化冒险结构 增加夹层功能
|
120
121
|
else
enemy = adv.battle:addEnemy(room, self, map.mapIdx)
|
43babcff
zhouhaihai
优化冒险结构 增加夹层功能
|
122
123
|
end
enemy:triggerPassive(Passive.BORN_ONCE)
|
d3da3368
zhouhaihai
冒险地图被动技, buff 神器
|
124
125
|
adv.battle.player:triggerPassive(Passive.OPEN_MONSTER, {trigger = enemy})
|
1e789624
zhouhaihai
新的 buff 效果
|
126
|
adv.battle.player:attrChangeCondBuffCheck(3, enemy:getClassify())
|
d3da3368
zhouhaihai
冒险地图被动技, buff 神器
|
127
|
for _, monster in pairs(adv.battle.player:getTeam(2)) do
|
1e789624
zhouhaihai
新的 buff 效果
|
128
129
|
monster:triggerPassive(Passive.OPEN_MONSTER, {trigger = enemy})
monster:attrChangeCondBuffCheck(3, enemy:getClassify())
|
d3da3368
zhouhaihai
冒险地图被动技, buff 神器
|
130
|
end
|
43babcff
zhouhaihai
优化冒险结构 增加夹层功能
|
131
132
133
134
|
end
randomFunc[AdvEventType.BOSS] = randomFunc[AdvEventType.Monster]
--掉落
randomFunc[AdvEventType.Drop] = function()
|
2d87caee
zhouhaihai
地块替换优化 新的效果类型
|
135
136
137
|
if not self.event.item then
self.event.item = csvdb["event_dropCsv"][self.event.id]["range"]:randWeight(true)
end
|
43babcff
zhouhaihai
优化冒险结构 增加夹层功能
|
138
139
140
141
142
143
|
end
--交易
randomFunc[AdvEventType.Trader] = function()
local data = csvdb["event_traderCsv"][self.event.id]
self.event.shop = {}
self.event.status = "" --购买次数状态 1 就是购买过了 -- 购买id就是shop索引
|
f8408529
zhouhaihai
冒险商店
|
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
|
local needDiscount = data.discount -- 需要的折扣数量
local curHad = {}
local advShop = adv.owner:getProperty("advShop")
local function randomGoods(range, gcount)
local pool = range:toTableArray(true) -- {{id, weight}, ... }
local function randomOneGood()
for i = #pool, 1, -1 do
local curId = pool[i][1]
local curData = csvdb["event_trader_goodsCsv"][curId]
if not curData then
table.remove(pool, i)
else
if curData.restrict == 1 then -- 冒险内限制
if curData.restrictnum <= ((adv.shopStatus[curId] or 0) + (curHad[curId] or 0)) then
table.remove(pool, i)
end
elseif curData.restrict == 2 then -- 角色限制
if curData.restrictnum <= ((advShop[curId] or 0) + (curHad[curId] or 0)) then
table.remove(pool, i)
end
end
end
end
if #pool <= 0 then
return false
end
local idx = math.randWeight(pool, 2)
local getId = pool[idx][1]
|
b992f1ca
zhouhaihai
bug
|
172
|
local getData = csvdb["event_trader_goodsCsv"][getId]
|
f8408529
zhouhaihai
冒险商店
|
173
|
if getData.restrict ~= 0 then
|
aef8ca87
zhouhaihai
两个bug
|
174
|
curHad[getId] = (curHad[getId] or 0) + 1
|
f8408529
zhouhaihai
冒险商店
|
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
|
end
if getData.discount ~= "" and needDiscount > 0 then
needDiscount = needDiscount - 1
table.insert(self.event.shop, {getId, getData.discount:randWeight()})
else
table.insert(self.event.shop, {getId})
end
return true
end
for i = 1, gcount do
if not randomOneGood() then
break
end
end
end
|
43babcff
zhouhaihai
优化冒险结构 增加夹层功能
|
192
193
194
|
for i = 1, 10 do
local numS, rangeS = "num" .. i, "range" .. i
if data[numS] and data[rangeS] then
|
f8408529
zhouhaihai
冒险商店
|
195
|
randomGoods(data[rangeS], data[numS])
|
43babcff
zhouhaihai
优化冒险结构 增加夹层功能
|
196
197
198
199
200
201
202
|
else
break
end
end
end
--建筑
randomFunc[AdvEventType.Build] = function()
|
9687f887
zhouhaihai
建筑被动
|
203
204
205
206
207
|
local build = adv.battle:getBuild(room.roomId, self.blockId, map.mapIdx)
if build then
build:unlock()
else
build = adv.battle:addEnemy(room, self, map.mapIdx)
|
9687f887
zhouhaihai
建筑被动
|
208
209
|
end
build:triggerPassive(Passive.BORN_ONCE)
|
43babcff
zhouhaihai
优化冒险结构 增加夹层功能
|
210
211
212
213
|
end
randomFunc[AdvEventType.Trap] = function()
local data = csvdb["event_trapCsv"][self.event.id]
|
e058aebe
zhouhaihai
修改生效位置
|
214
215
216
|
-- 因为一些神器效果 提前触发被动
adv.battle.player:triggerPassive(Passive.CLICK_TRAP)
|
7828ffd0
zhouhaihai
冒险 连续选择点 和 地图因子
|
217
|
local buffs = data.effect:toArray(true, "=")
|
f3c37873
zhouhaihai
block
|
218
|
|
b9b9c757
zhouhaihai
陷阱翻开房间
|
219
220
|
local backTrap = true
|
f3c37873
zhouhaihai
block
|
221
222
223
224
225
|
if data.target == 0 then -- 给玩家增加buff
for _, buffId in ipairs(buffs) do
adv.battle.player:addBuff(buffId)
end
elseif data.target == 1 then-- 给玩家 和 所有敌人同样增加buff
|
7828ffd0
zhouhaihai
冒险 连续选择点 和 地图因子
|
226
|
local enemys = adv.battle.player:getTeam(2)
|
f3c37873
zhouhaihai
block
|
227
228
229
|
for _, buffId in ipairs(buffs) do
adv.battle.player:addBuff(buffId)
end
|
7828ffd0
zhouhaihai
冒险 连续选择点 和 地图因子
|
230
231
232
233
234
|
for k , enemy in ipairs(enemys) do
for _, buffId in ipairs(buffs) do
enemy:addBuff(buffId)
end
end
|
b9b9c757
zhouhaihai
陷阱翻开房间
|
235
236
237
|
elseif data.target == 2 then -- 翻开房间
self.room.map.adv:getCurMap():openBlocksByRoom(self.room.roomId)
backTrap = false
|
f3c37873
zhouhaihai
block
|
238
239
|
elseif data.target == 3 then -- 翻开周围8格,并给怪物附带buff(不伤害玩家)
self.room.map.adv:getCurMap():openBlocksBySize(self.room.roomId, self.blockId, 2)
|
a0834e49
zhouhaihai
增加潜行 功能
|
240
241
242
243
|
local enemys = self.room.map.adv:getCurMap():getEnemysBySize(self.room.roomId, self.blockId, 2)
for _, e in ipairs(enemys) do
for _, buffId in ipairs(buffs) do
e:addBuff(buffId)
|
b382964b
zhouhaihai
给翻开的怪加buff
|
244
245
|
end
end
|
b6a2b78b
zhouhaihai
冒险 buff 类型 34 35
|
246
247
248
249
250
251
252
|
elseif data.target == 4 then
local enemys = self.room.map.adv:getCurMap():openBlocksIsMonsterByRoom(self.room.roomId)
for _, e in ipairs(enemys) do
for _, buffId in ipairs(buffs) do
e:addBuff(buffId)
end
end
|
7828ffd0
zhouhaihai
冒险 连续选择点 和 地图因子
|
253
|
end
|
b9b9c757
zhouhaihai
陷阱翻开房间
|
254
|
|
7828ffd0
zhouhaihai
冒险 连续选择点 和 地图因子
|
255
256
257
258
259
260
|
if data.specialEff ~= "" then
local effect = data.specialEff:toArray(true, "=")
if effect[1] == 1 then
self.room.map.adv:mapItemChange(effect[2])
end
end
|
e058aebe
zhouhaihai
修改生效位置
|
261
|
|
b176d7d3
zhouhaihai
冒险成就
|
262
|
adv:checkAchievement(adv.AchievType.Trap, 1, self.event.id)
|
b9b9c757
zhouhaihai
陷阱翻开房间
|
263
264
265
|
if backTrap then
adv:backTrap()
end
|
43babcff
zhouhaihai
优化冒险结构 增加夹层功能
|
266
267
268
269
270
271
272
273
274
|
self:clear()
end
if self.event then -- 随机出具体的事件
if randomFunc[self:getEventType()] then
randomFunc[self:getEventType()]()
end
end
|
4f0a5fae
zhouhaihai
营养剂
|
275
276
|
end
|
48962a74
zhouhaihai
路障系统提交
|
277
278
279
280
281
282
283
284
285
286
287
288
|
-- 获取event 数据
function Block:getEventData()
local typToCsv = {
[AdvEventType.Monster] = "event_monsterCsv",
[AdvEventType.BOSS] = "event_monsterCsv",
[AdvEventType.Choose] = "event_chooseCsv",
[AdvEventType.Drop] = "event_dropCsv",
[AdvEventType.Build] = "event_buildingCsv",
[AdvEventType.Trader] = "event_traderCsv",
[AdvEventType.Trap] = "event_trapCsv",
[AdvEventType.Click] = "event_clickCsv",
[AdvEventType.Layer] = "event_layerCsv",
|
48962a74
zhouhaihai
路障系统提交
|
289
290
291
292
293
294
295
296
297
298
|
[AdvEventType.LinkChoose] = "event_linkchooseCsv",
}
local etype = self:getEventType()
if not etype then return end
if not self.event.id then return end
if not typToCsv[etype] then return end
return csvdb[typToCsv[etype]][self.event.id]
end
|
4f0a5fae
zhouhaihai
营养剂
|
299
300
301
302
303
304
305
|
--事件有需要额外处理的部分
function Block:open()
if self.isOpen then return end
local room = self.room
local map = room.map
local adv = map.adv
|
43babcff
zhouhaihai
优化冒险结构 增加夹层功能
|
306
|
self.isOpen = true
|
c843f805
zhouhaihai
bug 栈溢出
|
307
|
self:randomEvent()
|
8955225b
zhouhaihai
快速拾取。快速使用
|
308
|
self:quickDrop()
|
1e789624
zhouhaihai
新的 buff 效果
|
309
310
311
312
313
314
315
316
317
318
|
local et = self:getEventType()
if et then
local em = {[et] = 1}
local player = self.room.map.adv.battle.player
player:attrChangeCondBuffCheck(4, em)
for _, monster in pairs(player:getTeam(2)) do
monster:attrChangeCondBuffCheck(4, em)
end
end
|
d3da3368
zhouhaihai
冒险地图被动技, buff 神器
|
319
|
return true
|
43babcff
zhouhaihai
优化冒险结构 增加夹层功能
|
320
321
|
end
|
8955225b
zhouhaihai
快速拾取。快速使用
|
322
323
324
325
326
327
328
329
330
331
|
function Block:quickDrop()
if self:getEventType() == AdvEventType.Drop and self.event.item then
local itemId, count = table.unpack(self.event.item)
if globalCsv.adv_auto_collect[itemId] then
self.room.map.adv:award({[itemId] = count}, {log = {desc = "clickDrop"}}, {roomId = self.room.roomId, blockId = self.blockId, tag = 1})
self:clear()
end
end
end
|
48962a74
zhouhaihai
路障系统提交
|
332
|
function Block:getObstacle()
|
b6a2b78b
zhouhaihai
冒险 buff 类型 34 35
|
333
334
|
if self:isMonster() then
local enemy = self.room.map.adv.battle:getEnemy(self.room.roomId, self.blockId)
|
b4b28ccd
zhouhaihai
数据保护
|
335
336
337
|
if enemy then
return enemy:getObstacle()
end
|
b6a2b78b
zhouhaihai
冒险 buff 类型 34 35
|
338
|
end
|
48962a74
zhouhaihai
路障系统提交
|
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
|
local data = self:getEventData()
if not data then return 0 end
return data.obstacle or 0
end
-- 是否看守周围地板
function Block:isGuard()
return self.isOpen and self:getObstacle() == 2
end
-- 是否是路障
function Block:isHinder()
return self.isOpen and self:getObstacle() == 1
end
-- 玩家是否经过 -- 已经翻开 并且 不是路障
function Block:isWalk()
return self.isOpen and not self:isHinder()
end
|
43babcff
zhouhaihai
优化冒险结构 增加夹层功能
|
359
|
return Block
|