示例#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
        internal static SpaceShip BuyShip(SpaceShip[] shipShop, SpaceShip currentShip, UserProfile player, TradeGood[] cargoHold)
        {
            int numOptions = shipShop.Length;
            int shipChoice = 0;

            UserProfile.PrintUserInfo(player, currentShip);

            Console.WriteLine($"Please enter the number for the spaceship you want to buy or fly");
            Console.WriteLine($"===============================================================================================================");
            Console.WriteLine($"     Ship            || Cost of Ship  || Amount of Cargo space avalible   ||  Fuel Capacity     ||   Top Speed");
            Console.WriteLine($"===============================================================================================================");
            Console.WriteLine($"1. {shipShop[0].shipName}     || {shipShop[0].shipCost}CC           ||  {shipShop[0].cargoCapacity}     ||    {shipShop[0].totalFuelCapacity}    " +
                              $"  ||     {shipShop[0].topSpeed} ");
            Console.WriteLine($"2. {shipShop[1].shipName}     || {shipShop[1].shipCost}CC           ||  {shipShop[1].cargoCapacity}     ||    {shipShop[1].totalFuelCapacity}    " +
                              $"  ||     {shipShop[1].topSpeed} ");
            Console.WriteLine($"3. {shipShop[2].shipName}     || {shipShop[2].shipCost}CC           ||  {shipShop[2].cargoCapacity}     ||    {shipShop[2].totalFuelCapacity}    " +
                              $"  ||     {shipShop[0].topSpeed} ");

            shipChoice = Utility.ErrorHandler(numOptions) - 1;
            if (shipChoice < 0)
            {
                Console.WriteLine("Invalid Option.  \"Good bye\"");
                System.Threading.Thread.Sleep(1000);
                return(currentShip);
            }
            else if (shipShop[shipChoice].shipCost > player.cosmicCredits)
            {
                Console.WriteLine("Sorry bud, you dont have enough cosmic credits to buy a new ride. ");
                Console.WriteLine("Please try again");
                Console.Read();
                return(currentShip);
            }
            else
            {
                // subtract the current cargo space from the new ship
                shipShop[shipChoice].cargoCapacity -= TradeGood.TotalCargoSize(cargoHold);
                player.cosmicCredits         -= shipShop[shipChoice].shipCost;
                shipShop[shipChoice].shipCost = 0;
                currentShip.cargoCapacity    += TradeGood.TotalCargoSize(cargoHold);

                Console.WriteLine($"You have purchased the {shipShop[shipChoice].shipName}!");
                Console.ReadLine();
                Console.Clear();
                return(shipShop[shipChoice]);
            }
        }
示例#3
0
        internal static void TotalCost(UserProfile player, TradeGood tradeGoods, SpaceShip spaceShips)
        {
            int     totalCost    = 0;
            int     newCargo     = 0;
            int     quantity     = 0;
            Boolean insufficient = true;

            do
            {
                Console.Write($"How much of {tradeGoods.goodName} do you want to purchase?  ");

                quantity = Utility.ErrorHandler(1000000);

                totalCost = tradeGoods.cost * quantity;
                newCargo  = tradeGoods.size * quantity;

                if (totalCost > player.cosmicCredits)
                {
                    Console.WriteLine($"Insufficient funds.  You have {player.cosmicCredits}cc and {quantity} of {tradeGoods.goodName} costs {totalCost}");
                    Console.WriteLine("Please try again.");
                    insufficient = true;
                }
                else if (newCargo > spaceShips.cargoCapacity)
                {
                    Console.WriteLine($"Insufficient cargo space.  You need {newCargo} space and you only have {spaceShips.cargoCapacity}.");
                    Console.WriteLine("Please try again.");
                    insufficient = true;
                }
                else
                {
                    insufficient = false;
                }
            } while (insufficient == true);

            player.cosmicCredits -= totalCost;
            TradeGood.AddGoods(tradeGoods, quantity);

            spaceShips.cargoCapacity -= (quantity * tradeGoods.size);

            if (quantity > 0)
            {
                tradeGoods.prevBuy = (tradeGoods.prevBuy + totalCost) / (tradeGoods.quantity + quantity);
            }
        }
示例#4
0
        internal static void MarketPlace(TradeGood[] cargoInventory, UserProfile player, SpaceShip currentShip)
        {
            int option      = 0;
            int goodChoice  = 0;
            int addQuantity = 0;
            int numOptions  = 4;

            do
            {
                UserProfile.PrintUserInfo(player, currentShip);
                Console.WriteLine($"What would you like to do? \n1. Buy \n2. Sell \n3. View Inventory \n 4. Go to Planet Menu");

                option = Utility.ErrorHandler(numOptions);

                switch (option)
                {
                case 1:
                    goodChoice  = BuyGoods(cargoInventory);
                    addQuantity = TotalCost(player, cargoInventory[goodChoice], currentShip);
                    TradeGood.AddGoods(cargoInventory[goodChoice], addQuantity);
                    Console.WriteLine($"There are now {cargoInventory[goodChoice].quantity} pieces of {cargoInventory[goodChoice].goodName} in your inventory.");
                    Console.WriteLine("Press <ENTER> to continue...");
                    Console.ReadLine();
                    break;

                case 2:
                    SellGoods(cargoInventory, player, currentShip);
                    break;

                case 3:
                    ViewInventory(cargoInventory);
                    Console.ReadLine();
                    break;

                default:
                    break;
                }
                Console.Clear();
            } while (option != 4);
        }
示例#5
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;
            }
        }
示例#6
0
 internal static void SellGoods(TradeGood sell, int sellGoods)
 {
     sell.quantity -= sellGoods;
 }
示例#7
0
 internal static void AddGoods(TradeGood add, int addGoods)
 {
     add.quantity += addGoods;
 }
示例#8
0
 internal static void PreviousPurchase(TradeGood add, int purchase)
 {
     add.prevBuy = purchase;
 }