Esempio n. 1
0
        // Menu for travel and changing of planets in Planets.cs
        public void TravelMenu()
        {
            string travelInput = "";

            Program.UI();
            Console.WriteLine("Where would you like to go!!: \n" +
                              "(Type name of planet you wish to go to)");
            Console.ForegroundColor = ConsoleColor.DarkYellow;
            Console.WriteLine("press 'Enter' to leave the space port and return to Main Menu");
            Console.WriteLine();
            Console.ForegroundColor = ConsoleColor.DarkCyan;

            // Bools for deciding if you are in range of planets
            #region Bool and loops for range
            bool[] inRange = new bool[8];
            for (int i = 0; i < inRange.Length; i++)
            {
                inRange[i] = false;
            }

            // If statements determening whether or not you are in range of a planet
            if ((Planet.DistanceToPlanets(Planet.currentPlanet, Planet.GetCurX(), Planet.GetCurY(), Planet.GetDestX(1), Planet.GetDestY(1)) <= Ship.curFuel) && (Planet.currentPlanet != 1))
            {
                Console.WriteLine("Planet {0} is in Range!", Planet.GetPlanetName(1));
                inRange[0] = true;
            }
            if ((Planet.DistanceToPlanets(Planet.currentPlanet, Planet.GetCurX(), Planet.GetCurY(), Planet.GetDestX(2), Planet.GetDestY(2)) <= Ship.curFuel) && (Planet.currentPlanet != 2))
            {
                Console.WriteLine("Planet {0} is in Range!", Planet.GetPlanetName(2));
                inRange[1] = true;
            }
            if ((Planet.DistanceToPlanets(Planet.currentPlanet, Planet.GetCurX(), Planet.GetCurY(), Planet.GetDestX(3), Planet.GetDestY(3)) <= Ship.curFuel) && (Planet.currentPlanet != 3))
            {
                Console.WriteLine("Planet {0} is in Range!", Planet.GetPlanetName(3));
                inRange[2] = true;
            }
            if ((Planet.DistanceToPlanets(Planet.currentPlanet, Planet.GetCurX(), Planet.GetCurY(), Planet.GetDestX(4), Planet.GetDestY(4)) <= Ship.curFuel) && (Planet.currentPlanet != 4))
            {
                Console.WriteLine("Planet {0} is in Range!", Planet.GetPlanetName(4));
                inRange[3] = true;
            }
            if ((Planet.DistanceToPlanets(Planet.currentPlanet, Planet.GetCurX(), Planet.GetCurY(), Planet.GetDestX(5), Planet.GetDestY(5)) <= Ship.curFuel) && (Planet.currentPlanet != 5))
            {
                Console.WriteLine("Planet {0} is in Range!", Planet.GetPlanetName(5));
                inRange[4] = true;
            }
            if ((Planet.DistanceToPlanets(Planet.currentPlanet, Planet.GetCurX(), Planet.GetCurY(), Planet.GetDestX(6), Planet.GetDestY(6)) <= Ship.curFuel) && (Planet.currentPlanet != 6))
            {
                Console.WriteLine("Planet {0} is in Range!", Planet.GetPlanetName(6));
                inRange[5] = true;
            }
            if ((Planet.DistanceToPlanets(Planet.currentPlanet, Planet.GetCurX(), Planet.GetCurY(), Planet.GetDestX(7), Planet.GetDestY(7)) <= Ship.curFuel) && (Planet.currentPlanet != 7))
            {
                Console.WriteLine("Planet {0} is in Range!", Planet.GetPlanetName(7));
                inRange[6] = true;
            }
            if ((Planet.DistanceToPlanets(Planet.currentPlanet, Planet.GetCurX(), Planet.GetCurY(), Planet.GetDestX(8), Planet.GetDestY(8)) <= Ship.curFuel) && (Planet.currentPlanet != 8))
            {
                Console.WriteLine("Planet {0} is in Range!", Planet.GetPlanetName(8));
                inRange[7] = true;
            }
            #endregion

            // Code for changing planetary information based on range and user input
            #region Planet changed based on range and input
            travelInput = Console.ReadLine().ToLower();
            if ((travelInput == "earth") && (inRange[0] == true))
            {
                Console.Clear();
                new Planet().Planets(1, Planet.GetCurX(), Planet.GetCurY(), Planet.GetDestX(1), Planet.GetDestY(1), 0);
                Program.UI();
            }
            else if ((travelInput == "alpha centauri") && (inRange[1] == true))
            {
                Console.Clear();
                new Planet().Planets(2, Planet.GetCurX(), Planet.GetCurY(), Planet.GetDestX(2), Planet.GetDestY(2), 500);
                Program.UI();
            }
            else if ((travelInput == "trappist-1") && (inRange[2] == true))
            {
                Console.Clear();
                new Planet().Planets(3, Planet.GetCurX(), Planet.GetCurY(), Planet.GetDestX(3), Planet.GetDestY(3), 1000);
                Program.UI();
            }
            else if ((travelInput == "krootabulon") && (inRange[3] == true))
            {
                Console.Clear();
                new Planet().Planets(4, Planet.GetCurX(), Planet.GetCurY(), Planet.GetDestX(4), Planet.GetDestY(4), 3000);
                Program.UI();
            }
            else if ((travelInput == "bird world") && (inRange[4] == true))
            {
                Console.Clear();
                new Planet().Planets(5, Planet.GetCurX(), Planet.GetCurY(), Planet.GetDestX(5), Planet.GetDestY(5), 5000);
                Program.UI();
            }
            else if ((travelInput == "gazorpazorp") && (inRange[5] == true))
            {
                Console.Clear();
                new Planet().Planets(6, Planet.GetCurX(), Planet.GetCurY(), Planet.GetDestX(6), Planet.GetDestY(6), 5500);
                Program.UI();
            }
            else if ((travelInput == "alphabetruim") && (inRange[6] == true))
            {
                Console.Clear();
                new Planet().Planets(7, Planet.GetCurX(), Planet.GetCurY(), Planet.GetDestX(7), Planet.GetDestY(7), 8000);
                Program.UI();
            }
            else if ((travelInput == "planet squanch") && (inRange[7] == true))
            {
                Console.Clear();
                new Planet().Planets(8, Planet.GetCurX(), Planet.GetCurY(), Planet.GetDestX(8), Planet.GetDestY(8), 10000);
                Program.UI();
            }
            else if ((inRange[0] == false) &&
                     (inRange[1] == false) &&
                     (inRange[2] == false) &&
                     (inRange[3] == false) &&
                     (inRange[4] == false) &&
                     (inRange[5] == false) &&
                     (inRange[6] == false) &&
                     (inRange[7] == false) &&
                     (V.credits < 500) &&
                     (V.curInventory < 1))
            {
                stranded = true;
            }
            else
            {
                Console.WriteLine("Returning to Menu");
                System.Threading.Thread.Sleep(1000);
                Console.Clear();
            }
            #endregion
        }
