Ejemplo n.º 1
0
    public void Move(Soldier soldierGoal, int range)
    {
        this.soldierGoal   = soldierGoal;
        this.movementRange = range;
        CellData soldierGoalPosition = soldierGoal.GetPosition();
        CellData currentPosition     = cachedTransform.GetComponent <Soldier>().GetPosition();

        AStar.SetSearching();

        while (!IsInRange(currentPosition, soldierGoalPosition, range))
        {
            switch (AStar.GetNextMove(currentPosition, soldierGoalPosition))
            {
            case Locomotion.MoveDirection.Up:    MoveUp(currentPosition);    break;

            case Locomotion.MoveDirection.Right: MoveRight(currentPosition); break;

            case Locomotion.MoveDirection.Left:  MoveLeft(currentPosition);  break;

            case Locomotion.MoveDirection.Down:  MoveDown(currentPosition);  break;
            }
        }
    }