コード例 #1
0
ファイル: Planet.cs プロジェクト: HEFLINGA/SpaceGame
        // Travel from planet to planet and change curX and curY
        public int Planets(int currentPlanet, double getX, double getY, double destX, double destY, int planetaryFactor)
        {
            Program.UI();
            if (currentPlanet == Planet.currentPlanet)
            {
                Console.WriteLine("You are already here!! No need to travel anywhere..");
                Console.ForegroundColor = ConsoleColor.DarkYellow;
                Console.WriteLine("Press 'enter' to return to Menu");
                Console.ReadLine();
            }
            else if (currentPlanet != Planet.currentPlanet)
            {
                Console.WriteLine("Heading to {0}!", GetPlanetName(currentPlanet));
                Console.WriteLine("Distance is: {0}LYs", Math.Round(Program.Distance(getX, getY, destX, destY), 3));
                Console.WriteLine("It will take you: {0}yrs", V.timePassage = Math.Round(Program.Distance(getX, getY, destX, destY) / Program.Velocity(Ship.ShowShipSpeed(Ship.currentShip)), 2));
                Console.WriteLine();
                Console.ForegroundColor = ConsoleColor.Green;
                Console.WriteLine("type 'GO' to depart");
                Console.ForegroundColor = ConsoleColor.DarkYellow;
                Console.WriteLine();
                Console.WriteLine("press 'enter' to go back to main menu");
                Console.ForegroundColor = ConsoleColor.Green;
                double distance = Math.Ceiling(Program.Distance(getX, getY, destX, destY));
                string conf     = Console.ReadLine().ToLower();
                Console.ForegroundColor = ConsoleColor.DarkYellow;

                if (conf == "go")
                {
                    Planet.currentPlanet = currentPlanet;
                    V.time += V.timePassage;
                    GetPlanetName(currentPlanet);
                    GetCurX();
                    GetCurY();
                    Ship.curFuel -= distance;
                    new Menu().RandomNumbers(planetaryFactor);
                    new Planet().Loading(currentPlanet);
                }
                else
                {
                    Console.WriteLine("Returning to Menu");
                    System.Threading.Thread.Sleep(1100);
                }
            }

            return(currentPlanet);
        }
コード例 #2
0
 // Congrats Window when buying ship
 private void Congrats()
 {
     Program.UI();
     Console.WriteLine("Congratulations on your new ship!!!!!");
     Console.WriteLine("You now have a new max speed, cargo, and fuel!");
     Console.WriteLine();
     Console.WriteLine("New Max Speed: {0}.  New Max Cargo: {1}. New Max Fuel: {2}", Ship.ShowShipSpeed(Ship.currentShip), V.maxInventory, Ship.ShowShipMaxFuel(Ship.currentShip));
     Console.ForegroundColor = ConsoleColor.DarkYellow;
     Console.WriteLine("Press 'enter' to return to Main Menu");
     Console.ReadLine();
 }
コード例 #3
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
        }