Esempio n. 2
0
        // Selects destination when traveling.
        private Planet PickPlanet(int warpFactor)
        {
            double fuelEfficiency = FuelEfficiencyCalc(warpFactor);
            double warpSpeed      = Math.Pow(warpFactor, (10.0 / 3.0)) + Math.Pow((10 - warpFactor), (-11.0 / 3.0));

            // Resource burn calculations. Will be used to determine which locations are displayed for travel.
            double fuelReq1  = Location.DistanceToPlanet(Earth) * fuelEfficiency;
            double yearsReq1 = Location.DistanceToPlanet(Earth) / (warpSpeed);

            double fuelReq2  = Location.DistanceToPlanet(AlphaCentauri) * fuelEfficiency;
            double yearsReq2 = Location.DistanceToPlanet(AlphaCentauri) / (warpSpeed);

            double fuelReq3  = Location.DistanceToPlanet(MysteryPlanet) * fuelEfficiency;
            double yearsReq3 = Location.DistanceToPlanet(MysteryPlanet) / (warpSpeed);

            double fuelReq4  = Location.DistanceToPlanet(ShipGarage) * fuelEfficiency;
            double yearsReq4 = Location.DistanceToPlanet(ShipGarage) / (warpSpeed);

            double fuelReq5  = Location.DistanceToPlanet(PizzaPlanet) * fuelEfficiency;
            double yearsReq5 = Location.DistanceToPlanet(PizzaPlanet) / (warpSpeed);

            double fuelReq6  = Location.DistanceToPlanet(OtherPlanet) * fuelEfficiency;
            double yearsReq6 = Location.DistanceToPlanet(OtherPlanet) / (warpSpeed);

            double fuelReq7  = Location.DistanceToPlanet(OtherPlanet2) * fuelEfficiency;
            double yearsReq7 = Location.DistanceToPlanet(OtherPlanet2) / (warpSpeed);

            double fuelReq8  = Location.DistanceToPlanet(OtherPlanet3) * fuelEfficiency;
            double yearsReq8 = Location.DistanceToPlanet(OtherPlanet3) / (warpSpeed);

            double fuelReq9  = Location.DistanceToPlanet(OtherPlanet4) * fuelEfficiency;
            double yearsReq9 = Location.DistanceToPlanet(OtherPlanet4) / (warpSpeed);


            Console.Clear();
            Console.WriteLine("Where would you like to go?");

            // used to asign a unique value to option cases.
            int optionIndex = 1;

            // each option corresponds to a location.
            int optionCase1 = 0;
            int optionCase2 = 0;
            int optionCase3 = 0;
            int optionCase4 = 0;
            int optionCase5 = 0;
            int optionCase6 = 0;
            int optionCase7 = 0;
            int optionCase8 = 0;
            int optionCase9 = 0;

            // each if statement checks that location is either in range based on current fuel level/years left,
            // and that the requirements do not burn 0 resources (travel to current location). optionIndex then
            // assigns a value (starting at 1) for each case that meets the boolean requirements.
            if (Math.Floor(fuelReq1) < GetFuelLevel() && fuelReq1 != 0)
            {
                Console.WriteLine($"{optionIndex} = {Earth.GetPlanetName()}");
                optionCase1 = optionIndex++;
            }
            if (Math.Floor(fuelReq2) < GetFuelLevel() && fuelReq2 != 0)
            {
                Console.WriteLine($"{optionIndex} = {AlphaCentauri.GetPlanetName()}");
                optionCase2 = optionIndex++;
            }
            if (Math.Floor(fuelReq3) < GetFuelLevel() && fuelReq3 != 0)
            {
                Console.WriteLine($"{optionIndex} = {MysteryPlanet.GetPlanetName()}");
                optionCase3 = optionIndex++;
            }
            if (Math.Floor(fuelReq4) < GetFuelLevel() && fuelReq4 != 0)
            {
                Console.WriteLine($"{optionIndex} = {ShipGarage.GetPlanetName()}");
                optionCase4 = optionIndex++;
            }
            if (Math.Floor(fuelReq5) < GetFuelLevel() && fuelReq5 != 0)
            {
                Console.WriteLine($"{optionIndex} = {PizzaPlanet.GetPlanetName()}");
                optionCase5 = optionIndex++;
            }
            if (Math.Floor(fuelReq6) < GetFuelLevel() && fuelReq6 != 0)
            {
                Console.WriteLine($"{optionIndex} = {OtherPlanet.GetPlanetName()}");
                optionCase6 = optionIndex++;
            }
            if (Math.Floor(fuelReq7) < GetFuelLevel() && fuelReq7 != 0)
            {
                Console.WriteLine($"{optionIndex} = {OtherPlanet2.GetPlanetName()}");
                optionCase7 = optionIndex++;
            }
            if (Math.Floor(fuelReq8) < GetFuelLevel() && fuelReq8 != 0)
            {
                Console.WriteLine($"{optionIndex} = {OtherPlanet3.GetPlanetName()}");
                optionCase8 = optionIndex++;
            }
            if (Math.Floor(fuelReq9) < GetFuelLevel() && fuelReq9 != 0)
            {
                Console.WriteLine($"{optionIndex} = {OtherPlanet4.GetPlanetName()}");
                optionCase9 = optionIndex++;
            }
            Console.WriteLine();

            Planet destination = new Planet();

            try
            {
                int option = int.Parse(Console.ReadLine());

                // if input matches the corresponding optionCase, destination is set to a given planet.
                if (option == optionCase1 && option != 0)
                {
                    destination = Earth;
                }
                else if (option == optionCase2 && option != 0)
                {
                    destination = AlphaCentauri;
                }
                else if (option == optionCase3 && option != 0)
                {
                    destination = MysteryPlanet;
                }
                else if (option == optionCase4 && option != 0)
                {
                    destination = ShipGarage;
                }
                else if (option == optionCase5 && option != 0)
                {
                    destination = PizzaPlanet;
                }
                else if (option == optionCase6 && option != 0)
                {
                    destination = OtherPlanet;
                }
                else if (option == optionCase7 && option != 0)
                {
                    destination = OtherPlanet2;
                }
                else if (option == optionCase8 && option != 0)
                {
                    destination = OtherPlanet3;
                }
                else if (option == optionCase9 && option != 0)
                {
                    destination = OtherPlanet4;
                }
                else
                {
                    Console.WriteLine("You did not pick a valid option.");
                    // if input does not match an option case, the current location is returned. A boolean check in Travel() bypasses remaining travel
                    // functions if destination == Location.
                    destination = Location;
                }
                return(destination);
            }
            catch (Exception)
            {
                Console.WriteLine("Invalid Input.");
                // if input does not match an option case, the current location is returned. A boolean check in Travel() bypasses remaining travel
                // functions if destination == Location.
                return(Location);
            }
        }
