示例#1
0
        public static Planet newOrLoadGame()
        {
            Planet loadPlanet = Universe.Earth;

            Console.ForegroundColor = ConsoleColor.DarkGreen;

            string upgradeQuestion1 = "Use the UP and DOWN arrow keys to select an option" +
                                      ", then press enter.";

            Console.SetCursorPosition((Console.WindowWidth - upgradeQuestion1.Length) / 2, 6);
            Console.WriteLine(upgradeQuestion1);

            List <string> newOrLoad = new List <string> ()
            {
                "New Game", "Load Saved Game"
            };
            int selected = ListNavigation.scrollList(newOrLoad, 8);

            if (selected == 0)
            {
                Console.ForegroundColor = ConsoleColor.DarkGreen;

                string loadQuestion = "Starting a new game will erase your current Save data. Are you Sure?";

                Console.SetCursorPosition((Console.WindowWidth - upgradeQuestion1.Length) / 2, 12);
                Console.WriteLine(loadQuestion);

                List <string> areYouSure = new List <string> ()
                {
                    "Yes, Start New Game", "No, Load Current Saved Game"
                };
                selected = ListNavigation.scrollList(areYouSure, 14);

                if (selected == 1)
                {
                    LoadGame load = new LoadGame();
                    loadPlanet = load.LoadG();
                }
                else
                {
                    Console.SetCursorPosition(0, 22);
                    Console.ForegroundColor = ConsoleColor.DarkGreen;
                    Console.WriteLine("What is your name?");
                    Game.NewPlayer.name = Console.ReadLine();
                }
            }
            Console.Title = Game.NewPlayer.name + ": A Life Well Lived";
            return(loadPlanet);
        }
示例#2
0
        public static void TradeUpgradesMenu(Planet CurrentPlanet)
        {
            int selected = 0;

            bool finished = false;

            Console.ForegroundColor = ConsoleColor.DarkGreen;
            string upgradeQuestion1 = "Use the UP and DOWN arrow keys to select an option" +
                                      ", then press enter.";
            string upgradeQuestion2 = "Press ESC to cancel";

            Console.SetCursorPosition((Console.WindowWidth - upgradeQuestion1.Length) / 2, 6);
            Console.WriteLine(upgradeQuestion1);
            Console.SetCursorPosition((Console.WindowWidth - upgradeQuestion2.Length) / 2, 7);
            Console.WriteLine(upgradeQuestion2);

            List <string> goodsOrShip = new List <string>()
            {
                "Goods", "Ship"
            };

            (finished, selected) = ListNavigation.scrollList(goodsOrShip, 9, finished);

            if (selected == 0 && finished != true)
            {
                TradeMenu(CurrentPlanet);
            }
            else if (selected == 1 && finished != true)
            {
                ShipUpgradesMenu(CurrentPlanet);
            }
            else
            {
                UserMenu(CurrentPlanet);
            }
        }
