Esempio n. 1
0
        static void BeginAdventure(UserProfile player, string currentPlanet)
        {
            int option      = 0;
            int menuOptions = 3;

            //Create the types of Tradable Goods as objects
            TradeGood[] cargoInventory = new TradeGood[4];

            TradeGood tOil      = new TradeGood("Oil", 5);
            TradeGood tSilver   = new TradeGood("Silver", 10);
            TradeGood tGold     = new TradeGood("Gold", 25);
            TradeGood tTitanium = new TradeGood("Titanium", 10);

            cargoInventory[0] = tOil;
            cargoInventory[1] = tSilver;
            cargoInventory[2] = tGold;
            cargoInventory[3] = tTitanium;

            int[] setGoodPrice = new int[cargoInventory.Length];

            //Create the planets as objects
            PlanetFactory earth        = new PlanetFactory("Earth", 0, 0);
            PlanetFactory alphaCentari = new PlanetFactory("Alpha Centari", 0, -4.367);
            PlanetFactory m63          = new PlanetFactory("M63", -5, 4);
            PlanetFactory magrathea    = new PlanetFactory("Magrathea", 50, 50);
            PlanetFactory vogosphere   = new PlanetFactory("Vogosphere", -15, 10);
            PlanetFactory arrakis      = new PlanetFactory("Arrakis", 7, 3);
            PlanetFactory corrin       = new PlanetFactory("Corrin", -3, -9);
            PlanetFactory helionPrime  = new PlanetFactory("Helion Prime", -5, -5);

            // Create space ships as objects
            SpaceShip[] shipShop = new SpaceShip[3];

            SpaceShip beginnerShip = new SpaceShip("Simple Simon", 000, 3000, 10, 4);
            SpaceShip MidLevelShip = new SpaceShip("Space Knight", 1500, 3500, 40, 7);
            SpaceShip ExpertShip   = new SpaceShip("Avenger jet", 2500, 2000, 100, 9);

            shipShop[0] = beginnerShip;
            shipShop[1] = MidLevelShip;
            shipShop[2] = ExpertShip;

            // Need a loop here so that the player can continue to play for '40' years

            setGoodPrice = PlanetFactory.MarketValue(setGoodPrice.Length);
            for (int i = 0; i < setGoodPrice.Length; i++)
            {
                cargoInventory[i].cost = setGoodPrice[i];
            }

            SpaceShip currentShip = beginnerShip;

            UserProfile.PrintUserInfo(player, currentShip);
            Console.WriteLine($"Welcome to {currentPlanet}!  What would you like to do? \n1.The Trader's Market \n2.Shipshape Ship Shop\n3.Travel to next planet");

            option = Utility.ErrorHandler(menuOptions);

            Console.Clear();

            switch (option)
            {
            case 1:
                Economy.MarketPlace(cargoInventory, player, currentShip);      //Pass current ShipObject, GoodObjects, and UserProfile object
                Console.Read();
                break;

            case 2:
                SpaceShip.ShipGarage(shipShop, player);
                currentShip = SpaceShip.ShipGarage(shipShop, player);
                Console.WriteLine($"You have purchased the {currentShip.shipName}");
                Console.ReadLine();
                break;

            case 3:
                Travel();
                break;

            default:
                break;
            }
        }
Esempio n. 2
0
        internal static PlanetFactory GoSomewhere(UserProfile player, SpaceShip currentShip, PlanetFactory currentPlanet, PlanetFactory[] smallGalaxy)
        {
            double[] distance = new double[smallGalaxy.Length];
            int      i        = 0;
            int      j        = 0;
            int      option   = 0;

            UserProfile.PrintUserInfo(player, currentShip);

            for (i = 0; i < smallGalaxy.Length; i++)
            {
                distance[i] = DistanceToPlanet(currentPlanet, smallGalaxy[i]);
            }

            Console.WriteLine("Please choose a destination");
            do
            {
                for (i = 0; i < smallGalaxy.Length; i++)
                {
                    if (distance[i] > 0 && distance[i] <= currentShip.currentFuelCapacity)
                    {
                        Console.WriteLine($"{i + 1}. Planet {smallGalaxy[i].planetName} is {distance[i].ToString("#.000")} light years away");
                        j++;
                    }
                }

                if (j == 0)
                {
                    option = 0;
                    Console.WriteLine($"There are no planets within range.  Go fuel up the {currentShip.shipName}.");
                    Console.ReadLine();
                    distance[option] = 0;
                }
                else
                {
                    Console.WriteLine("\n");
                    option = (Utility.ErrorHandler(i) - 1);

                    if (currentShip.currentFuelCapacity < distance[option])
                    {
                        Console.WriteLine("You do not have enough fuel to reach that planet, please try again.\n");
                    }
                }
            }while (currentShip.currentFuelCapacity < distance[option]);

            if (j == 0)
            {
                return(currentPlanet);
            }
            else
            {
                double warpSpeed = GetWarpSpeed(currentShip);

                int timePassed = TravelTime(warpSpeed, distance[option]);

                currentShip.currentFuelCapacity -= distance[option];
                player.daysPlayed += timePassed;

                currentPlanet = smallGalaxy[option];

                return(currentPlanet);
            }
        }