使用原版模式进行濒死僵尸处理
This commit is contained in:
parent
fcd6714389
commit
1f3181a3c1
@ -32,7 +32,7 @@ class Zombie(pg.sprite.Sprite):
|
|||||||
self.animate_timer = 0
|
self.animate_timer = 0
|
||||||
self.attack_timer = 0
|
self.attack_timer = 0
|
||||||
self.state = c.WALK
|
self.state = c.WALK
|
||||||
self.animate_interval = 200
|
self.animate_interval = 150
|
||||||
self.ice_slow_ratio = 1
|
self.ice_slow_ratio = 1
|
||||||
self.ice_slow_timer = 0
|
self.ice_slow_timer = 0
|
||||||
self.hit_timer = 0
|
self.hit_timer = 0
|
||||||
@ -67,13 +67,22 @@ class Zombie(pg.sprite.Sprite):
|
|||||||
elif self.state == c.FREEZE:
|
elif self.state == c.FREEZE:
|
||||||
self.freezing()
|
self.freezing()
|
||||||
|
|
||||||
def walking(self):
|
# 濒死状态用函数
|
||||||
if (self.lostHead and (self.current_time - self.losthead_timer) > self.dead_timer):
|
def checkToDie(self, framesKind):
|
||||||
|
if self.health <= 0:
|
||||||
self.setDie()
|
self.setDie()
|
||||||
elif self.health <= c.LOSTHEAD_HEALTH and not self.lostHead:
|
elif self.health <= c.LOSTHEAD_HEALTH:
|
||||||
self.changeFrames(self.losthead_walk_frames)
|
if not self.lostHead:
|
||||||
|
self.changeFrames(framesKind)
|
||||||
self.setLostHead()
|
self.setLostHead()
|
||||||
elif self.health <= c.NORMAL_HEALTH and self.helmet:
|
else:
|
||||||
|
self.health -= (self.current_time - self.losthead_timer) / 40
|
||||||
|
self.losthead_timer = self.current_time
|
||||||
|
|
||||||
|
def walking(self):
|
||||||
|
self.checkToDie(self.losthead_walk_frames)
|
||||||
|
|
||||||
|
if self.health <= c.NORMAL_HEALTH and self.helmet:
|
||||||
self.changeFrames(self.walk_frames)
|
self.changeFrames(self.walk_frames)
|
||||||
self.helmet = False
|
self.helmet = False
|
||||||
if self.name == c.NEWSPAPER_ZOMBIE:
|
if self.name == c.NEWSPAPER_ZOMBIE:
|
||||||
@ -87,12 +96,9 @@ class Zombie(pg.sprite.Sprite):
|
|||||||
self.rect.x -= self.speed
|
self.rect.x -= self.speed
|
||||||
|
|
||||||
def attacking(self):
|
def attacking(self):
|
||||||
if (self.lostHead and (self.current_time - self.losthead_timer) > self.dead_timer):
|
self.checkToDie(self.losthead_attack_frames)
|
||||||
self.setDie()
|
|
||||||
elif self.health <= c.LOSTHEAD_HEALTH and not self.lostHead:
|
if self.health <= c.NORMAL_HEALTH and self.helmet:
|
||||||
self.changeFrames(self.losthead_attack_frames)
|
|
||||||
self.setLostHead()
|
|
||||||
elif self.health <= c.NORMAL_HEALTH and self.helmet:
|
|
||||||
self.changeFrames(self.attack_frames)
|
self.changeFrames(self.attack_frames)
|
||||||
self.helmet = False
|
self.helmet = False
|
||||||
if (self.current_time - self.attack_timer) > (c.ATTACK_INTERVAL * self.getTimeRatio()):
|
if (self.current_time - self.attack_timer) > (c.ATTACK_INTERVAL * self.getTimeRatio()):
|
||||||
@ -111,21 +117,19 @@ class Zombie(pg.sprite.Sprite):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
def freezing(self):
|
def freezing(self):
|
||||||
if (self.lostHead and (self.current_time - self.losthead_timer) > self.dead_timer):
|
|
||||||
self.setDie()
|
|
||||||
elif self.health <= c.LOSTHEAD_HEALTH and not self.lostHead:
|
|
||||||
if self.old_state == c.WALK:
|
if self.old_state == c.WALK:
|
||||||
self.changeFrames(self.losthead_walk_frames)
|
self.checkToDie(self.losthead_walk_frames)
|
||||||
else:
|
else:
|
||||||
self.changeFrames(self.losthead_attack_frames)
|
self.checkToDie(self.losthead_attack_frames)
|
||||||
self.setLostHead()
|
|
||||||
if (self.current_time - self.freeze_timer) > c.FREEZE_TIME:
|
if (self.current_time - self.freeze_timer) > c.FREEZE_TIME:
|
||||||
self.setWalk()
|
self.setWalk()
|
||||||
|
|
||||||
def setLostHead(self):
|
def setLostHead(self):
|
||||||
self.losthead_timer = self.current_time
|
self.losthead_timer = self.current_time
|
||||||
self.lostHead = True
|
self.lostHead = True
|
||||||
self.animate_interval = 90
|
self.animate_interval = 180
|
||||||
|
self.speed = 0.5
|
||||||
if self.head_group is not None:
|
if self.head_group is not None:
|
||||||
self.head_group.add(ZombieHead(self.rect.centerx, self.rect.bottom))
|
self.head_group.add(ZombieHead(self.rect.centerx, self.rect.bottom))
|
||||||
|
|
||||||
@ -185,7 +189,7 @@ class Zombie(pg.sprite.Sprite):
|
|||||||
|
|
||||||
def setWalk(self):
|
def setWalk(self):
|
||||||
self.state = c.WALK
|
self.state = c.WALK
|
||||||
self.animate_interval = 150
|
self.animate_interval = 180
|
||||||
|
|
||||||
if self.helmet:
|
if self.helmet:
|
||||||
self.changeFrames(self.helmet_walk_frames)
|
self.changeFrames(self.helmet_walk_frames)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user