优化:寒冰射手无法减速持有二类防具的僵尸
新增:坚果保龄球单独的攻击模式 修改:读报僵尸、旗帜僵尸生命值、移动速度恢复原版设定
This commit is contained in:
parent
05d34c3a7b
commit
11e8eb8e6e
@ -88,14 +88,15 @@ class Zombie(pg.sprite.Sprite):
|
||||
self.changeFrames(self.walk_frames)
|
||||
self.helmetType2 = False
|
||||
if self.name == c.NEWSPAPER_ZOMBIE:
|
||||
self.speed = 2
|
||||
self.speed = 2.5
|
||||
self.animate_interval = 300 # 因为加速了时间间隔要除以倍率,所以减小动画帧率
|
||||
|
||||
if (self.current_time - self.walk_timer) > (c.ZOMBIE_WALK_INTERVAL * self.getTimeRatio()):
|
||||
self.walk_timer = self.current_time
|
||||
if self.is_hypno:
|
||||
self.rect.x += self.speed
|
||||
self.rect.x += 1
|
||||
else:
|
||||
self.rect.x -= self.speed
|
||||
self.rect.x -= 1
|
||||
|
||||
def attacking(self):
|
||||
self.checkToDie(self.losthead_attack_frames)
|
||||
@ -106,7 +107,7 @@ class Zombie(pg.sprite.Sprite):
|
||||
if self.helmetType2Health <= 0 and self.helmetType2:
|
||||
self.changeFrames(self.attack_frames)
|
||||
self.helmetType2 = False
|
||||
if (self.current_time - self.attack_timer) > (c.ATTACK_INTERVAL * self.getTimeRatio()):
|
||||
if (self.current_time - self.attack_timer) > (c.ATTACK_INTERVAL * self.getAttackTimeRatio()):
|
||||
if self.prey.health > 0:
|
||||
if self.prey_is_plant:
|
||||
self.prey.setDamage(self.damage, self)
|
||||
@ -174,10 +175,13 @@ class Zombie(pg.sprite.Sprite):
|
||||
self.image.set_alpha(192)
|
||||
|
||||
def getTimeRatio(self):
|
||||
return self.ice_slow_ratio
|
||||
return (self.ice_slow_ratio / self.speed) # 目前的机制为:冰冻减速状态与自身速度共同决定行走的时间间隔
|
||||
|
||||
def getAttackTimeRatio(self):
|
||||
return self.ice_slow_ratio # 攻击速度只取决于冰冻状态
|
||||
|
||||
def setIceSlow(self):
|
||||
'''when get a ice bullet damage, slow the attack or walk speed of the zombie'''
|
||||
# when get a ice bullet damage, slow the attack or walk speed of the zombie
|
||||
self.ice_slow_timer = self.current_time
|
||||
self.ice_slow_ratio = 2
|
||||
|
||||
@ -187,6 +191,14 @@ class Zombie(pg.sprite.Sprite):
|
||||
self.ice_slow_ratio = 1
|
||||
|
||||
def setDamage(self, damage, ice=False, damageType=c.ZOMBIE_COMMON_DAMAGE):
|
||||
# 冰冻减速效果
|
||||
if ice:
|
||||
if damageType == c.ZOMBIE_DEAFULT_DAMAGE: # 寒冰射手不能穿透二类防具进行减速
|
||||
if not self.helmetType2:
|
||||
self.setIceSlow()
|
||||
else:
|
||||
self.setIceSlow()
|
||||
|
||||
if damageType == c.ZOMBIE_DEAFULT_DAMAGE: # 不穿透二类防具的攻击
|
||||
# 从第二类防具开始逐级传递
|
||||
if self.helmetType2:
|
||||
@ -248,15 +260,25 @@ class Zombie(pg.sprite.Sprite):
|
||||
self.health -= damage
|
||||
elif damageType == c.ZOMBIE_ASH_DAMAGE:
|
||||
self.health -= damage # 无视任何防具
|
||||
elif damageType == c.ZOMBIE_WALLNUT_BOWLING_DANMAGE:
|
||||
# 逻辑:对防具的多余伤害不传递
|
||||
# 以后增设铁门后可能需要设置侧面冲撞特殊性
|
||||
if self.helmetType2:
|
||||
self.helmetType2Health -= damage
|
||||
if self.helmetType2Health <= 0:
|
||||
self.helmetType2 = False
|
||||
elif self.helmet: # 不存在二类防具,但是存在一类防具
|
||||
self.helmetHealth -= damage
|
||||
if self.helmetHealth <= 0:
|
||||
self.helmet = False
|
||||
else: # 没有防具
|
||||
self.health -= damage
|
||||
else:
|
||||
print('警告:植物攻击类型错误,现在默认进行类豌豆射手型攻击')
|
||||
setDamage(damage, ice=ice, damageType=c.ZOMBIE_DEAFULT_DAMAGE)
|
||||
|
||||
# 记录攻击时间
|
||||
self.hit_timer = self.current_time
|
||||
# 冰冻减速效果
|
||||
if ice:
|
||||
self.setIceSlow()
|
||||
|
||||
def setWalk(self):
|
||||
self.state = c.WALK
|
||||
@ -431,7 +453,8 @@ class BucketHeadZombie(Zombie):
|
||||
|
||||
class FlagZombie(Zombie):
|
||||
def __init__(self, x, y, head_group):
|
||||
Zombie.__init__(self, x, y, c.FLAG_ZOMBIE, head_group, bodyHealth=c.FLAG_HEALTH + c.NORMAL_HEALTH)
|
||||
Zombie.__init__(self, x, y, c.FLAG_ZOMBIE, head_group)
|
||||
self.speed = 1.25
|
||||
|
||||
def loadImages(self):
|
||||
self.walk_frames = []
|
||||
|
||||
@ -175,17 +175,17 @@ BOOMDIE = 'BoomDie'
|
||||
ZOMBIE_DEAFULT_DAMAGE = 'helmet2First'
|
||||
ZOMBIE_HELMET_2_FIRST = 'helmet2First' # 优先攻击二类防具
|
||||
ZOMBIE_COMMON_DAMAGE = 'commonDamage' # 优先攻击僵尸与一类防具的整体
|
||||
ZOMBIE_RANGE_DAMAGE = 'rangeDAMAGE' # 范围攻击,同时伤害二类防具与(僵尸与一类防具的整体)
|
||||
ZOMBIE_ASH_DAMAGE = 'ashDAMAGE' # 灰烬植物攻击,直接伤害本体
|
||||
ZOMBIE_RANGE_DAMAGE = 'rangeDamage' # 范围攻击,同时伤害二类防具与(僵尸与一类防具的整体)
|
||||
ZOMBIE_ASH_DAMAGE = 'ashDamage' # 灰烬植物攻击,直接伤害本体
|
||||
ZOMBIE_WALLNUT_BOWLING_DANMAGE = 'wallnutBowlingDamage' # 坚果保龄球冲撞伤害
|
||||
|
||||
# 僵尸生命值设置
|
||||
LOSTHEAD_HEALTH = 70
|
||||
NORMAL_HEALTH = 200 # 普通僵尸生命值
|
||||
|
||||
FLAG_HEALTH = 50
|
||||
CONEHEAD_HEALTH = 370
|
||||
BUCKETHEAD_HEALTH = 1100
|
||||
NEWSPAPER_HEALTH = 200
|
||||
NEWSPAPER_HEALTH = 150
|
||||
|
||||
ATTACK_INTERVAL = 500
|
||||
ZOMBIE_WALK_INTERVAL = 60 # 僵尸步行间隔
|
||||
@ -213,6 +213,6 @@ PLAY = 'play'
|
||||
BACKGROUND_DAY = 0
|
||||
BACKGROUND_NIGHT = 1
|
||||
BACKGROUND_POOL = 2
|
||||
BACKGROUND_FOOGY = 3
|
||||
BACKGROUND_FOG = 3
|
||||
BACKGROUND_ROOF = 4
|
||||
BACKGROUND_ROOFNIGHT = 5
|
||||
@ -606,7 +606,8 @@ class Level(tool.State):
|
||||
if plant:
|
||||
if plant.name == c.WALLNUTBOWLING:
|
||||
if plant.canHit(i):
|
||||
zombie.setDamage(c.WALLNUT_BOWLING_DAMAGE, damageType=c.ZOMBIE_DEAFULT_DAMAGE)
|
||||
zombie.setDamage(c.WALLNUT_BOWLING_DAMAGE, damageType=c.ZOMBIE_WALLNUT_BOWLING_DANMAGE)
|
||||
# 注意:以上语句为通用处理,以后加入了铁门僵尸需要单独设置直接冲撞就直接杀死
|
||||
plant.changeDirection(i)
|
||||
elif plant.name == c.REDWALLNUTBOWLING:
|
||||
if plant.state == c.IDLE:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user