Commit 7b2dc17cfcec7bdf38fda812c174f8a7377f849d
1 parent
cb071e8d
地图 层 buff passive
Showing
7 changed files
with
125 additions
and
25 deletions
Show diff stats
src/adv/Adv.lua
... | ... | @@ -157,6 +157,11 @@ function Adv:initByChapter(params) |
157 | 157 | self.battle.player:afterLayer() -- 玩家的buff 清理一下 |
158 | 158 | end |
159 | 159 | |
160 | + -- 不是中继层 加上 层 和 地图的buff和被动 | |
161 | + if not self.isRelay then | |
162 | + self.battle:initMapEffect() | |
163 | + end | |
164 | + | |
160 | 165 | -- 中继进入奖励 |
161 | 166 | if relayData and isEnter then |
162 | 167 | self:awardRelay(relayData, notNotify) |
... | ... | @@ -1440,6 +1445,7 @@ local function clickLayer(self, room, block, params) |
1440 | 1445 | |
1441 | 1446 | self.maps[mapIdx] = AdvMap.new(self, mapIdx, mapId) |
1442 | 1447 | self.battle:initMapEnemys(mapIdx, true) |
1448 | + self.battle:initMapEffect(true) | |
1443 | 1449 | self.maps[mapIdx]:initBattleAfter() |
1444 | 1450 | self:checkAchievement(Adv.AchievType.EnterILayer, 1, mapId) |
1445 | 1451 | end |
... | ... | @@ -1648,7 +1654,7 @@ function Adv:doActive(activeId, target) |
1648 | 1654 | doActiveEffect[5] = function(_) |
1649 | 1655 | for _, target in ipairs(targers) do |
1650 | 1656 | if not target.lock and not target.isDead then |
1651 | - target.isDead = true | |
1657 | + target:kill() | |
1652 | 1658 | self:backBlockChange(target.roomId, target.blockId) |
1653 | 1659 | end |
1654 | 1660 | end | ... | ... |
src/adv/AdvBattle.lua
... | ... | @@ -125,7 +125,7 @@ function Battle:initMapEnemys(mapIdx, after) |
125 | 125 | if map then |
126 | 126 | for _, room in pairs(map.rooms) do |
127 | 127 | for _, block in pairs(room.blocks) do |
128 | - self:addEnemy(room, block, mapIdx) | |
128 | + self:addEnemy(room, block, mapIdx, true) | |
129 | 129 | end |
130 | 130 | end |
131 | 131 | end |
... | ... | @@ -146,9 +146,10 @@ function Battle:initMapEnemys(mapIdx, after) |
146 | 146 | self.cachePassiveEvent[mapIdx] = nil |
147 | 147 | end |
148 | 148 | |
149 | -function Battle:addEnemy(room, block, mapIdx) | |
149 | +function Battle:addEnemy(room, block, mapIdx, init) | |
150 | 150 | mapIdx = mapIdx or self.adv:getCurMapIdx() |
151 | 151 | |
152 | + local isNew, player, data | |
152 | 153 | if block:isMonster() then |
153 | 154 | if not block.event.enemy then |
154 | 155 | local enemyCsv = csvdb["event_monsterCsv"][block.event.id] |
... | ... | @@ -162,14 +163,15 @@ function Battle:addEnemy(room, block, mapIdx) |
162 | 163 | table.insert(enemy.passives, {id = id}) |
163 | 164 | end |
164 | 165 | block.event.enemy = enemy |
166 | + isNew = true | |
165 | 167 | end |
166 | 168 | if not block.event.mId then |
167 | 169 | block.event.mId = self.adv.lastEnemyId |
168 | 170 | self.adv.lastEnemyId = self.adv.lastEnemyId + 1 |
169 | 171 | end |
170 | - local player = Enemy.new(self, block.event.mId, block.event.id, room.roomId, block.blockId, not block.isOpen, block.event.enemy, mapIdx) | |
172 | + data = block.event.enemy | |
173 | + player = Enemy.new(self, block.event.mId, block.event.id, room.roomId, block.blockId, not block.isOpen, block.event.enemy, mapIdx) | |
171 | 174 | table.insert(self.enemys[mapIdx], player) |
172 | - return player | |
173 | 175 | elseif block:isBuild() then |
174 | 176 | if not block.event.build then |
175 | 177 | local buildCsv = csvdb["event_buildingCsv"][block.event.id] |
... | ... | @@ -179,11 +181,28 @@ function Battle:addEnemy(room, block, mapIdx) |
179 | 181 | table.insert(build.passives, {id = id}) |
180 | 182 | end |
181 | 183 | block.event.build = build |
184 | + isNew = true | |
182 | 185 | end |
183 | - local player = Build.new(self, block.event.id, room.roomId, block.blockId, not block.isOpen, block.event.build, mapIdx) | |
186 | + data = block.event.build | |
187 | + player = Build.new(self, block.event.id, room.roomId, block.blockId, not block.isOpen, block.event.build, mapIdx) | |
184 | 188 | table.insert(self.builds[mapIdx], player) |
185 | - return player | |
186 | 189 | end |
190 | + if not init then | |
191 | + player:initAfter(data) | |
192 | + | |
193 | + -- 游戏中新创建的 加上地图 floor 效果 | |
194 | + if isNew then | |
195 | + local passives, buffs = self:getMapEffect(2, true, mapIdx) | |
196 | + for _, passive in ipairs(passives) do | |
197 | + player:addPassive({id = passive}) | |
198 | + end | |
199 | + | |
200 | + for _, buff in ipairs(buffs) do | |
201 | + enemy:addBuff(buff) | |
202 | + end | |
203 | + end | |
204 | + end | |
205 | + return player | |
187 | 206 | end |
188 | 207 | |
189 | 208 | function Battle:getEnemy(roomId, blockId, mapIdx) |
... | ... | @@ -323,7 +342,7 @@ function Battle:battleBegin(roomId, blockId, params) |
323 | 342 | if not player then return end |
324 | 343 | -- 玩家没死就是怪死了 |
325 | 344 | if player.hp > 0 then |
326 | - enemy:hurt(enemy.hp, self.player, {hurtType = 5}) | |
345 | + enemy:kill() | |
327 | 346 | self.player:effectBattleBuff() |
328 | 347 | |
329 | 348 | self.adv.owner:checkTaskEnter("AdvBattleWin", {id = self.adv.chapterId}) |
... | ... | @@ -341,6 +360,63 @@ function Battle:battleBegin(roomId, blockId, params) |
341 | 360 | end |
342 | 361 | |
343 | 362 | |
363 | +function Battle:getMapEffect(ctype, ilayer, mapIdx) | |
364 | + mapIdx = mapIdx or self.adv:getCurMapIdx() | |
365 | + local mapData = self.adv.maps[mapIdx]:getMapInfoCsv() or {} | |
366 | + local floorData = self.adv:getCurFloorData() or {} | |
367 | + | |
368 | + local passives = {} | |
369 | + local buffs = {} | |
370 | + | |
371 | + for _type, temp in ipairs({mapData, floorData}) do | |
372 | + for _, one in ipairs((temp.passive or ""):toTableArray(true)) do | |
373 | + passives[one[1]] = passives[one[1]] or {} | |
374 | + if ilayer and one[1] == 1 and _type == 2 then | |
375 | + else | |
376 | + table.insert(passives[one[1]], one[2]) | |
377 | + end | |
378 | + end | |
379 | + for _, one in ipairs((temp.buff or ""):toTableArray(true)) do | |
380 | + buffs[one[1]] = buffs[one[1]] or {} | |
381 | + if ilayer and one[1] == 1 and _type == 2 then | |
382 | + else | |
383 | + table.insert(buffs[one[1]], one[2]) | |
384 | + end | |
385 | + end | |
386 | + end | |
387 | + if ctype then | |
388 | + passives = passives[ctype] or {} | |
389 | + buffs = buffs[ctype] or {} | |
390 | + end | |
391 | + return passives, buffs | |
392 | +end | |
393 | +-- 夹层玩家 不重复加 floor | |
394 | +function Battle:initMapEffect(ilayer) | |
395 | + local passives, buffs = self:getMapEffect(nil, ilayer) | |
396 | + local mapIdx = self.adv:getCurMapIdx() | |
397 | + | |
398 | + for _, passive in ipairs(passives[1] or {}) do | |
399 | + self.player:addPassive({id = passive}) | |
400 | + end | |
401 | + | |
402 | + for _, passive in ipairs(passives[2] or {}) do | |
403 | + for _, enemy in ipairs(self.enemys[mapIdx]) do | |
404 | + enemy:addPassive({id = passive}) | |
405 | + end | |
406 | + end | |
407 | + | |
408 | + for _, buff in ipairs(buffs[1] or {}) do | |
409 | + self.palyer:addBuff(buff) | |
410 | + end | |
411 | + | |
412 | + for _, buff in ipairs(buffs[2] or {}) do | |
413 | + for _, enemy in ipairs(self.enemys[mapIdx]) do | |
414 | + enemy:addBuff(buff) | |
415 | + end | |
416 | + end | |
417 | +end | |
418 | + | |
419 | + | |
344 | 420 | --写入数据 |
345 | 421 | function Battle:saveDB() |
346 | 422 | for idx, mapEnemys in pairs(self.enemys) do | ... | ... |
src/adv/AdvBlock.lua
... | ... | @@ -63,7 +63,6 @@ function Block:randomEvent() |
63 | 63 | enemy:unlock() |
64 | 64 | else |
65 | 65 | enemy = adv.battle:addEnemy(room, self, map.mapIdx) |
66 | - enemy:initAfter(self.event.enemy) | |
67 | 66 | end |
68 | 67 | enemy:triggerPassive(Passive.BORN_ONCE) |
69 | 68 | |
... | ... | @@ -146,7 +145,6 @@ function Block:randomEvent() |
146 | 145 | build:unlock() |
147 | 146 | else |
148 | 147 | build = adv.battle:addEnemy(room, self, map.mapIdx) |
149 | - build:initAfter(self.event.build) | |
150 | 148 | end |
151 | 149 | build:triggerPassive(Passive.BORN_ONCE) |
152 | 150 | end | ... | ... |
src/adv/AdvBuff.lua
src/adv/AdvMap.lua
... | ... | @@ -49,6 +49,11 @@ function Map:initBattleAfter() |
49 | 49 | end |
50 | 50 | end |
51 | 51 | |
52 | + | |
53 | +function Map:getMapInfoCsv() | |
54 | + return csvdb["mapCsv"][self.mapId] | |
55 | +end | |
56 | + | |
52 | 57 | function Map:getDB() |
53 | 58 | local map = {} |
54 | 59 | map.mapId = self.mapId |
... | ... | @@ -124,7 +129,6 @@ function Map:addNewMonsterRand(monsterId, where) |
124 | 129 | block:updateEvent(event) |
125 | 130 | |
126 | 131 | local enemy = self.adv.battle:addEnemy(room, block) |
127 | - enemy:initAfter(event.enemy) | |
128 | 132 | enemy:triggerPassive(Passive.BORN_ONCE) |
129 | 133 | |
130 | 134 | return room, block | ... | ... |
src/adv/AdvPassive.lua
... | ... | @@ -316,7 +316,7 @@ function Passive:effect(triggerPms) |
316 | 316 | self.round = self.passiveData.round |
317 | 317 | end |
318 | 318 | |
319 | - if self.count <= 0 and self.passiveData.refresh == 1 then -- 次数 <= 0 并且一次冒险内不刷新,被动可以直接移除 | |
319 | + if self.count <= 0 then -- 次数 <= 0 并且一次冒险内不刷新,被动可以直接移除 | |
320 | 320 | self.isDel = true |
321 | 321 | end |
322 | 322 | end |
... | ... | @@ -334,6 +334,12 @@ function Passive:afterRound() |
334 | 334 | end |
335 | 335 | end |
336 | 336 | |
337 | +function Passive:afterLayer() | |
338 | + if self.passiveData.mapLock == 1 or self.passiveData.floorType == 1 then | |
339 | + self.isDel = true | |
340 | + end | |
341 | +end | |
342 | + | |
337 | 343 | -- 可以触发 |
338 | 344 | function Passive:canTrigger( ) |
339 | 345 | return self.count > 0 and self.delay <= 0 | ... | ... |
src/adv/AdvPlayer.lua
... | ... | @@ -85,27 +85,26 @@ function BaseObject:clear() |
85 | 85 | self.passives = {} |
86 | 86 | end |
87 | 87 | |
88 | -function BaseObject:battleBegin() | |
89 | - for _, passive in ipairs(self.passives) do | |
90 | - passive:battleBegin() | |
91 | - end | |
92 | -end | |
93 | - | |
94 | -function BaseObject:battleEnd() | |
95 | - for _, buff in ipairs(self.buffs) do | |
96 | - buff:battleEnd() | |
97 | - end | |
98 | -end | |
99 | - | |
100 | 88 | function BaseObject:addPassive(params) |
101 | 89 | local skillId = params.id |
102 | 90 | local skillData = csvdb["adv_map_passiveCsv"][skillId] |
103 | 91 | if not skillData then return end |
104 | 92 | local level = params.level or 1 |
105 | 93 | if not skillData[level] then return end |
94 | + | |
95 | + if self:getPassiveById(skillId) then return end -- 被动技不能重复 | |
96 | + | |
106 | 97 | table.insert(self.passives, Passive.new(self, { id = skillId, level = level })) |
107 | 98 | end |
108 | 99 | |
100 | +function BaseObject:getPassiveById(bId) | |
101 | + for idx, passive in ipairs(self.passives) do | |
102 | + if passive.id == bId then | |
103 | + return passive | |
104 | + end | |
105 | + end | |
106 | +end | |
107 | + | |
109 | 108 | function BaseObject:getPassiveIdx(passive) |
110 | 109 | for idx, passive_ in ipairs(self.passives) do |
111 | 110 | if passive_ == passive then |
... | ... | @@ -535,6 +534,10 @@ function Enemy:isEnemy() |
535 | 534 | return true |
536 | 535 | end |
537 | 536 | |
537 | +function Enemy:kill() | |
538 | + self:hurt(self.hp, self.battle.player, {hurtType = 5}) | |
539 | +end | |
540 | + | |
538 | 541 | local Player = class("Player", BaseObject) |
539 | 542 | function Player:ctor(battle, data) |
540 | 543 | Player.super.ctor(self, battle) |
... | ... | @@ -648,11 +651,18 @@ function Player:effectBattleBuff() |
648 | 651 | end |
649 | 652 | |
650 | 653 | function Player:afterLayer() |
654 | + for _, passive in ipairs(self.passives) do | |
655 | + if not passive.isDel then | |
656 | + passive:afterLayer() | |
657 | + end | |
658 | + end | |
651 | 659 | for _, buff in ipairs(self.buffs) do |
652 | 660 | if not buff.isDel then |
653 | 661 | buff:afterLayer() |
654 | 662 | end |
655 | 663 | end |
664 | + | |
665 | + self:clearRound() | |
656 | 666 | end |
657 | 667 | |
658 | 668 | function Player:addBuff(buffId, releaser) | ... | ... |