修复部分音效的bug
This commit is contained in:
parent
df3e649fd5
commit
9ea76dce22
@ -500,10 +500,10 @@ class CherryBomb(Plant):
|
||||
if self.start_boom:
|
||||
if self.bomb_timer == 0:
|
||||
self.bomb_timer = self.current_time
|
||||
elif (self.current_time - self.bomb_timer) > 500:
|
||||
self.health = 0
|
||||
# 播放爆炸音效
|
||||
pg.mixer.Sound(os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(__file__))) ,"resources", "sound", "bomb.ogg")).play()
|
||||
elif (self.current_time - self.bomb_timer) > 500:
|
||||
self.health = 0
|
||||
else:
|
||||
if (self.current_time - self.animate_timer) > 100:
|
||||
self.frame_index += 1
|
||||
@ -798,11 +798,12 @@ class Jalapeno(Plant):
|
||||
def animation(self):
|
||||
if self.start_explode:
|
||||
if (self.current_time - self.animate_timer) > 100:
|
||||
if self.frame_index == 1:
|
||||
# 播放爆炸音效
|
||||
pg.mixer.Sound(os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(__file__))) ,"resources", "sound", "bomb.ogg")).play()
|
||||
self.frame_index += 1
|
||||
if self.frame_index >= self.frame_num:
|
||||
self.health = 0
|
||||
# 播放爆炸音效
|
||||
pg.mixer.Sound(os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(__file__))) ,"resources", "sound", "bomb.ogg")).play()
|
||||
return
|
||||
self.animate_timer = self.current_time
|
||||
else:
|
||||
@ -1119,10 +1120,10 @@ class RedWallNutBowling(Plant):
|
||||
if self.explode_timer == 0:
|
||||
self.explode_timer = self.current_time
|
||||
self.changeFrames(self.explode_frames)
|
||||
elif (self.current_time - self.explode_timer) > 500:
|
||||
self.health = 0
|
||||
# 播放爆炸音效
|
||||
pg.mixer.Sound(os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(__file__))) ,"resources", "sound", "bomb.ogg")).play()
|
||||
elif (self.current_time - self.explode_timer) > 500:
|
||||
self.health = 0
|
||||
|
||||
def animation(self):
|
||||
if (self.current_time - self.animate_timer) > self.animate_interval:
|
||||
|
||||
@ -206,6 +206,9 @@ class Zombie(pg.sprite.Sprite):
|
||||
self.prey.setDamage(self.damage, self)
|
||||
else:
|
||||
self.prey.setDamage(self.damage)
|
||||
|
||||
# 播放啃咬音效
|
||||
pg.mixer.Sound(os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(__file__))) ,"resources", "sound", "zombieAttack.ogg")).play()
|
||||
self.attack_timer = self.current_time
|
||||
|
||||
if self.prey.health <= 0:
|
||||
@ -280,7 +283,8 @@ class Zombie(pg.sprite.Sprite):
|
||||
|
||||
def setIceSlow(self):
|
||||
# 在转入冰冻减速状态时播放冰冻音效
|
||||
pg.mixer.Sound(os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(__file__))) ,"resources", "sound", "freeze.ogg")).play()
|
||||
if self.ice_slow_ratio == 1:
|
||||
pg.mixer.Sound(os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(__file__))) ,"resources", "sound", "freeze.ogg")).play()
|
||||
|
||||
# when get a ice bullet damage, slow the attack or walk speed of the zombie
|
||||
self.ice_slow_timer = self.current_time
|
||||
@ -420,9 +424,6 @@ class Zombie(pg.sprite.Sprite):
|
||||
else:
|
||||
self.changeFrames(self.attack_frames)
|
||||
|
||||
# 播放啃咬音效
|
||||
pg.mixer.Sound(os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(__file__))) ,"resources", "sound", "zombieAttack.ogg")).play()
|
||||
|
||||
def setDie(self):
|
||||
self.state = c.DIE
|
||||
self.animate_interval = self.die_animate_interval
|
||||
|
||||
@ -176,12 +176,14 @@ class Level(tool.State):
|
||||
self.waveTime = current_time
|
||||
self.waveZombies = self.waves[self.waveNum - 1]
|
||||
self.numZombie = len(self.waveZombies)
|
||||
pg.mixer.Sound(os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(__file__))) ,"resources", "sound", "zombieComing.ogg")).play()
|
||||
else:
|
||||
if (current_time - self.waveTime >= 6000):
|
||||
self.waveNum += 1
|
||||
self.waveTime = current_time
|
||||
self.waveZombies = self.waves[self.waveNum - 1]
|
||||
self.numZombie = len(self.waveZombies)
|
||||
pg.mixer.Sound(os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(__file__))) ,"resources", "sound", "zombieComing.ogg")).play()
|
||||
return
|
||||
if (self.waveNum % 10 != 9):
|
||||
if ((current_time - self.waveTime >= 25000 + randint(0, 6000)) or (self.bar_type != c.CHOOSEBAR_STATIC and current_time - self.waveTime >= 12500 + randint(0, 3000))):
|
||||
@ -189,10 +191,8 @@ class Level(tool.State):
|
||||
self.waveTime = current_time
|
||||
self.waveZombies = self.waves[self.waveNum - 1]
|
||||
self.numZombie = len(self.waveZombies)
|
||||
pg.mixer.Sound(os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(__file__))) ,"resources", "sound", "zombieVoice.ogg")).play()
|
||||
# 第一波刚刚刷出来的时候播放音效
|
||||
if self.waveNum == 1:
|
||||
pg.mixer.Sound(os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(__file__))) ,"resources", "sound", "zombieComing.ogg")).play()
|
||||
return
|
||||
else:
|
||||
if ((current_time - self.waveTime >= 45000) or (self.bar_type != c.CHOOSEBAR_STATIC and current_time - self.waveTime >= 25000)):
|
||||
self.waveNum += 1
|
||||
@ -791,7 +791,8 @@ class Level(tool.State):
|
||||
mushroomSleep = False
|
||||
self.plant_groups[map_y].add(new_plant)
|
||||
# 种植植物后应当刷新僵尸的攻击对象
|
||||
self.refreshZombieAttack = True
|
||||
# 这里用植物名称代替布尔值,保存更多信息
|
||||
self.refreshZombieAttack = new_plant.name
|
||||
if self.bar_type == c.CHOOSEBAR_STATIC:
|
||||
self.menubar.decreaseSunValue(self.select_plant.sun_cost)
|
||||
self.menubar.setCardFrozenTime(self.plant_name)
|
||||
@ -894,7 +895,9 @@ class Level(tool.State):
|
||||
hypo_zombies = []
|
||||
for zombie in self.zombie_groups[i]:
|
||||
if zombie.state != c.WALK:
|
||||
if not self.refreshZombieAttack:
|
||||
if zombie.state != c.ATTACK:
|
||||
continue
|
||||
if (((zombie.prey.name not in {c.LILYPAD, "花盆(未实现)"}) and (self.refreshZombieAttack != "南瓜头(未实现)")) or (not self.refreshZombieAttack)):
|
||||
continue
|
||||
if zombie.canSwim and (not zombie.swimming):
|
||||
continue
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user