Skip to content

Commit

Permalink
使杨桃向后发射的子弹可以忽略二类防具
Browse files Browse the repository at this point in the history
  • Loading branch information
wszqkzqk committed Jun 4, 2022
1 parent e2d2110 commit 1e86ad1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
12 changes: 8 additions & 4 deletions source/component/plant.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def draw(self, surface):

# 豌豆及孢子类普通子弹
class Bullet(pg.sprite.Sprite):
def __init__(self, x, start_y, dest_y, name, damage, effect=None, passedTorchWood=None):
def __init__(self, x, start_y, dest_y, name, damage, effect=None, passedTorchWood=None, damageType=c.ZOMBIE_DEAFULT_DAMAGE):
pg.sprite.Sprite.__init__(self)

self.name = name
Expand All @@ -55,6 +55,7 @@ def __init__(self, x, start_y, dest_y, name, damage, effect=None, passedTorchWoo
self.y_vel = 15 if (dest_y > start_y) else -15
self.x_vel = 10
self.damage = damage
self.damageType = damageType
self.effect = effect
self.state = c.FLY
self.current_time = 0
Expand Down Expand Up @@ -182,8 +183,8 @@ def loadFrames(self, frames, name):

# 杨桃的子弹
class StarBullet(Bullet):
def __init__(self, x, start_y, damage, direction, level): # direction指星星飞行方向
Bullet.__init__(self, x, start_y, start_y, c.BULLET_STAR, damage)
def __init__(self, x, start_y, damage, direction, level, damageType = c.ZOMBIE_DEAFULT_DAMAGE): # direction指星星飞行方向
Bullet.__init__(self, x, start_y, start_y, c.BULLET_STAR, damage, damageType = damageType)

self.level = level
_, self.map_y = self.level.map.getMapIndex(self.rect.x, self.rect.centery)
Expand Down Expand Up @@ -1338,7 +1339,9 @@ def attacking(self):
if self.shoot_timer == 0:
self.shoot_timer = self.current_time - 700
elif (self.current_time - self.shoot_timer) >= 1400:
self.bullet_group.add(StarBullet(self.rect.left - 10, self.rect.y + 15, c.BULLET_DAMAGE_NORMAL, c.STAR_BACKWARD, self.level))
# 向后打的杨桃子弹无视铁门与报纸防具
self.bullet_group.add(StarBullet(self.rect.left - 10, self.rect.y + 15, c.BULLET_DAMAGE_NORMAL, c.STAR_BACKWARD, self.level, damageType = c.ZOMBIE_COMMON_DAMAGE))
# 其他方向的杨桃子弹伤害效果与豌豆等同
self.bullet_group.add(StarBullet(self.rect.centerx - 20, self.rect.bottom - self.rect.h - 15, c.BULLET_DAMAGE_NORMAL, c.STAR_UPWARD, self.level))
self.bullet_group.add(StarBullet(self.rect.centerx - 20, self.rect.bottom - 5, c.BULLET_DAMAGE_NORMAL, c.STAR_DOWNWARD, self.level))
self.bullet_group.add(StarBullet(self.rect.right - 5, self.rect.bottom - 20, c.BULLET_DAMAGE_NORMAL, c.STAR_FORWARD_DOWN, self.level))
Expand Down Expand Up @@ -1589,6 +1592,7 @@ def animation(self):
else:
self.image.set_alpha(255)


# 用于描述毁灭菇的坑
class Hole(Plant):
def __init__(self, x, y, plotType):
Expand Down
2 changes: 1 addition & 1 deletion source/state/level.py
Original file line number Diff line number Diff line change
Expand Up @@ -1015,7 +1015,7 @@ def checkBulletCollisions(self):
continue
if collided_func(zombie, bullet):
if zombie.state != c.DIE:
zombie.setDamage(bullet.damage, effect=bullet.effect, damageType=c.ZOMBIE_DEAFULT_DAMAGE)
zombie.setDamage(bullet.damage, effect=bullet.effect, damageType=bullet.damageType)
bullet.setExplode()
# 火球有溅射伤害
if bullet.name == c.BULLET_FIREBALL:
Expand Down

0 comments on commit 1e86ad1

Please sign in to comment.