예제 #1
0
    public void FinishMove(PathfindingNode destination)
    {
        if ((base.currentMovement - destination.GetCost()) >= 0 && playerCanMove == true)
        {
            UpdatePlayerLocation(destination.GetSpace());
            UpdateCurrentPlayerMovement(destination.GetCost());

            this.GetController().MoveShip(destination.GetPath(true).ToArray());

            playerController.SetCurrentMovement(base.currentMovement, base.maxMovement);


            SetPlayerCanMove(false);
            animatingMovement = true;

            fuelResource -= destination.GetCost();
            playerController.SetFuel(fuelResource, fuelResourceMax);
            if (fuelResource < 0)
            {
                SceneManager.LoadScene("GameOver");
            }

            gameController.SetTradeable(stationModel.GetStation(destination.GetSpace()) != null);

            foreach (PathfindingNode node in validMovementSpaces)
            {
                node.GetSpace().ClearHighlighted();
            }

            validMovementSpaces.Clear();
        }
    }
예제 #2
0
 // recursive function
 public List <PathfindingNode> GetPath(bool endPoint)
 {
     if (parent == null)
     {
         return(new List <PathfindingNode>());
     }
     else if (endPoint)
     {
         List <PathfindingNode> path = parent.GetPath(false);
         path.Add(parent);
         path.Add(this);
         return(path);
     }
     else
     {
         List <PathfindingNode> path = parent.GetPath(false);
         path.Add(parent);
         return(path);
     }
 }