diff --git a/resources/graphics/Plants/WallNut/GiantWallNut/GiantWallNut_0.png b/resources/graphics/Plants/WallNut/GiantWallNut/GiantWallNut_0.png index 8788347..23e13de 100644 Binary files a/resources/graphics/Plants/WallNut/GiantWallNut/GiantWallNut_0.png and b/resources/graphics/Plants/WallNut/GiantWallNut/GiantWallNut_0.png differ diff --git a/source/component/plant.py b/source/component/plant.py index e6e8dd0..db01a8f 100755 --- a/source/component/plant.py +++ b/source/component/plant.py @@ -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: diff --git a/source/state/level.py b/source/state/level.py index 9914f52..83d4997 100644 --- a/source/state/level.py +++ b/source/state/level.py @@ -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