示例#3
0
        public static void TradeMenu(Planet CurrentPlanet)
        {
            Actions.UpdateMarketPrices(CurrentPlanet);

            int  selectedGood  = 0;
            int  buyOrSell     = 0;
            int  cursorCurrent = 9;
            bool finished      = false;

            List <double> productPrices = new List <double>()
            {
                CurrentMarket.air,
                CurrentMarket.fur,
                CurrentMarket.robot,
                CurrentMarket.doors,
                CurrentMarket.seeds
            };

            List <string> productStrings = new List <string>()
            {
                "Canned Earth Air",
                "Proxima Centaurian Fur",
                "Gazorpian Service Robot",
                "Real Fake Doors",
                "Mega Tree Seeds"
            };

            List <string> buySell = new List <string>()
            {
                "Buy",
                "Sell"
            };

            Console.Clear();
            UserMenu(CurrentPlanet);

            Console.ForegroundColor = ConsoleColor.DarkGreen;
            string tradeQuestion1 = "Use the UP and DOWN arrow keys to select a good " +
                                    "to trade, then press enter.";
            string tradeQuestion2 = "Press ESC to cancel";

            Console.SetCursorPosition((Console.WindowWidth - tradeQuestion1.Length) / 2, 6);
            Console.WriteLine(tradeQuestion1);
            Console.SetCursorPosition((Console.WindowWidth - tradeQuestion2.Length) / 2, 7);
            Console.WriteLine(tradeQuestion2);
            Console.SetCursorPosition(Console.CursorLeft, 9);

            Console.WriteLine($"{productStrings[0]}");
            Console.WriteLine($"      Price: #{productPrices[0]}");
            Console.WriteLine($"      On Hand: {Products.productList[0].onHand}");
            Console.WriteLine();
            Console.WriteLine($"{productStrings[1]}");
            Console.WriteLine($"      Price: #{productPrices[1]}");
            Console.WriteLine($"      On Hand: {Products.productList[1].onHand}");
            Console.WriteLine();
            Console.WriteLine($"{productStrings[2]}");
            Console.WriteLine($"      Price: #{productPrices[2]}");
            Console.WriteLine($"      On Hand: {Products.productList[2].onHand}");
            Console.WriteLine();
            Console.WriteLine($"{productStrings[3]}");
            Console.WriteLine($"      Price: #{productPrices[3]}");
            Console.WriteLine($"      On Hand: {Products.productList[3].onHand}");
            Console.WriteLine();
            Console.WriteLine($"{productStrings[4]}");
            Console.WriteLine($"      Price: #{productPrices[4]}");
            Console.Write($"      On Hand: {Products.productList[4].onHand}");

            Console.SetCursorPosition(0, cursorCurrent);
            Console.ForegroundColor = ConsoleColor.White;
            Console.BackgroundColor = ConsoleColor.DarkGreen;
            Console.WriteLine($"{productStrings[0]}");
            Console.ResetColor();
            Console.SetCursorPosition(0, 6);

            ConsoleKeyInfo cki;

            Console.TreatControlCAsInput = true;
            do
            {
                if (finished != true)
                {
                    do
                    {
                        cki = Console.ReadKey(true);
                        switch (cki.Key)
                        {
                        case ConsoleKey.DownArrow:
                            if (cursorCurrent < 25)
                            {
                                Console.SetCursorPosition(0, cursorCurrent);
                                Console.ForegroundColor = ConsoleColor.DarkGreen;
                                Console.Write($"{productStrings[selectedGood]}");

                                cursorCurrent += 4;
                                selectedGood  += 1;

                                Console.SetCursorPosition(0, cursorCurrent);
                                Console.ForegroundColor = ConsoleColor.White;
                                Console.BackgroundColor = ConsoleColor.DarkGreen;
                                Console.Write($"{productStrings[selectedGood]}");
                                Console.ResetColor();
                                Console.SetCursorPosition(0, 6);
                                break;
                            }
                            else
                            {
                                break;
                            }

                        case ConsoleKey.UpArrow:

                            if (cursorCurrent > 9)
                            {
                                Console.SetCursorPosition(0, cursorCurrent);
                                Console.ForegroundColor = ConsoleColor.DarkGreen;
                                Console.Write($"{productStrings[selectedGood]}");

                                cursorCurrent -= 4;
                                selectedGood  -= 1;

                                Console.SetCursorPosition(0, cursorCurrent);
                                Console.ForegroundColor = ConsoleColor.White;
                                Console.BackgroundColor = ConsoleColor.DarkGreen;
                                Console.Write($"{productStrings[selectedGood]}");
                                Console.ResetColor();
                                Console.SetCursorPosition(0, 6);
                                break;
                            }
                            else
                            {
                                break;
                            }

                        case ConsoleKey.Escape:
                            finished = true;
                            break;
                        }
                    } while (cki.Key != ConsoleKey.Enter && finished != true);
                }

                Console.Clear();
                UserMenu(CurrentPlanet);
                Console.ForegroundColor = ConsoleColor.DarkGreen;
                string buyOrSell1 = $"Buy or Sell {Products.productList[selectedGood].unit} at #{productPrices[selectedGood]}.";
                string buyOrSell2 = "Enter to confirm | ESC to cancel";

                Console.SetCursorPosition((Console.WindowWidth - buyOrSell1.Length) / 2, 6);
                Console.WriteLine(buyOrSell1);
                Console.SetCursorPosition((Console.WindowWidth - buyOrSell2.Length) / 2, 7);
                Console.WriteLine(buyOrSell2);

                if (finished != true)
                {
                    (finished, buyOrSell) = ListNavigation.scrollList(buySell, 9, finished);
                }

                int toBuy;
                if ((NewPlayer.wallet / productPrices [selectedGood]) > (NewShip.maxInventory - NewShip.currentInventory))
                {
                    toBuy = NewShip.maxInventory - NewShip.currentInventory;
                }
                else
                {
                    toBuy = ((int)NewPlayer.wallet / (int)productPrices [selectedGood]);
                }
                int toSell = Products.productList[selectedGood].onHand;
                if (finished != true)
                {
                    do
                    {
                        Console.Clear();
                        UserMenu(CurrentPlanet);
                        Console.ForegroundColor = ConsoleColor.DarkGreen;
                        string howMuch1 = $"So you'd like to {buySell[buyOrSell]} {Products.productList[selectedGood].unit} for #{productPrices[selectedGood]}?";

                        Console.SetCursorPosition((Console.WindowWidth - howMuch1.Length) / 2, 6);
                        Console.WriteLine(howMuch1);

                        string controls = "Use the UP and DOWN arrow keys to change the quantity | ENTER to confirm.";
                        Console.SetCursorPosition((Console.WindowWidth - controls.Length) / 2, 8);
                        Console.WriteLine(controls);

                        if (buyOrSell == 0)
                        {
                            Console.SetCursorPosition(0, 10);
                            Console.Write("Buy ");
                            Console.ForegroundColor = ConsoleColor.White;
                            Console.BackgroundColor = ConsoleColor.DarkGreen;
                            Console.Write(toBuy);
                            Console.ResetColor();
                            Console.ForegroundColor = ConsoleColor.DarkGreen;
                            Console.Write($" {Products.productList[selectedGood].unit} for ");
                            Console.ForegroundColor = ConsoleColor.White;
                            Console.BackgroundColor = ConsoleColor.DarkGreen;
                            Console.Write($"#{toBuy * productPrices[selectedGood]}");
                            Console.ResetColor();
                            Console.ForegroundColor = ConsoleColor.DarkGreen;
                            Console.Write("?");
                        }
                        else
                        {
                            if (Products.productList[selectedGood].onHand == 0)
                            {
                                Console.SetCursorPosition(0, 10);
                                Console.Write($"You have no {Products.productList[selectedGood].unit} to sell.");
                                finished = true;
                            }
                            else
                            {
                                Console.SetCursorPosition(0, 10);
                                Console.Write("Sell ");
                                Console.ForegroundColor = ConsoleColor.White;
                                Console.BackgroundColor = ConsoleColor.DarkGreen;
                                Console.Write(toSell);
                                Console.ResetColor();
                                Console.ForegroundColor = ConsoleColor.DarkGreen;
                                Console.Write($" {Products.productList[selectedGood].unit} for ");
                                Console.ForegroundColor = ConsoleColor.White;
                                Console.BackgroundColor = ConsoleColor.DarkGreen;
                                Console.Write($"#{toSell * productPrices[selectedGood]}");
                                Console.ResetColor();
                                Console.ForegroundColor = ConsoleColor.DarkGreen;
                                Console.Write("?");
                            }
                        }
                        if (finished != true)
                        {
                            cki = Console.ReadKey(true);
                            switch (cki.Key)
                            {
                            case ConsoleKey.DownArrow:
                                if (buyOrSell == 0)
                                {
                                    if (toBuy > 0)
                                    {
                                        toBuy -= 1;
                                        break;
                                    }
                                    else
                                    {
                                        break;
                                    }
                                }
                                else
                                {
                                    if (toSell > 0)
                                    {
                                        toSell -= 1;
                                        break;
                                    }
                                    else
                                    {
                                        break;
                                    }
                                }

                            case ConsoleKey.UpArrow:
                                if (buyOrSell == 0)
                                {
                                    if (toBuy < (int)(NewPlayer.wallet / productPrices[selectedGood]))
                                    {
                                        toBuy += 1;
                                        break;
                                    }
                                    else
                                    {
                                        break;
                                    }
                                }
                                else
                                {
                                    if (toSell < Products.productList[selectedGood].onHand)
                                    {
                                        toSell += 1;
                                        break;
                                    }
                                    else
                                    {
                                        break;
                                    }
                                }

                            case ConsoleKey.Escape:
                                finished = true;
                                break;
                            }
                        }
                        else
                        {
                            cki = Console.ReadKey(true);
                            switch (cki.Key)
                            {
                            case ConsoleKey.Escape:
                                finished = true;
                                break;
                            }
                        }
                    } while (cki.Key != ConsoleKey.Enter && finished != true);
                }


                if (buyOrSell == 0 && finished != true)
                {
                    Actions.UpdateInventoryTotal();
                    if (Game.NewShip.maxInventory >= Game.NewShip.currentInventory + toBuy)
                    {
                        NewPlayer.wallet -= (productPrices[selectedGood] * toBuy);
                        Products.productList[selectedGood].onHand = Products.productList[selectedGood].onHand + toBuy;
                        finished = true;
                    }
                    else
                    {
                        Console.WriteLine("\nYou don't have enough space on your ship.");
                        Console.ReadKey();
                        finished = true;
                    }
                }
                else if (buyOrSell == 1 && finished != true)
                {
                    NewPlayer.wallet += (productPrices[selectedGood] * toSell);
                    Products.productList[selectedGood].onHand = Products.productList[selectedGood].onHand - toSell;
                    finished = true;
                }
                else
                {
                }
            }while (finished != true);
            Actions.UpdateInventoryTotal();
            Console.Clear();
            UserMenu(CurrentPlanet);
        }
