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,6 +157,11 @@ function Adv:initByChapter(params) | ||
157 | self.battle.player:afterLayer() -- 玩家的buff 清理一下 | 157 | self.battle.player:afterLayer() -- 玩家的buff 清理一下 |
158 | end | 158 | end |
159 | 159 | ||
160 | + -- 不是中继层 加上 层 和 地图的buff和被动 | ||
161 | + if not self.isRelay then | ||
162 | + self.battle:initMapEffect() | ||
163 | + end | ||
164 | + | ||
160 | -- 中继进入奖励 | 165 | -- 中继进入奖励 |
161 | if relayData and isEnter then | 166 | if relayData and isEnter then |
162 | self:awardRelay(relayData, notNotify) | 167 | self:awardRelay(relayData, notNotify) |
@@ -1440,6 +1445,7 @@ local function clickLayer(self, room, block, params) | @@ -1440,6 +1445,7 @@ local function clickLayer(self, room, block, params) | ||
1440 | 1445 | ||
1441 | self.maps[mapIdx] = AdvMap.new(self, mapIdx, mapId) | 1446 | self.maps[mapIdx] = AdvMap.new(self, mapIdx, mapId) |
1442 | self.battle:initMapEnemys(mapIdx, true) | 1447 | self.battle:initMapEnemys(mapIdx, true) |
1448 | + self.battle:initMapEffect(true) | ||
1443 | self.maps[mapIdx]:initBattleAfter() | 1449 | self.maps[mapIdx]:initBattleAfter() |
1444 | self:checkAchievement(Adv.AchievType.EnterILayer, 1, mapId) | 1450 | self:checkAchievement(Adv.AchievType.EnterILayer, 1, mapId) |
1445 | end | 1451 | end |
@@ -1648,7 +1654,7 @@ function Adv:doActive(activeId, target) | @@ -1648,7 +1654,7 @@ function Adv:doActive(activeId, target) | ||
1648 | doActiveEffect[5] = function(_) | 1654 | doActiveEffect[5] = function(_) |
1649 | for _, target in ipairs(targers) do | 1655 | for _, target in ipairs(targers) do |
1650 | if not target.lock and not target.isDead then | 1656 | if not target.lock and not target.isDead then |
1651 | - target.isDead = true | 1657 | + target:kill() |
1652 | self:backBlockChange(target.roomId, target.blockId) | 1658 | self:backBlockChange(target.roomId, target.blockId) |
1653 | end | 1659 | end |
1654 | end | 1660 | end |
src/adv/AdvBattle.lua
@@ -125,7 +125,7 @@ function Battle:initMapEnemys(mapIdx, after) | @@ -125,7 +125,7 @@ function Battle:initMapEnemys(mapIdx, after) | ||
125 | if map then | 125 | if map then |
126 | for _, room in pairs(map.rooms) do | 126 | for _, room in pairs(map.rooms) do |
127 | for _, block in pairs(room.blocks) do | 127 | for _, block in pairs(room.blocks) do |
128 | - self:addEnemy(room, block, mapIdx) | 128 | + self:addEnemy(room, block, mapIdx, true) |
129 | end | 129 | end |
130 | end | 130 | end |
131 | end | 131 | end |
@@ -146,9 +146,10 @@ function Battle:initMapEnemys(mapIdx, after) | @@ -146,9 +146,10 @@ function Battle:initMapEnemys(mapIdx, after) | ||
146 | self.cachePassiveEvent[mapIdx] = nil | 146 | self.cachePassiveEvent[mapIdx] = nil |
147 | end | 147 | end |
148 | 148 | ||
149 | -function Battle:addEnemy(room, block, mapIdx) | 149 | +function Battle:addEnemy(room, block, mapIdx, init) |
150 | mapIdx = mapIdx or self.adv:getCurMapIdx() | 150 | mapIdx = mapIdx or self.adv:getCurMapIdx() |
151 | 151 | ||
152 | + local isNew, player, data | ||
152 | if block:isMonster() then | 153 | if block:isMonster() then |
153 | if not block.event.enemy then | 154 | if not block.event.enemy then |
154 | local enemyCsv = csvdb["event_monsterCsv"][block.event.id] | 155 | local enemyCsv = csvdb["event_monsterCsv"][block.event.id] |
@@ -162,14 +163,15 @@ function Battle:addEnemy(room, block, mapIdx) | @@ -162,14 +163,15 @@ function Battle:addEnemy(room, block, mapIdx) | ||
162 | table.insert(enemy.passives, {id = id}) | 163 | table.insert(enemy.passives, {id = id}) |
163 | end | 164 | end |
164 | block.event.enemy = enemy | 165 | block.event.enemy = enemy |
166 | + isNew = true | ||
165 | end | 167 | end |
166 | if not block.event.mId then | 168 | if not block.event.mId then |
167 | block.event.mId = self.adv.lastEnemyId | 169 | block.event.mId = self.adv.lastEnemyId |
168 | self.adv.lastEnemyId = self.adv.lastEnemyId + 1 | 170 | self.adv.lastEnemyId = self.adv.lastEnemyId + 1 |
169 | end | 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 | table.insert(self.enemys[mapIdx], player) | 174 | table.insert(self.enemys[mapIdx], player) |
172 | - return player | ||
173 | elseif block:isBuild() then | 175 | elseif block:isBuild() then |
174 | if not block.event.build then | 176 | if not block.event.build then |
175 | local buildCsv = csvdb["event_buildingCsv"][block.event.id] | 177 | local buildCsv = csvdb["event_buildingCsv"][block.event.id] |
@@ -179,11 +181,28 @@ function Battle:addEnemy(room, block, mapIdx) | @@ -179,11 +181,28 @@ function Battle:addEnemy(room, block, mapIdx) | ||
179 | table.insert(build.passives, {id = id}) | 181 | table.insert(build.passives, {id = id}) |
180 | end | 182 | end |
181 | block.event.build = build | 183 | block.event.build = build |
184 | + isNew = true | ||
182 | end | 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 | table.insert(self.builds[mapIdx], player) | 188 | table.insert(self.builds[mapIdx], player) |
185 | - return player | ||
186 | end | 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 | end | 206 | end |
188 | 207 | ||
189 | function Battle:getEnemy(roomId, blockId, mapIdx) | 208 | function Battle:getEnemy(roomId, blockId, mapIdx) |
@@ -323,7 +342,7 @@ function Battle:battleBegin(roomId, blockId, params) | @@ -323,7 +342,7 @@ function Battle:battleBegin(roomId, blockId, params) | ||
323 | if not player then return end | 342 | if not player then return end |
324 | -- 玩家没死就是怪死了 | 343 | -- 玩家没死就是怪死了 |
325 | if player.hp > 0 then | 344 | if player.hp > 0 then |
326 | - enemy:hurt(enemy.hp, self.player, {hurtType = 5}) | 345 | + enemy:kill() |
327 | self.player:effectBattleBuff() | 346 | self.player:effectBattleBuff() |
328 | 347 | ||
329 | self.adv.owner:checkTaskEnter("AdvBattleWin", {id = self.adv.chapterId}) | 348 | self.adv.owner:checkTaskEnter("AdvBattleWin", {id = self.adv.chapterId}) |
@@ -341,6 +360,63 @@ function Battle:battleBegin(roomId, blockId, params) | @@ -341,6 +360,63 @@ function Battle:battleBegin(roomId, blockId, params) | ||
341 | end | 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 | function Battle:saveDB() | 421 | function Battle:saveDB() |
346 | for idx, mapEnemys in pairs(self.enemys) do | 422 | for idx, mapEnemys in pairs(self.enemys) do |
src/adv/AdvBlock.lua
@@ -63,7 +63,6 @@ function Block:randomEvent() | @@ -63,7 +63,6 @@ function Block:randomEvent() | ||
63 | enemy:unlock() | 63 | enemy:unlock() |
64 | else | 64 | else |
65 | enemy = adv.battle:addEnemy(room, self, map.mapIdx) | 65 | enemy = adv.battle:addEnemy(room, self, map.mapIdx) |
66 | - enemy:initAfter(self.event.enemy) | ||
67 | end | 66 | end |
68 | enemy:triggerPassive(Passive.BORN_ONCE) | 67 | enemy:triggerPassive(Passive.BORN_ONCE) |
69 | 68 | ||
@@ -146,7 +145,6 @@ function Block:randomEvent() | @@ -146,7 +145,6 @@ function Block:randomEvent() | ||
146 | build:unlock() | 145 | build:unlock() |
147 | else | 146 | else |
148 | build = adv.battle:addEnemy(room, self, map.mapIdx) | 147 | build = adv.battle:addEnemy(room, self, map.mapIdx) |
149 | - build:initAfter(self.event.build) | ||
150 | end | 148 | end |
151 | build:triggerPassive(Passive.BORN_ONCE) | 149 | build:triggerPassive(Passive.BORN_ONCE) |
152 | end | 150 | end |
src/adv/AdvBuff.lua
@@ -570,7 +570,7 @@ end | @@ -570,7 +570,7 @@ end | ||
570 | 570 | ||
571 | function Buff:afterLayer() | 571 | function Buff:afterLayer() |
572 | -- 持续一层 | 572 | -- 持续一层 |
573 | - if self.buffData.round == 0 then | 573 | + if self.buffData.round == 0 or self.buffData.mapLock == 1 then |
574 | self.isDel = true | 574 | self.isDel = true |
575 | end | 575 | end |
576 | end | 576 | end |
src/adv/AdvMap.lua
@@ -49,6 +49,11 @@ function Map:initBattleAfter() | @@ -49,6 +49,11 @@ function Map:initBattleAfter() | ||
49 | end | 49 | end |
50 | end | 50 | end |
51 | 51 | ||
52 | + | ||
53 | +function Map:getMapInfoCsv() | ||
54 | + return csvdb["mapCsv"][self.mapId] | ||
55 | +end | ||
56 | + | ||
52 | function Map:getDB() | 57 | function Map:getDB() |
53 | local map = {} | 58 | local map = {} |
54 | map.mapId = self.mapId | 59 | map.mapId = self.mapId |
@@ -124,7 +129,6 @@ function Map:addNewMonsterRand(monsterId, where) | @@ -124,7 +129,6 @@ function Map:addNewMonsterRand(monsterId, where) | ||
124 | block:updateEvent(event) | 129 | block:updateEvent(event) |
125 | 130 | ||
126 | local enemy = self.adv.battle:addEnemy(room, block) | 131 | local enemy = self.adv.battle:addEnemy(room, block) |
127 | - enemy:initAfter(event.enemy) | ||
128 | enemy:triggerPassive(Passive.BORN_ONCE) | 132 | enemy:triggerPassive(Passive.BORN_ONCE) |
129 | 133 | ||
130 | return room, block | 134 | return room, block |
src/adv/AdvPassive.lua
@@ -316,7 +316,7 @@ function Passive:effect(triggerPms) | @@ -316,7 +316,7 @@ function Passive:effect(triggerPms) | ||
316 | self.round = self.passiveData.round | 316 | self.round = self.passiveData.round |
317 | end | 317 | end |
318 | 318 | ||
319 | - if self.count <= 0 and self.passiveData.refresh == 1 then -- 次数 <= 0 并且一次冒险内不刷新,被动可以直接移除 | 319 | + if self.count <= 0 then -- 次数 <= 0 并且一次冒险内不刷新,被动可以直接移除 |
320 | self.isDel = true | 320 | self.isDel = true |
321 | end | 321 | end |
322 | end | 322 | end |
@@ -334,6 +334,12 @@ function Passive:afterRound() | @@ -334,6 +334,12 @@ function Passive:afterRound() | ||
334 | end | 334 | end |
335 | end | 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 | function Passive:canTrigger( ) | 344 | function Passive:canTrigger( ) |
339 | return self.count > 0 and self.delay <= 0 | 345 | return self.count > 0 and self.delay <= 0 |
src/adv/AdvPlayer.lua
@@ -85,27 +85,26 @@ function BaseObject:clear() | @@ -85,27 +85,26 @@ function BaseObject:clear() | ||
85 | self.passives = {} | 85 | self.passives = {} |
86 | end | 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 | function BaseObject:addPassive(params) | 88 | function BaseObject:addPassive(params) |
101 | local skillId = params.id | 89 | local skillId = params.id |
102 | local skillData = csvdb["adv_map_passiveCsv"][skillId] | 90 | local skillData = csvdb["adv_map_passiveCsv"][skillId] |
103 | if not skillData then return end | 91 | if not skillData then return end |
104 | local level = params.level or 1 | 92 | local level = params.level or 1 |
105 | if not skillData[level] then return end | 93 | if not skillData[level] then return end |
94 | + | ||
95 | + if self:getPassiveById(skillId) then return end -- 被动技不能重复 | ||
96 | + | ||
106 | table.insert(self.passives, Passive.new(self, { id = skillId, level = level })) | 97 | table.insert(self.passives, Passive.new(self, { id = skillId, level = level })) |
107 | end | 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 | function BaseObject:getPassiveIdx(passive) | 108 | function BaseObject:getPassiveIdx(passive) |
110 | for idx, passive_ in ipairs(self.passives) do | 109 | for idx, passive_ in ipairs(self.passives) do |
111 | if passive_ == passive then | 110 | if passive_ == passive then |
@@ -535,6 +534,10 @@ function Enemy:isEnemy() | @@ -535,6 +534,10 @@ function Enemy:isEnemy() | ||
535 | return true | 534 | return true |
536 | end | 535 | end |
537 | 536 | ||
537 | +function Enemy:kill() | ||
538 | + self:hurt(self.hp, self.battle.player, {hurtType = 5}) | ||
539 | +end | ||
540 | + | ||
538 | local Player = class("Player", BaseObject) | 541 | local Player = class("Player", BaseObject) |
539 | function Player:ctor(battle, data) | 542 | function Player:ctor(battle, data) |
540 | Player.super.ctor(self, battle) | 543 | Player.super.ctor(self, battle) |
@@ -648,11 +651,18 @@ function Player:effectBattleBuff() | @@ -648,11 +651,18 @@ function Player:effectBattleBuff() | ||
648 | end | 651 | end |
649 | 652 | ||
650 | function Player:afterLayer() | 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 | for _, buff in ipairs(self.buffs) do | 659 | for _, buff in ipairs(self.buffs) do |
652 | if not buff.isDel then | 660 | if not buff.isDel then |
653 | buff:afterLayer() | 661 | buff:afterLayer() |
654 | end | 662 | end |
655 | end | 663 | end |
664 | + | ||
665 | + self:clearRound() | ||
656 | end | 666 | end |
657 | 667 | ||
658 | function Player:addBuff(buffId, releaser) | 668 | function Player:addBuff(buffId, releaser) |