Beispiel #1
0
class Mob(Character):
    def __init__(self, mob_type, name, **kwargs):
        super(Mob, self).__init__(mob_type, name, **kwargs)
        self.health = 7
        self.status = "alive"
        self.path = Path()
        self.side = "evil"
        self.face = mob_type
        self.state = None

    def take_damage(self, damage):
        self.health -= damage
        if self.health <= 0:
            self.status = "dead"

    def move_step(self, atlas):
        self.update_status()
        if self.state == 'idle':
            direction = self.directions.get_random_direction(self.x, self.y, atlas=atlas)
        else:
            direction = self.path.get_next_step()
            if not direction:
                direction = self.directions.get_random_direction(self.x, self.y, atlas=atlas)

        self.move(atlas, direction=direction)

    def update_status(self):
        if self.path.is_far():
            self.state = "idle"
        else:
            self.state = "alert"
Beispiel #2
0
 def __init__(self, mob_type, name, **kwargs):
     super(Mob, self).__init__(mob_type, name, **kwargs)
     self.health = 7
     self.status = "alive"
     self.path = Path()
     self.side = "evil"
     self.face = mob_type
     self.state = None