修复坚果保龄球闪退bug
This commit is contained in:
parent
8cd22a1140
commit
7240c61765
Binary file not shown.
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 18 KiB |
@ -1818,6 +1818,7 @@ class PumpkinHead(Plant):
|
||||
self.changeFrames(self.cracked2_frames)
|
||||
self.cracked2 = True
|
||||
|
||||
|
||||
class GiantWallNut(Plant):
|
||||
def __init__(self, x, y):
|
||||
Plant.__init__(self, x, y, c.GIANTWALLNUT, 1, None)
|
||||
@ -1826,7 +1827,7 @@ class GiantWallNut(Plant):
|
||||
self.animate_interval = 200
|
||||
self.move_timer = 0
|
||||
self.move_interval = 70
|
||||
self.vel_x = random.randint(12, 15)
|
||||
self.vel_x = random.randint(15, 18)
|
||||
|
||||
def idling(self):
|
||||
if self.move_timer == 0:
|
||||
|
||||
@ -1082,13 +1082,14 @@ class Level(tool.State):
|
||||
# 默认为最右侧的一个植物
|
||||
target_plant = max(attackable_common_plants, key=lambda i: i.rect.x)
|
||||
map_x, map_y = self.map.getMapIndex(target_plant.rect.centerx, target_plant.rect.centery)
|
||||
if c.PUMPKINHEAD in self.map.map[map_y][map_x][c.MAP_PLANT]:
|
||||
for actual_target_plant in self.plant_groups[i]:
|
||||
# 检测同一格的其他植物
|
||||
if self.map.getMapIndex(actual_target_plant.rect.centerx, actual_target_plant.rect.bottom) == (map_x, map_y):
|
||||
if actual_target_plant.name == c.PUMPKINHEAD:
|
||||
target_plant = actual_target_plant
|
||||
break
|
||||
if not (map_x >= self.map.width or map_y >= self.map.height):
|
||||
if c.PUMPKINHEAD in self.map.map[map_y][map_x][c.MAP_PLANT]:
|
||||
for actual_target_plant in self.plant_groups[i]:
|
||||
# 检测同一格的其他植物
|
||||
if self.map.getMapIndex(actual_target_plant.rect.centerx, actual_target_plant.rect.bottom) == (map_x, map_y):
|
||||
if actual_target_plant.name == c.PUMPKINHEAD:
|
||||
target_plant = actual_target_plant
|
||||
break
|
||||
elif attackable_backup_plants:
|
||||
target_plant = max(attackable_backup_plants, key=lambda i: i.rect.x)
|
||||
map_x, map_y = self.map.getMapIndex(target_plant.rect.centerx, target_plant.rect.centery)
|
||||
@ -1113,6 +1114,7 @@ class Level(tool.State):
|
||||
if zombie.name in {c.POLE_VAULTING_ZOMBIE} and (not zombie.jumped):
|
||||
if target_plant.name == c.GIANTWALLNUT:
|
||||
zombie.health = 0
|
||||
c.SOUND_BOWLING_IMPACT.play()
|
||||
elif not zombie.jumping:
|
||||
zombie.jump_map_x, zombie.jump_map_y = min(c.GRID_X_LEN - 1, zombie.prey_map_x), min(self.map_y_len - 1, zombie.prey_map_y)
|
||||
jump_x = target_plant.rect.x - c.GRID_X_SIZE * 0.6
|
||||
@ -1142,6 +1144,7 @@ class Level(tool.State):
|
||||
target_plant.setAttack()
|
||||
elif target_plant.name == c.GIANTWALLNUT:
|
||||
zombie.health = 0
|
||||
c.SOUND_BOWLING_IMPACT.play()
|
||||
elif zombie.target_y_change:
|
||||
# 大蒜作用正在生效的僵尸不进行传递
|
||||
continue
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user