示例#1
0
    def _approach (self, enemy, faceTorsoEnemy):
        i = 0
        x = 0
        while True:
            x = Board.adjacent_cells(enemy, (faceTorsoEnemy+i)%6, self.board)
            i += 1
            if (not x in self.mechs.enemys_cell()) and x != 0: break
        pf = pathfinder.PathFinder(self.board.successors, self.board.move_cost, self.board.heuristic_to_goal)
        A = Pos(self.playerCell, self.playerFace)
        B = Pos(x, Board.facing_side(x, enemy))
        if A == B: return ([], 3)

        path, can, cost = pf.compute_path_until_PM (A, B, 0, self.player.walk)

        if can == False and self.player.run != 0:
            path2, can2, cost2 = pf.compute_path_until_PM(A, B, 1, self.player.run)

            if can2 == True:
                return (path2, 1)
        if can == False and self.player.jump != 0:
            print "ESTO K ES!: walk then jump"
            print self.player.walk
            print self.player.jump
            path3, can3, cost3 = pf.compute_path_until_PM(A, B, 2, self.player.jump)
            if (can3 == True) or  (self.player.jump >= self.player.walk):
                return (path3,2)
        return (path, 0)
示例#2
0
    def posible_positions (self,enemyCell, distance2enemy):
        positions = []
        faceEnemy = relative_position (self.playerCell, enemyCell)
        face = faceEnemy
        #if distance2enemy <3:
        #    face = (face+3)%6
        cell = self.playerCell
        newCell = cell
        for i in range(2):
            cell = newCell
            for j in [0,1,-1]:
                newCell = Board.adjacent_cells(cell, face+j, self.board)
                if newCell == 0: continue
                # Miramos si ai algun bosque denso o  ligero
                obj = self.board.map[newCell[0]][newCell[1]].objects
                if obj == 1 or obj == 2:
                    positions.append(newCell)

        return positions, faceEnemy