统一变量名,更改大嘴花攻击实现本质

This commit is contained in:
星外之神 2022-05-15 15:46:14 +08:00
parent c87f5b3dc8
commit f8be222caf
2 changed files with 5 additions and 19 deletions

View File

@ -636,7 +636,7 @@ class Chomper(Plant):
if self.frame_index == (self.frame_num - 3):
# 播放吞的音效
pg.mixer.Sound(os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(__file__))) ,"resources", "sound", "bigchomp.ogg")).play()
self.zombie_group.remove(self.attack_zombie)
self.attack_zombie.kill()
if (self.frame_index + 1) == self.frame_num:
self.setDigest()
@ -645,7 +645,6 @@ class Chomper(Plant):
self.digest_timer = self.current_time
elif (self.current_time - self.digest_timer) > self.digest_interval:
self.digest_timer = 0
self.attack_zombie.kill()
self.setIdle()
@ -753,7 +752,7 @@ class Squash(Plant):
Plant.__init__(self, x, y, c.SQUASH, c.PLANT_HEALTH, None)
self.orig_pos = (x, y)
self.aim_timer = 0
self.squashing = False
self.start_boom = False # 和灰烬等植物统一变量名,在这里表示倭瓜是否跳起
self.mapPlantsSet = mapPlantsSet
def loadImages(self, name, scale):
@ -792,7 +791,7 @@ class Squash(Plant):
self.health = c.INF
def attacking(self):
if self.squashing:
if self.start_boom:
if (self.frame_index + 1) == self.frame_num:
for zombie in self.zombie_group:
if self.canAttack(zombie):
@ -810,7 +809,7 @@ class Squash(Plant):
elif (self.current_time - self.aim_timer) > 1000:
self.changeFrames(self.attack_frames)
self.rect.centerx = self.attack_zombie.rect.centerx
self.squashing = True
self.start_boom = True
self.animate_interval = 300
def getPosition(self):

View File

@ -1009,10 +1009,6 @@ class Level(tool.State):
for bullet in self.bullet_groups[i]:
if bullet.name == c.FUME:
continue
# elif bullet.name == c.BULLET_STAR:
# collided_func = pg.sprite.collide_circle_ratio(1)
# else:
# collided_func = pg.sprite.collide_circle_ratio(0.7)
collided_func = pg.sprite.collide_mask
if bullet.state == c.FLY:
# 利用循环而非内建精灵组碰撞判断函数,处理更加灵活,可排除已死亡僵尸
@ -1030,11 +1026,6 @@ class Level(tool.State):
def checkZombieCollisions(self):
# if self.bar_type == c.CHOSSEBAR_BOWLING:
# ratio = 0.6
# else:
# ratio = 0.5
# collided_func = pg.sprite.collide_circle_ratio(ratio)
for i in range(self.map_y_len):
hypo_zombies = []
for zombie in self.zombie_groups[i]:
@ -1087,11 +1078,7 @@ class Level(tool.State):
attackableCommonPlants.append(plant)
# 在某些状态下忽略啃食碰撞但某些状况下不能忽略的情形
elif plant.name in c.SKIP_ZOMBIE_COLLISION_CHECK_WHEN_WORKING:
if plant.name == c.SQUASH:
if not plant.squashing:
attackableCommonPlants.append(plant)
else:
if not plant.start_boom:
if not plant.start_boom:
attackableCommonPlants.append(plant)
else:
if attackableCommonPlants: