Exemple #1
0
        private static (int, bool) GetWarpSpeed(Location oldLocation, Location newLocation, Ship ship, Player player, DialogListBox dialogList)
        {
            //TODO list of warp speed and it shows you the list of calculations

            int  warpSpeed = 7;
            bool done      = false;
            bool travelYes = false;

            do
            {
                dialogList.Items.Clear();
                dialogList.Items.Add("Enter 'q' to exit the warp speed selection");
                dialogList.Items.Add("What is your warp speed of choice (1-9): ");

                string numString = CheckIfValidNumOrQ(dialogList);

                if (numString == "q")
                {
                    done = true;
                    dialogList.Items.Clear();
                }
                else
                {
                    warpSpeed = int.Parse(numString);
                    double tempTime, tempFuel, tempDistance = 42.9;
                    tempDistance         = SpaceTravel.DistanceCalculation(oldLocation, newLocation);
                    (tempTime, tempFuel) = SpaceTravel.WarpSpeedCalcuation(tempDistance, warpSpeed);
                    dialogList.Items.Add("That is " + tempDistance + " lightyears away");
                    dialogList.Items.Add("You will use " + tempFuel + " fuelies to get there at Warp " + warpSpeed);
                    dialogList.Items.Add("And will take " + tempTime + " years.");
                    bool   canTravel = travelCheck(tempTime, tempFuel, player, ship, dialogList);
                    string answer    = "n";
                    if (canTravel)
                    {
                        dialogList.Items.Add("Do you want to go now? Y/N: ");
                        answer = CheckIfValidYorN(dialogList);
                    }

                    if (answer == "y")
                    {
                        done      = true;
                        travelYes = true;
                    }
                    else
                    {
                        dialogList.Items.Add("Do you want to try a different Warp speed? y/n: ");
                        answer = CheckIfValidYorN(dialogList);
                        if (answer == "n")
                        {
                            done      = true;
                            travelYes = false;
                        }
                    }
                };
            } while (!done);

            return(warpSpeed, travelYes);
        }
Exemple #2
0
        private static void TravelDataToDialogBox(Location oldLocation, Location newLocation, int warpSpeed, List <Planet> planets, Ship ship, Player player, DialogListBox dialogList, ListBox planetList)
        {
            dialogList.Items.Clear();
            dialogList.Items.Add("You traveled to " + planets[planetList.SelectedIndex].name);
            double tempTime, tempFuel, tempDistance = 42.9;

            tempDistance         = SpaceTravel.DistanceCalculation(oldLocation, newLocation);
            (tempTime, tempFuel) = SpaceTravel.WarpSpeedCalcuation(tempDistance, warpSpeed);
            dialogList.Items.Add("Distance was " + tempDistance + " lightyears");
            dialogList.Items.Add("You used " + tempFuel + " fuelies (the official fuel of NASCAR)");
            dialogList.Items.Add("And it took " + tempTime + " years.");
        }