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(); } }
// 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); } }