diff --git a/resources/sound/squashing.ogg b/resources/sound/squashing.ogg new file mode 100644 index 0000000..456950c Binary files /dev/null and b/resources/sound/squashing.ogg differ diff --git a/source/component/plant.py b/source/component/plant.py index b066e6d..f7c310a 100755 --- a/source/component/plant.py +++ b/source/component/plant.py @@ -801,6 +801,8 @@ class Squash(Plant): self.health = 0 # 避免僵尸在原位啃食 self.mapPlantsSet.remove(c.SQUASH) self.kill() + # 播放碾压音效 + pg.mixer.Sound(os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(__file__))) ,"resources", "sound", "squashing.ogg")).play() elif self.aim_timer == 0: # 锁定目标时播放音效 pg.mixer.Sound(os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(__file__))) ,"resources", "sound", "squashHmm.ogg")).play() diff --git a/source/state/level.py b/source/state/level.py index f109d70..e88f727 100644 --- a/source/state/level.py +++ b/source/state/level.py @@ -1084,6 +1084,10 @@ class Level(tool.State): elif plant.name in {c.LILYPAD, "花盆(未实现)"}: attackableBackupPlant.append(plant) # 注意要剔除掉两个“假植物”,以及不能被啃的地刺 + elif plant.name == c.SQUASH: + # 跳起后不得被啃食 + if not plant.squashing: + attackableCommonPlants.append(plant) elif plant.name not in {c.HOLE, c.ICE_FROZEN_PLOT, c.GRAVE, c.SPIKEWEED}: attackableCommonPlants.append(plant) else: @@ -1280,7 +1284,7 @@ class Level(tool.State): for zombie in self.zombie_groups[i]: # 双判断:发生碰撞或在攻击范围内 if ((pg.sprite.collide_mask(zombie, targetPlant)) or - (abs(zombie.rect.centerx - x) <= targetPlant.explode_x_range)): + (abs(zombie.rect.centerx - targetPlant.rect.centerx) <= targetPlant.explode_x_range)): zombie.setDamage(1800, damageType=c.ZOMBIE_RANGE_DAMAGE) targetPlant.boomed = True elif targetPlant.name == c.SQUASH: