コード例 #1
0
ファイル: Program.cs プロジェクト: HEFLINGA/SpaceGame
        // 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
        }
コード例 #2
0
ファイル: Story.cs プロジェクト: HEFLINGA/SpaceGame
        // Intro Story and establishing name of Captian
        public void Intro()
        {
            #region StoryStartUp
            Console.WriteLine("Enter your name, Captian: ");
            V.character = Console.ReadLine();

            // Intro line and story
            Program.UI();
            Console.WriteLine("Welcome to Space Game!!");
            Console.WriteLine();
            Console.WriteLine($"  The year is 0AR. A relative passed and left you, {V.character}, 10,000 credits. Your family used to be rich merchants, but " +
                              "fell on hard times... You have just finished flight school, and have always had a dream of becoming a space ship captain. So, you " +
                              "decided to try your luck at that life to restore your family's name and wealth. The First stop! A cheap, Space Ship sales shop.");
            Console.WriteLine("Press 'Enter' to continue");
            Console.ReadLine();

            // Console
            Program.UI();
            Console.WriteLine("You arrive at the cheapest space ship sales barn you could.. Real Fake Ships.. Definitely not your first choice, " +
                              "But it's the only place on this planet you can find with a ship that's in your budget.");
            Console.WriteLine("");
            Console.WriteLine("You look around the room, trying to find anything below the price of 10,000 credits. Looking high and low, you " +
                              "discover that even here at Real Fake Ships, the choices are slim to none!");
            Console.WriteLine("");
            Console.WriteLine("Then you see it!! Behind a cracked Real Fake Door, a ship with a price tag in your budget.. the tag says \"5,000 " +
                              "credits.No Warrenty. Buy at own risk.\"");
            Console.WriteLine("");
            Console.WriteLine($"Click enter to walk up to the risky looking ship you spotted.. {Ship.ShowShipName(Ship.currentShip)}. and take its tag to the " +
                              $"check out counter: ");
            Console.WriteLine("");
            Console.ReadLine();

            Program.UI();
            Console.WriteLine($"The cashier sees you walking up from the dark corner where they keep {Ship.ShowShipName(Ship.currentShip)}, and begins to laugh. " +
                              $"as soon as you reach the counter, they asked if you knew what you were getting yourself into with that ship (the oldest ship " +
                              $"currently on the market).");
            Console.WriteLine("");
            Console.WriteLine("You reply with the truth, and let them know that you really don't have any other options. They try to control " +
                              "the laughter as they ring you up.");
            Console.WriteLine("");
            Console.WriteLine("Click 'enter' to continue");
            Console.ReadLine();
            Console.WriteLine($"You should be warned, {V.character}, this is a space game! You will be exploring the Galaxy, using fuel, buying and " +
                              $"selling resources and trying to get the next upgrade to your ship to get to further and further planets!! If you are not careful.. " +
                              $"you could easily run out of fuel on a random planet without any money or fuel left to get to a closer planet.. And that planet might " +
                              $"even by the 'Screaming Sun Planet'.. It seems nice at first, until the damn sun comes up. This game will not hold your hand! Watch your " +
                              $"fuel, and dont run out of money and get stranded! (I suggest just sticking to a travel route between 'Alpha Centauri' and 'Earth' for the " +
                              $"first few good sales).");
            Console.WriteLine("");
            Console.WriteLine("Anyways!! Good luck out there. You wont be hearing from me again. I got better things to do then explain things and hold " +
                              "your hand. You chose this life, don't blame me.");
            Console.WriteLine("");
            Console.WriteLine("Click 'enter' to continue");
            Console.ReadLine();
            Console.WriteLine("Type 'Buy' to complete the transaction, and start your amazing journey of wealth, family and adventure!!");
            #endregion
        }