예제 #1
0
파일: Patrol.py 프로젝트: Orchaldir/Pyro
 def execute(self, actor):
     moved = False
     
     while not moved:
         if self.path is None:
             x, y = self.points[self.index]
             self.path = actor.find_path(x, y)
     
         if self.path is not None and self.path.has_next():
             if can_move(actor, self.path.get()):
                 self.path.next()
                 return 'Success'
             else:
                 self.path = None
         else:
             self.index =  (self.index + 1) % len(self.points)
             self.path = None
예제 #2
0
 def execute(self, actor):
     perception = actor.components['Perception']
     
     if perception.sound is None:
         return 'Failed'
     
     print 'Investigate : ' + str(perception.sound.loudness)
     
     path = actor.find_path(perception.sound.x, perception.sound.y)
     
     if path is not None and path.has_next():
         if can_move(actor, path.get()):
             path.next()
             
             return 'Success'
     
     perception.sound = None
     
     return 'Failed'
예제 #3
0
파일: Attack.py 프로젝트: Orchaldir/Pyro
 def execute(self, actor):
     enemies = actor.components['Perception'].get_enemies()
     
     #print 'Attack: ', actor.name, ' ', len(enemies)
     
     if len(enemies) is 0:
         return 'Failed'
     
     enemy = enemies[0]
     
     if can_attack(actor, enemy):
         #actor.attack(enemy)
         return 'Success'
     
     path = actor.find_path(enemy.body.x, enemy.body.y)
     
     if path is not None and path.has_next():
         if can_move(actor, path.get()):
             path.next()
             return 'Success'
     
     return 'Failed'
예제 #4
0
파일: Pyro.py 프로젝트: Orchaldir/Pyro
def move(direction):
    global hero
    
    can_move(hero, direction)