铲子移除植物不触发植物功能
This commit is contained in:
parent
7bacfef07e
commit
66e2b9e47e
@ -279,7 +279,7 @@ class Level(tool.State):
|
|||||||
for i in self.plant_groups[map_y]:
|
for i in self.plant_groups[map_y]:
|
||||||
if (x >= i.rect.x and x <= i.rect.right and
|
if (x >= i.rect.x and x <= i.rect.right and
|
||||||
y >= i.rect.y and y <= i.rect.bottom):
|
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.drag_shovel = not self.drag_shovel
|
||||||
self.removeMouseImagePlus()
|
self.removeMouseImagePlus()
|
||||||
@ -660,13 +660,15 @@ class Level(tool.State):
|
|||||||
if zombie.rect.centerx < c.SCREEN_WIDTH:
|
if zombie.rect.centerx < c.SCREEN_WIDTH:
|
||||||
zombie.setFreeze(plant.trap_frames[0])
|
zombie.setFreeze(plant.trap_frames[0])
|
||||||
|
|
||||||
def killPlant(self, plant):
|
def killPlant(self, plant, shovel=False):
|
||||||
x, y = plant.getPosition()
|
x, y = plant.getPosition()
|
||||||
map_x, map_y = self.map.getMapIndex(x, y)
|
map_x, map_y = self.map.getMapIndex(x, y)
|
||||||
if self.bar_type != c.CHOSSEBAR_BOWLING:
|
if self.bar_type != c.CHOSSEBAR_BOWLING:
|
||||||
|
# 更改地图类型、添加南瓜头、睡莲、花盆后可能也需要改这里
|
||||||
self.map.setMapGridType(map_x, map_y, c.MAP_EMPTY)
|
self.map.setMapGridType(map_x, map_y, c.MAP_EMPTY)
|
||||||
|
# 用铲子铲不用触发植物功能
|
||||||
|
if not shovel:
|
||||||
if (plant.name == c.CHERRYBOMB or plant.name == c.JALAPENO or
|
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):
|
plant.name == c.REDWALLNUTBOWLING):
|
||||||
self.boomZombies(plant.rect.centerx, map_y, plant.explode_y_range,
|
self.boomZombies(plant.rect.centerx, map_y, plant.explode_y_range,
|
||||||
plant.explode_x_range)
|
plant.explode_x_range)
|
||||||
@ -678,6 +680,8 @@ class Level(tool.State):
|
|||||||
_, map_y = self.map.getMapIndex(zombie.rect.centerx, zombie.rect.bottom)
|
_, map_y = self.map.getMapIndex(zombie.rect.centerx, zombie.rect.bottom)
|
||||||
self.zombie_groups[map_y].remove(zombie)
|
self.zombie_groups[map_y].remove(zombie)
|
||||||
self.hypno_zombie_groups[map_y].add(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.health = 0
|
||||||
plant.kill()
|
plant.kill()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user