public static double UpdateFuelPrice(Planet CurrentPlanet) { double currentPrice = Math.Round(CurrentPlanet.dangerRating * 1, 2); // modifier may require tweaking return(currentPrice); }
public static bool StoryCheck(int wFactor, Planet CurrentPlanet, bool gameFinish) { bool travelAvailable = true; if (NewPlayer.wallet < Actions.UpdateFuelPrice(CurrentPlanet) && NewShip.currentInventory == 0) { travelAvailable = false; foreach (Planet a in Universe.planetTravel) { if ((NewShip.currentFuel - (NewShip.fuelPerLightYear * Equations.DistanceTo(a, CurrentPlanet))) > 0) { travelAvailable = true; } } } else if (NewPlayer.age >= 60) { travelAvailable = false; } if (travelAvailable == false) { TextOutput(story_GameOver, gameEnd: true); gameFinish = false; } if (travelAvailable == true) { if (wFactor >= 1 && NewPlayer.storyTracker == 1) { TextOutput(story_1); NewPlayer.storyTracker++; } else if (wFactor >= 2 && NewPlayer.storyTracker == 2) { TextOutput(story_2); NewPlayer.storyTracker++; } else if (wFactor >= 3 && NewPlayer.storyTracker == 3) { TextOutput(story_3); NewPlayer.storyTracker++; } else if (wFactor >= 4 && NewPlayer.storyTracker == 4) { TextOutput(story_4, 300, true); NewPlayer.storyTracker++; } else if (wFactor >= 5 && NewPlayer.storyTracker == 5) { TextOutput(story_5); NewPlayer.storyTracker++; } else if (wFactor >= 6 && NewPlayer.storyTracker == 6) { TextOutput(story_6); NewPlayer.storyTracker++; } else if (wFactor >= 7 && NewPlayer.storyTracker == 7) { TextOutput(story_7); NewPlayer.storyTracker++; } else if (wFactor >= 8 && NewPlayer.storyTracker == 8) { TextOutput(story_8); NewPlayer.storyTracker++; } else if (wFactor >= 9 && NewPlayer.storyTracker == 9) { TextOutput(story_9); TextOutput(story_glitch, 0); TextOutput(story_ending); gameFinish = true; } } return(gameFinish); }
public Colony(Planet planet) { this.Planet = planet; }
// 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 }
public void TravelTo(Planet destination) { mileage += currentPlanet.DistanceTo(destination); currentPlanet = destination; }
void LoadPlanet() //This method loads a planet depending on the item (spaceship) that the player has obtained. { Console.Clear(); try { Console.WriteLine("========================================================\n" + "You are trying to travel....analyzing ship.....\n" + "Press [Enter]\n"); Console.ReadKey(); if (player.Item == gameManager.Bounty) { player.ResetHealth(); Planet planet = planetManager.ReturnPlanet(gameManager.Bounty - 1); Console.WriteLine($"Your ship has the required components for travelling to {planet.Name}.\n" + $"You enter your spaceship and start navigating through space.....\n" + $"========================================================\n" + "Press [Enter]"); Console.ReadKey(); Console.Clear(); planet.Soundtrack.PlayLooping(); Console.WriteLine(planet.Text); Console.WriteLine("You start searching for bounty....\nIs that an enemy?\n"); foreach (var enemy in planet.Enemies) { Console.WriteLine($"=================================================================\n" + $"{enemy.Name}: { enemy.AppearMessage}\n" + "=================================================================\n"); Fight fight = new Fight(planet.Op); string answer; do { Console.WriteLine(fight.DisplayFight(enemy, player)); Console.WriteLine("\nWhat's your answer Aster?"); answer = Console.ReadLine(); if (fight.InputAnswer(answer)) { enemy.LoseHealth(1); } else { player.LoseHealth(1); } } while (!enemy.IsDead() && !player.IsDead()); if (player.IsDead()) { Console.WriteLine("You are dead, Aster.\n"); Console.WriteLine("Press [Enter] to try again..."); Console.ReadKey(); LoadPlanet(); } else { Console.WriteLine($"===================================\n" + $"{enemy.Name} is dead. \n" + $"===================================\n"); } Console.WriteLine("Press [Enter] to continue traversing through planet."); Console.ReadKey(); Console.Clear(); } gameManager.Bounty += 1; player.AddCoins(planet.Coins); Console.WriteLine("========================================================\n" + "You find no other inhabitants.\n " + $"You have cleared {planet.Name} of imperial rule....\n" + "Press [Enter] to collect bounty and return to Hubb...\n" + "========================================================"); Console.ReadKey(); } else { Console.Clear(); Console.WriteLine("You do not have the proper spaceship to travel to the next planet.\n" + "Press [Enter] to return to the Hubb...."); Console.ReadKey(); } if (gameManager.Bounty > planetManager.ReturnPlanets().Count) { EndGame(); } else { LoadHubb(); } } catch (Exception ex) { Console.WriteLine(ex.Message); } }
public Ship(Planet currentPlanet) { this.currentPlanet = currentPlanet; }
public Moon(Planet planet) { this.Planet = planet; }
public static Planet TravelMenu(Planet CurrentPlanet) { ConsoleKey rKey; int selectionTravel = 1; Planet PlaceHolder = CurrentPlanet; do { Console.Clear(); UserMenu(CurrentPlanet); Console.ForegroundColor = ConsoleColor.DarkGreen; string travelQuestion = "Use the left and right arrow keys to select where you want " + "to travel, then press enter."; Console.SetCursorPosition((Console.WindowWidth - travelQuestion.Length) / 2, 6); Console.WriteLine(travelQuestion); string selectionTravelString = $"{selectionTravel} / {planetTravel.Length}"; Console.SetCursorPosition((Console.WindowWidth - selectionTravelString.Length) / 2, 7); Console.WriteLine(selectionTravelString); PlanetTravelFunction(selectionTravel - 1, CurrentPlanet); rKey = Console.ReadKey().Key; if (rKey == ConsoleKey.LeftArrow) { if (selectionTravel - 1 == 0) { selectionTravel = planetTravel.Length; } else { selectionTravel--; } } if (rKey == ConsoleKey.RightArrow) { if (selectionTravel + 1 > planetTravel.Length) { selectionTravel = 1; } else { selectionTravel++; } } if (rKey == ConsoleKey.Enter) { Console.WriteLine($"Do you want to travel to {planetTravel[selectionTravel - 1].name}?"); Console.WriteLine("Press Enter to confirm or Escape to cancel.\n"); rKey = Console.ReadKey().Key; if (rKey == ConsoleKey.Enter) { bool travelAble = Actions.ChangePlanets(planetTravel[selectionTravel - 1], CurrentPlanet); if (travelAble == false) { return(PlaceHolder); } else { return(planetTravel[selectionTravel - 1]); } } } } while (rKey != ConsoleKey.Escape); return(PlaceHolder); }
public static void TradeMenu(Planet CurrentPlanet) { Actions.UpdateMarketPrices(CurrentPlanet); int selectedGood = 0; int buyOrSell = 0; int cursorCurrent = 9; bool finished = false; List <double> productPrices = new List <double>() { CurrentMarket.air, CurrentMarket.fur, CurrentMarket.robot, CurrentMarket.doors, CurrentMarket.seeds }; List <string> productStrings = new List <string>() { "Canned Earth Air", "Proxima Centaurian Fur", "Gazorpian Service Robot", "Real Fake Doors", "Mega Tree Seeds" }; List <string> buySell = new List <string>() { "Buy", "Sell" }; Console.Clear(); UserMenu(CurrentPlanet); Console.ForegroundColor = ConsoleColor.DarkGreen; string tradeQuestion1 = "Use the UP and DOWN arrow keys to select a good " + "to trade, then press enter."; string tradeQuestion2 = "Press ESC to cancel"; Console.SetCursorPosition((Console.WindowWidth - tradeQuestion1.Length) / 2, 6); Console.WriteLine(tradeQuestion1); Console.SetCursorPosition((Console.WindowWidth - tradeQuestion2.Length) / 2, 7); Console.WriteLine(tradeQuestion2); Console.SetCursorPosition(Console.CursorLeft, 9); Console.WriteLine($"{productStrings[0]}"); Console.WriteLine($" Price: #{productPrices[0]}"); Console.WriteLine($" On Hand: {Products.productList[0].onHand}"); Console.WriteLine(); Console.WriteLine($"{productStrings[1]}"); Console.WriteLine($" Price: #{productPrices[1]}"); Console.WriteLine($" On Hand: {Products.productList[1].onHand}"); Console.WriteLine(); Console.WriteLine($"{productStrings[2]}"); Console.WriteLine($" Price: #{productPrices[2]}"); Console.WriteLine($" On Hand: {Products.productList[2].onHand}"); Console.WriteLine(); Console.WriteLine($"{productStrings[3]}"); Console.WriteLine($" Price: #{productPrices[3]}"); Console.WriteLine($" On Hand: {Products.productList[3].onHand}"); Console.WriteLine(); Console.WriteLine($"{productStrings[4]}"); Console.WriteLine($" Price: #{productPrices[4]}"); Console.Write($" On Hand: {Products.productList[4].onHand}"); Console.SetCursorPosition(0, cursorCurrent); Console.ForegroundColor = ConsoleColor.White; Console.BackgroundColor = ConsoleColor.DarkGreen; Console.WriteLine($"{productStrings[0]}"); Console.ResetColor(); Console.SetCursorPosition(0, 6); ConsoleKeyInfo cki; Console.TreatControlCAsInput = true; do { if (finished != true) { do { cki = Console.ReadKey(true); switch (cki.Key) { case ConsoleKey.DownArrow: if (cursorCurrent < 25) { Console.SetCursorPosition(0, cursorCurrent); Console.ForegroundColor = ConsoleColor.DarkGreen; Console.Write($"{productStrings[selectedGood]}"); cursorCurrent += 4; selectedGood += 1; Console.SetCursorPosition(0, cursorCurrent); Console.ForegroundColor = ConsoleColor.White; Console.BackgroundColor = ConsoleColor.DarkGreen; Console.Write($"{productStrings[selectedGood]}"); Console.ResetColor(); Console.SetCursorPosition(0, 6); break; } else { break; } case ConsoleKey.UpArrow: if (cursorCurrent > 9) { Console.SetCursorPosition(0, cursorCurrent); Console.ForegroundColor = ConsoleColor.DarkGreen; Console.Write($"{productStrings[selectedGood]}"); cursorCurrent -= 4; selectedGood -= 1; Console.SetCursorPosition(0, cursorCurrent); Console.ForegroundColor = ConsoleColor.White; Console.BackgroundColor = ConsoleColor.DarkGreen; Console.Write($"{productStrings[selectedGood]}"); Console.ResetColor(); Console.SetCursorPosition(0, 6); break; } else { break; } case ConsoleKey.Escape: finished = true; break; } } while (cki.Key != ConsoleKey.Enter && finished != true); } Console.Clear(); UserMenu(CurrentPlanet); Console.ForegroundColor = ConsoleColor.DarkGreen; string buyOrSell1 = $"Buy or Sell {Products.productList[selectedGood].unit} at #{productPrices[selectedGood]}."; string buyOrSell2 = "Enter to confirm | ESC to cancel"; Console.SetCursorPosition((Console.WindowWidth - buyOrSell1.Length) / 2, 6); Console.WriteLine(buyOrSell1); Console.SetCursorPosition((Console.WindowWidth - buyOrSell2.Length) / 2, 7); Console.WriteLine(buyOrSell2); if (finished != true) { (finished, buyOrSell) = ListNavigation.scrollList(buySell, 9, finished); } int toBuy; if ((NewPlayer.wallet / productPrices [selectedGood]) > (NewShip.maxInventory - NewShip.currentInventory)) { toBuy = NewShip.maxInventory - NewShip.currentInventory; } else { toBuy = ((int)NewPlayer.wallet / (int)productPrices [selectedGood]); } int toSell = Products.productList[selectedGood].onHand; if (finished != true) { do { Console.Clear(); UserMenu(CurrentPlanet); Console.ForegroundColor = ConsoleColor.DarkGreen; string howMuch1 = $"So you'd like to {buySell[buyOrSell]} {Products.productList[selectedGood].unit} for #{productPrices[selectedGood]}?"; Console.SetCursorPosition((Console.WindowWidth - howMuch1.Length) / 2, 6); Console.WriteLine(howMuch1); string controls = "Use the UP and DOWN arrow keys to change the quantity | ENTER to confirm."; Console.SetCursorPosition((Console.WindowWidth - controls.Length) / 2, 8); Console.WriteLine(controls); if (buyOrSell == 0) { Console.SetCursorPosition(0, 10); Console.Write("Buy "); Console.ForegroundColor = ConsoleColor.White; Console.BackgroundColor = ConsoleColor.DarkGreen; Console.Write(toBuy); Console.ResetColor(); Console.ForegroundColor = ConsoleColor.DarkGreen; Console.Write($" {Products.productList[selectedGood].unit} for "); Console.ForegroundColor = ConsoleColor.White; Console.BackgroundColor = ConsoleColor.DarkGreen; Console.Write($"#{toBuy * productPrices[selectedGood]}"); Console.ResetColor(); Console.ForegroundColor = ConsoleColor.DarkGreen; Console.Write("?"); } else { if (Products.productList[selectedGood].onHand == 0) { Console.SetCursorPosition(0, 10); Console.Write($"You have no {Products.productList[selectedGood].unit} to sell."); finished = true; } else { Console.SetCursorPosition(0, 10); Console.Write("Sell "); Console.ForegroundColor = ConsoleColor.White; Console.BackgroundColor = ConsoleColor.DarkGreen; Console.Write(toSell); Console.ResetColor(); Console.ForegroundColor = ConsoleColor.DarkGreen; Console.Write($" {Products.productList[selectedGood].unit} for "); Console.ForegroundColor = ConsoleColor.White; Console.BackgroundColor = ConsoleColor.DarkGreen; Console.Write($"#{toSell * productPrices[selectedGood]}"); Console.ResetColor(); Console.ForegroundColor = ConsoleColor.DarkGreen; Console.Write("?"); } } if (finished != true) { cki = Console.ReadKey(true); switch (cki.Key) { case ConsoleKey.DownArrow: if (buyOrSell == 0) { if (toBuy > 0) { toBuy -= 1; break; } else { break; } } else { if (toSell > 0) { toSell -= 1; break; } else { break; } } case ConsoleKey.UpArrow: if (buyOrSell == 0) { if (toBuy < (int)(NewPlayer.wallet / productPrices[selectedGood])) { toBuy += 1; break; } else { break; } } else { if (toSell < Products.productList[selectedGood].onHand) { toSell += 1; break; } else { break; } } case ConsoleKey.Escape: finished = true; break; } } else { cki = Console.ReadKey(true); switch (cki.Key) { case ConsoleKey.Escape: finished = true; break; } } } while (cki.Key != ConsoleKey.Enter && finished != true); } if (buyOrSell == 0 && finished != true) { Actions.UpdateInventoryTotal(); if (Game.NewShip.maxInventory >= Game.NewShip.currentInventory + toBuy) { NewPlayer.wallet -= (productPrices[selectedGood] * toBuy); Products.productList[selectedGood].onHand = Products.productList[selectedGood].onHand + toBuy; finished = true; } else { Console.WriteLine("\nYou don't have enough space on your ship."); Console.ReadKey(); finished = true; } } else if (buyOrSell == 1 && finished != true) { NewPlayer.wallet += (productPrices[selectedGood] * toSell); Products.productList[selectedGood].onHand = Products.productList[selectedGood].onHand - toSell; finished = true; } else { } }while (finished != true); Actions.UpdateInventoryTotal(); Console.Clear(); UserMenu(CurrentPlanet); }
public static void ShipUpgradesMenu(Planet CurrentPlanet) { int selected = 0; bool finished = false; List <double> upgradePrices = new List <double>() { Math.Round(Actions.UpdateFuelPrice(CurrentPlanet), 2), Equations.UpgradeCost(NewShip.fuelFactor), Equations.UpgradeCost(NewShip.fuelEfficiencyFactor), Equations.UpgradeCost(NewShip.storageFactor), Equations.UpgradeCost(NewShip.warpFactor) }; List <string> upgradeStrings = new List <string>() { $"Purchase Fuel: #{upgradePrices[0]}", $"Increase Fuel Capacity: #{upgradePrices[1]}", $"Increase Fuel Efficiency: #{upgradePrices[2]}", $"Increase Storage Capacity: #{upgradePrices[3]}", $"Increase Warp Factor: #{upgradePrices[4]}" }; List <string> toBuyStrings = new List <string>() { "more fuel", "a larger fuel tank", "better fuel efficiency", "more inventory space", "a faster Warp Factor" }; List <double> upgradeAdds = new List <double>() { 0, 250, 10, 10, 1 }; Console.Clear(); UserMenu(CurrentPlanet); Console.ForegroundColor = ConsoleColor.DarkGreen; string upgradeQuestion1 = "Use the UP and DOWN arrow keys to select a ship upgrade " + ", then press enter."; string upgradeQuestion2 = "Press ESC to cancel"; Console.SetCursorPosition((Console.WindowWidth - upgradeQuestion1.Length) / 2, 6); Console.WriteLine(upgradeQuestion1); Console.SetCursorPosition((Console.WindowWidth - upgradeQuestion2.Length) / 2, 7); Console.WriteLine(upgradeQuestion2); (finished, selected) = ListNavigation.scrollList(upgradeStrings, 9, finished); int toBuy = 1; int maxBuy = (int)(NewPlayer.wallet / upgradePrices[selected]); ConsoleKeyInfo cki; Console.TreatControlCAsInput = true; if (finished != true) { do { Console.Clear(); UserMenu(CurrentPlanet); Console.ForegroundColor = ConsoleColor.DarkGreen; string howMuch1 = $"So you'd like to buy {toBuyStrings[selected]} for #{upgradePrices[selected]}?"; Console.SetCursorPosition((Console.WindowWidth - howMuch1.Length) / 2, 6); Console.WriteLine(howMuch1); if (selected == 0) { do { Console.SetCursorPosition(0, 10); Console.Write("Buy "); Console.ForegroundColor = ConsoleColor.White; Console.BackgroundColor = ConsoleColor.DarkGreen; Console.Write(toBuy); Console.ResetColor(); Console.ForegroundColor = ConsoleColor.DarkGreen; Console.Write($" Kerbal gallons of rocket fuel for "); Console.ForegroundColor = ConsoleColor.White; Console.BackgroundColor = ConsoleColor.DarkGreen; Console.Write($"#{toBuy * upgradePrices[selected]}"); Console.ResetColor(); Console.ForegroundColor = ConsoleColor.DarkGreen; Console.Write("? "); cki = Console.ReadKey(true); switch (cki.Key) { case ConsoleKey.DownArrow: if (toBuy > 0) { toBuy -= 1; break; } else { break; } case ConsoleKey.UpArrow: if (toBuy < maxBuy) { toBuy += 1; break; } else { break; } case ConsoleKey.LeftArrow: if (toBuy > 24) { toBuy -= 25; break; } else { break; } case ConsoleKey.RightArrow: if (toBuy + 24 < maxBuy) { toBuy += 25; break; } else { break; } case ConsoleKey.Escape: finished = true; break; } } while (cki.Key != ConsoleKey.Enter); } else { if (finished != true && NewPlayer.wallet >= upgradePrices[selected]) { toBuy = 1; NewPlayer.wallet -= (upgradePrices[selected] * toBuy); if (selected == 1) { NewShip.maxFuel += upgradeAdds[selected]; } else if (selected == 2) { NewShip.fuelPerLightYear -= NewShip.fuelPerLightYear / upgradeAdds[selected]; //reduces fuel/lightyear by 10% } else if (selected == 3) { NewShip.maxInventory += (int)upgradeAdds[selected]; } else if (selected == 4) { NewShip.warpFactor += 1; } finished = true; } else { Console.SetCursorPosition(0, 10); Console.WriteLine("You can not afford this upgrade. Keep trading."); Console.ReadLine(); finished = true; } } if (finished != true && selected == 0) { if ((Game.NewShip.currentFuel + toBuy) > Game.NewShip.maxFuel) { Console.WriteLine("\nYou can't store that much fuel."); Console.ReadKey(); finished = true; } else { NewPlayer.wallet -= (upgradePrices [selected] * toBuy); NewShip.currentFuel += toBuy; finished = true; } } } while (finished != true); } Actions.UpdateInventoryTotal(); Console.Clear(); UserMenu(CurrentPlanet); }