static void Main(string[] args) { Ship myShip; myShip = new Ship(3, 12, 6, 10, 10); // set ship speed, cargo slots, slot size, fuel tank, and fuel Travel myUniverse; myUniverse = new Travel(200, 0); Player_Stats player; player = new Player_Stats(100, 0, 0, 0, 0, 0); bool isGameOver = false; //if a game end triggers this will be changed to true string input = ""; //Useful for when we want input int[,] cargoItems = new int[24, 2] { { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 } }; //to store type and amount of cargo in slots
public static bool CheckGameOver(Ship myShip, Travel myUniverse, Player_Stats player) { int counter = 0; bool hasCargo = false; bool enoughFuel = false; do { if (myShip.inventory[counter, 1] == 0) { hasCargo = false; counter++; } else { hasCargo = true; counter = myShip.CargoSlots(); } }while (counter < myShip.CargoSlots()); myUniverse.WhereCanMove(myShip, ref enoughFuel, false); if (player.SYears() >= 40) { Console.WriteLine("After long years trading you've gotten too old to for this and retire."); return(true); } else if (player.SMoney() == 0 && hasCargo == false) { return(true); } else if ((player.SMoney() <= 4) && enoughFuel == false) { return(true); } return(false); }
public void UIstart() { bool valid; Console.WriteLine("Please enter your character name: "); characterName = Console.ReadLine(); while (string.IsNullOrWhiteSpace(characterName)) { Console.Clear(); Console.WriteLine("Please enter a valid character name: "); characterName = Console.ReadLine(); } do { Console.Clear(); Console.WriteLine($"Hey {characterName.ToUpper()}!!! pick your stage in life :"); Console.WriteLine("\n1. Beginning - You start at 18 yrs old, and have $100."); Console.WriteLine("2. Intermediate - You start at 22 yrs old, and have $200."); Console.WriteLine("3. Advanced - You start at 26 yrs old, and have $300."); Console.WriteLine("\nSelect number cooresponding to class"); valid = int.TryParse(Console.ReadLine(), out userCharClass); } while ((userCharClass < 0) || (userCharClass > 3) || (!valid)); Dialog.StartGameDialog(); Console.WriteLine("Press <Enter> to continue"); Console.ReadLine(); character1 = new Character(characterName, userCharClass); move = new Travel(); trade = new PlanetPhase(); move.setShip(character1.currentAge); trade.SetDictionary(); trade.goods.ItemChange(50, 's'); Console.Clear(); do { Console.WriteLine($"Current Planet: {move.currentPlanet.planetName}"); MainMenu(); if ((character1.currentAge > 60) || (Character.currentMoney < 1 && trade.assets < 10)) { Console.WriteLine("YOU DIED OF OLD AGE and/or YOU DIED BECAUSE YOU LOST ALL OF YOUR MONEY, TRY AGAIN NEXT TIME!"); gameOver = true; } if ((Character.currentDebt < 0)) { Console.WriteLine("YOU WIN GOOD JOB PAY OFF YOUR SCUMMY FATHER'S DEBT. I HEAR HE IS STILL AROUND SOMEWHERE THOUGH, AND JUST FAKED HIS DEATH TO MAKE YOU PAY!"); gameOver = true; } } while (!gameOver); }
public void BuyThings(Ship myShip, Player_Stats player, Travel myUniverse) { int cargoWhere = 0; int itemAmount = 0; int currentItemBuy = 0; bool isGood = false; bool buy = false; cost = 0; do { if (checkInventorySlot(myShip, ref cargoWhere)) { if (myShip.inventory[cargoWhere, 0] != 0) //if slot isn't empty need to buy same thing { Console.WriteLine($"You want to buy more {Utility.CargoName(myShip.inventory[cargoWhere, 0])}."); Console.WriteLine("How much do you want to buy?"); itemAmount = Utility.GetInt(myShip.SlotSize()); if (itemAmount == 0) { Console.WriteLine("Decided not to buy huh."); isGood = true; } else if ((itemAmount + myShip.inventory[cargoWhere, 1]) > myShip.SlotSize()) //if the amount you want more than fills it you can't buy { Console.WriteLine("There isn't enough space"); isGood = true; } else// this is where buying happens when you already have the item { cost = prices[myShip.inventory[cargoWhere, 0]] * itemAmount; Console.WriteLine($"That will cost {cost}."); Utility.BuySellYN(cost, ref buy, 1, player); //call the buying thing if (buy) //you bought something { Console.WriteLine("Thank you for your business."); isGood = true; } cost = 0; } } else //slot is empty, what do you want? { Console.WriteLine("What do you want to buy?"); Console.WriteLine("Press 0 to exit."); currentItemBuy = Utility.GetInt(9); if (currentItemBuy == 0) //you want to leave { Console.WriteLine("It's ok if you don't want to buy anything."); isGood = true; } else //initial buying an item, something you don't already own { Console.WriteLine("How much to you want to buy?"); itemAmount = Utility.GetInt(myShip.SlotSize()); if (itemAmount == 0) { Console.WriteLine("Decided not to buy huh."); // 0 means buy nothing isGood = true; } else if (itemAmount > myShip.SlotSize()) { Console.WriteLine("There isn't enough space"); // you can't fit more than slotsize } else { cost = itemAmount * prices[currentItemBuy]; Console.WriteLine($"The cost is {cost}."); Utility.BuySellYN(cost, ref buy, 1, player); if (buy) { myShip.inventory[cargoWhere, 1] = itemAmount; myShip.inventory[cargoWhere, 0] = currentItemBuy; cost = 0; isGood = true; } else { Console.WriteLine("Mayber another time."); cost = 0; isGood = true; } } } } } }while (!isGood); return; }
static void Main(string[] args) { Ship myShip; myShip = new Ship(3, 12, 6, 10, 10); // set ship speed, cargo slots, slot size, fuel tank, and fuel Travel myUniverse; myUniverse = new Travel(200, 0); Player_Stats player; player = new Player_Stats(100, 0, 0, 0, 0, 0); int[] prices = new int[10] { 0, 11, 3, 8, 12, 7, 4, 14, 10, 9 }; Trading makeMoney = new Trading(prices, 0); bool isGameOver = false; //if a game end triggers this will be changed to true int input; //Useful for when we want input Console.WriteLine("The Space Game"); Console.WriteLine("After a lifetime of wandering between planets you have finally decided to pursue your fortune in the interplanetary trade industry."); Console.WriteLine("Earth is your home and starting planet. You will embark from here to start exploring new routes to new planets."); System.Threading.Thread.Sleep(10000); Console.Clear(); Console.WriteLine("With your life savings(100 credits) and a brand new ship you head out to make your fortune. "); Console.WriteLine("Welcome to the beginning of your space trading adventure."); System.Threading.Thread.Sleep(6000); Console.Clear(); Console.WriteLine("Rules for the game:"); Console.WriteLine("You will have 40 years to acquire as much wealth as possible and become the greatest trader of all time."); Console.WriteLine("Trade Routes: Plan appropriate and ensure that you find the best routes for moving around the galaxy."); Console.WriteLine("Time: This is your greatest enemy, learn to manipulate it to give you the advantage."); Console.WriteLine("Trade: Start early and trade often to be successful."); Console.WriteLine("Game Over Criteria: The game will end if you lose all of your fortune, quit the game, or you survive for 40 years."); System.Threading.Thread.Sleep(15000); Console.Clear(); do { Console.WriteLine("What would you like to do?"); Console.WriteLine("1. Trade"); Console.WriteLine("2. Travel"); Console.WriteLine("3. Take care of my ship."); Console.WriteLine("4. Check Status"); Console.WriteLine("0. Quit"); input = Utility.GetInt(4); switch (input) { case 1: { makeMoney.NewTrade(myUniverse, player, myShip); break; } case 2: { myUniverse.MovingTo(myShip, player, makeMoney); break; } case 3: { myShip.ShipThings(player); break; } case 4: { player.Status(myUniverse, myShip); break; } case 0: { isGameOver = true; break; } } if (!isGameOver) { isGameOver = Utility.CheckGameOver(myShip, myUniverse, player); } }while (!isGameOver); player.Status(myUniverse, myShip); Console.ReadLine(); }