internal static SpaceShip ShipGarage(SpaceShip[] shipShop, SpaceShip currentShip, UserProfile player, TradeGood[] cargoHold) { int option = 0; int numOptions = 3; do { UserProfile.PrintUserInfo(player, currentShip); Console.WriteLine($"Welcome to Ship Shape's Ship Shop! What would you like to do? " + $"\n1. Buy a ship \n2. Refuel your ship \n3. Return to Planet Menu"); option = Utility.ErrorHandler(numOptions); switch (option) { case 1: currentShip = BuyShip(shipShop, currentShip, player, cargoHold); break; case 2: RefuelShip(currentShip, player); break; default: break; } Console.Clear(); } while (option != 3); return(currentShip); }
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); }
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]); } }
internal static void MarketPlace(TradeGood[] cargoInventory, UserProfile player, SpaceShip currentShip) { int option = 0; int numOptions = 4; Console.Clear(); do { UserProfile.PrintUserInfo(player, currentShip); Console.WriteLine($"What would you like to do? \n1. Buy \n2. Sell \n3. View Inventory \n4. Go to Planet Menu"); option = Utility.ErrorHandler(numOptions); switch (option) { case 1: BuyGoods(player, cargoInventory, currentShip); //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); }
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; } }
internal static PlanetFactory GoSomewhere(UserProfile player, SpaceShip currentShip, PlanetFactory currentPlanet, PlanetFactory[] smallGalaxy) { double[] distance = new double[smallGalaxy.Length]; int i = 0; int j = 0; int option = 0; UserProfile.PrintUserInfo(player, currentShip); for (i = 0; i < smallGalaxy.Length; i++) { distance[i] = DistanceToPlanet(currentPlanet, smallGalaxy[i]); } Console.WriteLine("Please choose a destination"); do { for (i = 0; i < smallGalaxy.Length; i++) { if (distance[i] > 0 && distance[i] <= currentShip.currentFuelCapacity) { Console.WriteLine($"{i + 1}. Planet {smallGalaxy[i].planetName} is {distance[i].ToString("#.000")} light years away"); j++; } } if (j == 0) { option = 0; Console.WriteLine($"There are no planets within range. Go fuel up the {currentShip.shipName}."); Console.ReadLine(); distance[option] = 0; } else { Console.WriteLine("\n"); option = (Utility.ErrorHandler(i) - 1); if (currentShip.currentFuelCapacity < distance[option]) { Console.WriteLine("You do not have enough fuel to reach that planet, please try again.\n"); } } }while (currentShip.currentFuelCapacity < distance[option]); if (j == 0) { return(currentPlanet); } else { double warpSpeed = GetWarpSpeed(currentShip); int timePassed = TravelTime(warpSpeed, distance[option]); currentShip.currentFuelCapacity -= distance[option]; player.daysPlayed += timePassed; currentPlanet = smallGalaxy[option]; return(currentPlanet); } }