Exemplo n.º 1
0
        public void MovingTo(Ship myShip, Player_Stats player, Trading makeMoney)
        {
            int    destNum; //going to planet #
            int    wSpeed;  // warp factor holder
            double speed;   //speed in light years
            bool   isGood      = false;
            bool   closePlanet = false;
            int    input       = 0;

            do
            {
                Console.WriteLine("Where would you like to go?");
                WhereCanMove(myShip, ref closePlanet, true);
                Console.WriteLine("Enter the number for where you would like to go.");
                Console.WriteLine($"Or enter {numberOfPlanets + 1} to leave."); //ask where to go Earth is 0 so max+1
                destNum = Utility.GetInt(numberOfPlanets + 1);                  //get input
                if (destNum == numberOfPlanets + 1)
                {
                    Console.WriteLine("You decide not to leave.");
                    isGood = true;
                }
                else if (closePlanet == false)
                {
                    Console.WriteLine("You don't have enough fuel to get anywhere.");
                    isGood = true;
                }
                else if (Distance(destNum) > myShip.Fuel() && planetNum != destNum)
                {
                    Console.WriteLine($"That is not close enough. Please select a planet on the list. Or {numberOfPlanets + 1} to leave.");
                }
                else if (planetNum != destNum)
                {
                    Console.WriteLine("What warp speed do you want to travel at?");
                    Console.WriteLine($"Your current ship's maximum speed is {myShip.Speed()}.");
                    wSpeed = Utility.GetInt(myShip.Speed());
                    if (wSpeed == 0)
                    {
                        Console.WriteLine("You decide not to leave.");
                        isGood = false;
                    }
                    else
                    {
                        speed      = Math.Pow(wSpeed, (10 / 3.0)) + Math.Pow((10 - wSpeed), (-11 / 3.0));
                        travelTime = Distance(destNum) / speed;
                        convertTime(travelTime);
                        Console.Write("It will take: ");
                        Console.Write($"{tripYears} Years, ");
                        Console.Write($"{tripWeeks} Weeks, ");
                        Console.Write($"{tripDays} Days, ");
                        Console.Write($"and {tripHours} Hours.");
                        Console.WriteLine("Would you like to travel?");
                        input = Utility.GetInt(2);
                        if (input == 1)
                        {
                            player.AddDistance(Distance(destNum));
                            Console.WriteLine($"You have arrived at {GetPlanetName(destNum)}.");
                            player.AddTime(tripYears, tripWeeks, tripDays, tripHours);
                            tripYears = 0;
                            tripWeeks = 0;
                            tripDays  = 0;
                            tripHours = 0;
                            myShip.UseFuel(Distance(destNum)); //uses the fuel
                            planetNum = destNum;
                            isGood    = true;
                            makeMoney.MakePrices(universe, planetNum);
                        }
                        else
                        {
                            Console.WriteLine("You decided not to leave.");
                            isGood = true;
                        }
                    }
                }
                else
                {
                    Console.WriteLine("You decided not to leave.");
                    isGood = true;
                }
            }while (!isGood);
            return;
        }
Exemplo n.º 2
0
        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();
        }