示例#4
0
        public static void ShipUpgradesMenu(Planet CurrentPlanet)
        {
            int  selected = 0;
            bool finished = false;

            List <double> upgradePrices = new List <double>()
            {
                Math.Round(Actions.UpdateFuelPrice(CurrentPlanet), 2),
                Equations.UpgradeCost(NewShip.fuelFactor),
                Equations.UpgradeCost(NewShip.fuelEfficiencyFactor),
                Equations.UpgradeCost(NewShip.storageFactor),
                Equations.UpgradeCost(NewShip.warpFactor)
            };

            List <string> upgradeStrings = new List <string>()
            {
                $"Purchase Fuel: #{upgradePrices[0]}",
                $"Increase Fuel Capacity: #{upgradePrices[1]}",
                $"Increase Fuel Efficiency: #{upgradePrices[2]}",
                $"Increase Storage Capacity: #{upgradePrices[3]}",
                $"Increase Warp Factor: #{upgradePrices[4]}"
            };

            List <string> toBuyStrings = new List <string>()
            {
                "more fuel",
                "a larger fuel tank",
                "better fuel efficiency",
                "more inventory space",
                "a faster Warp Factor"
            };

            List <double> upgradeAdds = new List <double>()
            {
                0,
                250,
                10,
                10,
                1
            };

            Console.Clear();
            UserMenu(CurrentPlanet);

            Console.ForegroundColor = ConsoleColor.DarkGreen;
            string upgradeQuestion1 = "Use the UP and DOWN arrow keys to select a ship upgrade " +
                                      ", then press enter.";
            string upgradeQuestion2 = "Press ESC to cancel";

            Console.SetCursorPosition((Console.WindowWidth - upgradeQuestion1.Length) / 2, 6);
            Console.WriteLine(upgradeQuestion1);
            Console.SetCursorPosition((Console.WindowWidth - upgradeQuestion2.Length) / 2, 7);
            Console.WriteLine(upgradeQuestion2);

            (finished, selected) = ListNavigation.scrollList(upgradeStrings, 9, finished);

            int toBuy  = 1;
            int maxBuy = (int)(NewPlayer.wallet / upgradePrices[selected]);

            ConsoleKeyInfo cki;

            Console.TreatControlCAsInput = true;
            if (finished != true)
            {
                do
                {
                    Console.Clear();
                    UserMenu(CurrentPlanet);
                    Console.ForegroundColor = ConsoleColor.DarkGreen;
                    string howMuch1 = $"So you'd like to buy {toBuyStrings[selected]} for #{upgradePrices[selected]}?";

                    Console.SetCursorPosition((Console.WindowWidth - howMuch1.Length) / 2, 6);
                    Console.WriteLine(howMuch1);

                    if (selected == 0)
                    {
                        do
                        {
                            Console.SetCursorPosition(0, 10);
                            Console.Write("Buy ");
                            Console.ForegroundColor = ConsoleColor.White;
                            Console.BackgroundColor = ConsoleColor.DarkGreen;
                            Console.Write(toBuy);
                            Console.ResetColor();
                            Console.ForegroundColor = ConsoleColor.DarkGreen;
                            Console.Write($" Kerbal gallons of rocket fuel for ");
                            Console.ForegroundColor = ConsoleColor.White;
                            Console.BackgroundColor = ConsoleColor.DarkGreen;
                            Console.Write($"#{toBuy * upgradePrices[selected]}");
                            Console.ResetColor();
                            Console.ForegroundColor = ConsoleColor.DarkGreen;
                            Console.Write("?                                   ");
                            cki = Console.ReadKey(true);
                            switch (cki.Key)
                            {
                            case ConsoleKey.DownArrow:

                                if (toBuy > 0)
                                {
                                    toBuy -= 1;
                                    break;
                                }
                                else
                                {
                                    break;
                                }

                            case ConsoleKey.UpArrow:

                                if (toBuy < maxBuy)
                                {
                                    toBuy += 1;
                                    break;
                                }
                                else
                                {
                                    break;
                                }

                            case ConsoleKey.LeftArrow:

                                if (toBuy > 24)
                                {
                                    toBuy -= 25;
                                    break;
                                }
                                else
                                {
                                    break;
                                }

                            case ConsoleKey.RightArrow:

                                if (toBuy + 24 < maxBuy)
                                {
                                    toBuy += 25;
                                    break;
                                }
                                else
                                {
                                    break;
                                }

                            case ConsoleKey.Escape:
                                finished = true;
                                break;
                            }
                        } while (cki.Key != ConsoleKey.Enter);
                    }
                    else
                    {
                        if (finished != true && NewPlayer.wallet >= upgradePrices[selected])
                        {
                            toBuy             = 1;
                            NewPlayer.wallet -= (upgradePrices[selected] * toBuy);
                            if (selected == 1)
                            {
                                NewShip.maxFuel += upgradeAdds[selected];
                            }
                            else if (selected == 2)
                            {
                                NewShip.fuelPerLightYear -= NewShip.fuelPerLightYear / upgradeAdds[selected]; //reduces fuel/lightyear by 10%
                            }
                            else if (selected == 3)
                            {
                                NewShip.maxInventory += (int)upgradeAdds[selected];
                            }
                            else if (selected == 4)
                            {
                                NewShip.warpFactor += 1;
                            }
                            finished = true;
                        }
                        else
                        {
                            Console.SetCursorPosition(0, 10);
                            Console.WriteLine("You can not afford this upgrade. Keep trading.");
                            Console.ReadLine();
                            finished = true;
                        }
                    }

                    if (finished != true && selected == 0)
                    {
                        if ((Game.NewShip.currentFuel + toBuy) > Game.NewShip.maxFuel)
                        {
                            Console.WriteLine("\nYou can't store that much fuel.");
                            Console.ReadKey();
                            finished = true;
                        }
                        else
                        {
                            NewPlayer.wallet    -= (upgradePrices [selected] * toBuy);
                            NewShip.currentFuel += toBuy;
                            finished             = true;
                        }
                    }
                } while (finished != true);
            }
            Actions.UpdateInventoryTotal();
            Console.Clear();
            UserMenu(CurrentPlanet);
        }