예제 #1
0
        static void BeginAdventure(UserProfile player, PlanetFactory[] smallGalaxy, SpaceShip[] spaceShip, TradeGood[] cargoTypes)
        {
            bool   quit = false;
            string option;

            PlanetFactory currentPlanet = smallGalaxy[0]; //The user starts at Plant '0' which is Earth

            SpaceShip currentShip = spaceShip[0];         //This is the beginning ship

            do                                            //The program will loop through this until they decide to quit or 14600 days (40 years) have passed
            {
                for (int i = 0; i < cargoTypes.Length; i++)
                {
                    cargoTypes[i].cost = TradeGood.MarketValue(cargoTypes[i].goodName);
                }

                do                                                  //The user will stay at this planet until they decide to travel to another planet
                {
                    UserProfile.PrintUserInfo(player, currentShip); //Keeps a header at the top of the game that displays the player's information as well as some information about the ship
                    Console.WriteLine($"Welcome to {currentPlanet.planetName}!  What would you like to do? \nVisit the Trader's Market    <Market>\nGo to Shipshape's Ship Shop  <Ship>\n" +
                                      $"Travel to the next planet    <Travel>\nQuit the Game <Quit>");

                    option = Console.ReadLine();  //String input for the option chosen by the player    //Error checked by the switch statement

                    switch (option)
                    {
                    case "Market":
                        Economy.MarketPlace(cargoTypes, player, currentShip);      //Goes to the Marketplace to buy and sell goods, as well as view their inventory
                        break;

                    case "Ship":
                        currentShip = SpaceShip.ShipGarage(spaceShip, currentShip, player, cargoTypes);      //Goes to the shipyard to buy a new ship
                        break;

                    case "Travel":
                        currentPlanet = Travel.GoSomewhere(player, currentShip, currentPlanet, smallGalaxy);      //Go somewhere else in this small part of the galaxy
                        break;

                    case "Quit":
                        quit = true;
                        break;

                    default:                                                                                    //Error handles any incorrect input
                        Console.WriteLine("Please enter a valid option.  The input is Case-sensative");
                        Console.WriteLine("Press <Enter> to try again.");
                        Console.ReadLine();
                        break;
                    }
                    Console.Clear();
                } while (option != "Travel" && !quit);
            } while(!quit && player.daysPlayed <= 14600);
        }
예제 #2
0
        static void BeginAdventure(UserProfile player, string currentPlanet)
        {
            int option      = 0;
            int menuOptions = 3;

            //Create the types of Tradable Goods as objects
            TradeGood[] cargoInventory = new TradeGood[4];

            TradeGood tOil      = new TradeGood("Oil", 5);
            TradeGood tSilver   = new TradeGood("Silver", 10);
            TradeGood tGold     = new TradeGood("Gold", 25);
            TradeGood tTitanium = new TradeGood("Titanium", 10);

            cargoInventory[0] = tOil;
            cargoInventory[1] = tSilver;
            cargoInventory[2] = tGold;
            cargoInventory[3] = tTitanium;

            int[] setGoodPrice = new int[cargoInventory.Length];

            //Create the planets as objects
            PlanetFactory earth        = new PlanetFactory("Earth", 0, 0);
            PlanetFactory alphaCentari = new PlanetFactory("Alpha Centari", 0, -4.367);
            PlanetFactory m63          = new PlanetFactory("M63", -5, 4);
            PlanetFactory magrathea    = new PlanetFactory("Magrathea", 50, 50);
            PlanetFactory vogosphere   = new PlanetFactory("Vogosphere", -15, 10);
            PlanetFactory arrakis      = new PlanetFactory("Arrakis", 7, 3);
            PlanetFactory corrin       = new PlanetFactory("Corrin", -3, -9);
            PlanetFactory helionPrime  = new PlanetFactory("Helion Prime", -5, -5);

            // Create space ships as objects
            SpaceShip[] shipShop = new SpaceShip[3];

            SpaceShip beginnerShip = new SpaceShip("Simple Simon", 000, 3000, 10, 4);
            SpaceShip MidLevelShip = new SpaceShip("Space Knight", 1500, 3500, 40, 7);
            SpaceShip ExpertShip   = new SpaceShip("Avenger jet", 2500, 2000, 100, 9);

            shipShop[0] = beginnerShip;
            shipShop[1] = MidLevelShip;
            shipShop[2] = ExpertShip;

            // Need a loop here so that the player can continue to play for '40' years

            setGoodPrice = PlanetFactory.MarketValue(setGoodPrice.Length);
            for (int i = 0; i < setGoodPrice.Length; i++)
            {
                cargoInventory[i].cost = setGoodPrice[i];
            }

            SpaceShip currentShip = beginnerShip;

            UserProfile.PrintUserInfo(player, currentShip);
            Console.WriteLine($"Welcome to {currentPlanet}!  What would you like to do? \n1.The Trader's Market \n2.Shipshape Ship Shop\n3.Travel to next planet");

            option = Utility.ErrorHandler(menuOptions);

            Console.Clear();

            switch (option)
            {
            case 1:
                Economy.MarketPlace(cargoInventory, player, currentShip);      //Pass current ShipObject, GoodObjects, and UserProfile object
                Console.Read();
                break;

            case 2:
                SpaceShip.ShipGarage(shipShop, player);
                currentShip = SpaceShip.ShipGarage(shipShop, player);
                Console.WriteLine($"You have purchased the {currentShip.shipName}");
                Console.ReadLine();
                break;

            case 3:
                Travel();
                break;

            default:
                break;
            }
        }