Esempio n. 3
0
        // Main Game
        public static void Main(string[] args)
        {
            // Instantiating first ship into game, and placing player on 1st planet
            Ship.currentShip = 1;
            new Ship().ShipName("Star Cruiser");
            new Ship().ShipSpeed(1.5);
            new Ship().ShipVelocity(Velocity(1.5));
            new Ship().ShipMaxFuel(10);
            Planet.currentPlanet = 1;

            // Variable Decleration
            string input;
            string shopInput;
            int    cost = 0;

            // Stroy Start up
            new Story().Intro();

            // Get input from console to select first ship
            input = Console.ReadLine();
            switch (input)
            {
            case "Buy":
            case "buy":
                cost       = 5000;
                V.credits -= 5000;
                new Ship().ShipCargo(3);
                Ship.curFuel = 10;
                break;

            default:
                Console.Clear();
                Console.WriteLine("You decide not to buy the ship, and to take a less risky/difficult approach to life.. You decide to instead go to the nearest " +
                                  "bar and spend every dime you just inherited on anything! that will make you feel better.... You died later that night, by " +
                                  "an overdose from who knows how many different things... ");
                Console.WriteLine("Press enter to exit");
                Console.ReadLine();
                break;
            }

            // Loop for game
            #region Game
            if (cost != 0)
            {
                Planet.GetPlanetName(Planet.currentPlanet);
                UI();
                Console.SetCursorPosition(43, 12);
                Console.WriteLine("You paid {0} for your ship!!", cost);
                Console.WriteLine();
                Console.SetCursorPosition(35, 13);
                Console.WriteLine("Thank you for shopping with SpaceBuggies R Us");
                Menu.ShowLoadingScreen();

                UI();
                Console.SetCursorPosition(26, 13);
                Console.WriteLine("Your first ship!! The {0}. Speed: {1}. Cargo Space: {2}",
                                  Ship.ShowShipName(Ship.currentShip),
                                  Ship.ShowShipSpeed(Ship.currentShip),
                                  V.maxInventory);
                Menu.ShowLoadingScreen();

                // Player starts his journey exploring and buying
                do
                {
                    // Console/Menu
                    UI();
                    Console.WriteLine("You are on planet {0}! Current year is {1}!",
                                      Planet.GetPlanetName(Planet.currentPlanet),
                                      Math.Round(V.time, 2));

                    Console.WriteLine();
                    Console.WriteLine("What would you like to do?: \n" +
                                      "- 'Ship'to buy a new ship or buy Fuel for your current one\n" +
                                      "- 'Buy' to buy goods\n" +
                                      "- 'Sell' to sell goods\n" +
                                      "- 'travel' to see planets in range!\n" +
                                      "- 'inv' to check your current inventory space");
                    Console.ForegroundColor = ConsoleColor.DarkYellow;
                    Console.WriteLine("- 'exit' to exit the game........");

                    // Planetary options
                    shopInput = Console.ReadLine().ToLower();
                    if (shopInput != "exit")
                    {
                        if (shopInput == "ship")
                        {
                            new Menu.ShipBuy().ShipMenu();
                        }
                        else if (shopInput == "buy")
                        {
                            new Menu.Buy().BuyMenu();
                        }
                        else if (shopInput == "sell")
                        {
                            new Menu.Sell().SellMenu();
                        }
                        else if (shopInput == "inv")
                        {
                            V.Inventory(V.maxInventory, V.curInventory);
                        }
                        else if (shopInput == "travel")
                        {
                            new Menu().TravelMenu();
                        }
                        else if (shopInput == "exit")
                        {
                            break;
                        }
                    }
                } while ((GameOver(V.credits, V.time) == false) && (shopInput != "exit") && (Menu.stranded == false));
                // Game over
                Console.ForegroundColor = ConsoleColor.DarkYellow;
                Console.WriteLine("Game Over!! Total years played: {0}yrs.  Total credits earned: {1}.", Math.Round(V.time, 2), V.totalCredits - 10000);
                Console.ReadLine();
            }
            #endregion
        }