예제 #1
0
        public override bool doAction()
        {
            Direction[] directions = {Direction.North, Direction.East, Direction.South, Direction.West};

            Util.shuffle(directions);

            Location newLocation = new Location(-1, -1);

            Direction direction = Direction.None;
            for(int i = 0; i < 4; i++)
            {
                Location adjLocation = actor.location.getAdjLocation(directions[i]);
                Tile tile = level.getTile(adjLocation);
                if (tile != null && !level.getTile(adjLocation).blocksMovement)
                {
                    direction = directions[i];
                    break;
                }
            }

            if (actor is Monster)
            {
                checkCanSeePlayer();
            }

            alternate = new MoveAction(direction);
            return false;
        }
예제 #2
0
        public override bool doAction()
        {
            Location target = AStarSearch.getFirstStep(actor.location,
                                                       level.getHeroLocation(),
                                                       level);

            Direction directionToTarget = Direction.None;
            if (actor.location.x < target.x)
            {
                directionToTarget = Direction.East;
            }
            else if (actor.location.x > target.x)
            {
                directionToTarget = Direction.West;
            }
            else if (actor.location.y < target.y)
            {
                directionToTarget = Direction.South;
            }
            else if (actor.location.y > target.y)
            {
                directionToTarget = Direction.North;
            }

            alternate = new MoveAction(directionToTarget);
            return false;
        }