From 66e2b9e47e0dbb4ad1916452f4d7f01db581eb25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=98=9F=E5=A4=96=E4=B9=8B=E7=A5=9E?= Date: Tue, 12 Apr 2022 22:29:11 +0800 Subject: [PATCH] =?UTF-8?q?=E9=93=B2=E5=AD=90=E7=A7=BB=E9=99=A4=E6=A4=8D?= =?UTF-8?q?=E7=89=A9=E4=B8=8D=E8=A7=A6=E5=8F=91=E6=A4=8D=E7=89=A9=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/state/level.py | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/source/state/level.py b/source/state/level.py index 886cda3..c762dcf 100644 --- a/source/state/level.py +++ b/source/state/level.py @@ -279,7 +279,7 @@ class Level(tool.State): for i in self.plant_groups[map_y]: if (x >= i.rect.x and x <= i.rect.right and y >= i.rect.y and y <= i.rect.bottom): - self.killPlant(i) + self.killPlant(i, shovel=True) # 使用后默认铲子复原 self.drag_shovel = not self.drag_shovel self.removeMouseImagePlus() @@ -660,24 +660,28 @@ class Level(tool.State): if zombie.rect.centerx < c.SCREEN_WIDTH: zombie.setFreeze(plant.trap_frames[0]) - def killPlant(self, plant): + def killPlant(self, plant, shovel=False): x, y = plant.getPosition() map_x, map_y = self.map.getMapIndex(x, y) if self.bar_type != c.CHOSSEBAR_BOWLING: + # 更改地图类型、添加南瓜头、睡莲、花盆后可能也需要改这里 self.map.setMapGridType(map_x, map_y, c.MAP_EMPTY) - if (plant.name == c.CHERRYBOMB or plant.name == c.JALAPENO or - (plant.name == c.POTATOMINE and not plant.is_init) or - plant.name == c.REDWALLNUTBOWLING): - self.boomZombies(plant.rect.centerx, map_y, plant.explode_y_range, - plant.explode_x_range) - elif plant.name == c.ICESHROOM and plant.state != c.SLEEP: - self.freezeZombies(plant) - elif plant.name == c.HYPNOSHROOM and plant.state != c.SLEEP: - zombie = plant.kill_zombie - zombie.setHypno() - _, map_y = self.map.getMapIndex(zombie.rect.centerx, zombie.rect.bottom) - self.zombie_groups[map_y].remove(zombie) - self.hypno_zombie_groups[map_y].add(zombie) + # 用铲子铲不用触发植物功能 + if not shovel: + if (plant.name == c.CHERRYBOMB or plant.name == c.JALAPENO or + plant.name == c.REDWALLNUTBOWLING): + self.boomZombies(plant.rect.centerx, map_y, plant.explode_y_range, + plant.explode_x_range) + elif plant.name == c.ICESHROOM and plant.state != c.SLEEP: + self.freezeZombies(plant) + elif plant.name == c.HYPNOSHROOM and plant.state != c.SLEEP: + zombie = plant.kill_zombie + zombie.setHypno() + _, map_y = self.map.getMapIndex(zombie.rect.centerx, zombie.rect.bottom) + self.zombie_groups[map_y].remove(zombie) + self.hypno_zombie_groups[map_y].add(zombie) + elif (plant.name == c.POTATOMINE and not plant.is_init): + zombie.setDamage(1800) # 避免僵尸在用铲子移除植物后还在原位啃食 plant.health = 0 plant.kill()