Beispiel #1
0
        public void Button(string chanceButton, string safeButton)
        {
            int index = 0;

            string[] menu = new string[] { chanceButton, safeButton };

            ConsoleKeyInfo ckey;
            string         selection;

            Console.CursorVisible = false;
            do
            {
                for (int i = 0; i < menu.Length; i++)
                {
                    if (i == index)
                    {
                        Console.BackgroundColor = ConsoleColor.Gray;
                        Console.ForegroundColor = ConsoleColor.Black;

                        Console.WriteLine(menu[i]);
                    }
                    else
                    {
                        Console.WriteLine(menu[i]);
                    }
                    Console.ResetColor();
                    selection = menu[i];
                }

                ckey = Console.ReadKey();

                if (ckey.Key == ConsoleKey.DownArrow)
                {
                    if (index == menu.Length - 1)
                    {
                        index = 0;
                        // Console.BackgroundColor = ConsoleColor.Blue;
                    }
                    else
                    {
                        index++;
                    }
                }
                if (ckey.Key == ConsoleKey.UpArrow)
                {
                    if (index == 0)
                    {
                        index = menu.Length - 1;
                    }
                    else
                    {
                        index--;
                    }
                }
                if (ckey.Key == ConsoleKey.Enter && menu[index] == safeButton)
                {
                    Safe safe = new Safe();
                    safe.CallSafe(safeButton); // Goes to Safe class and calls the dialogue for the safe adventure
                }
                else if (ckey.Key == ConsoleKey.Enter && menu[index] == chanceButton)
                {
                    //for(int i = 0; i < 3; i++) // Commented out so the screen size remains the same throughout the entire game.!!!!!!!!!!!!!!!!!!!!John
                    //{
                    //    Console.SetWindowSize(1,1);
                    //    Thread.Sleep(50);
                    //    Console.SetWindowSize(100, 25);
                    //}
                    Chance chance = new Chance();
                    Planet dice   = new Planet();
                    // dice.RngDice();
                    chance.CallChance(chanceButton);
                }


                ClearLine();
            } while (ckey.Key != ConsoleKey.Escape);
        }
Beispiel #2
0
        public void MerchantMenu(string plumbusSelect, string goldSelect, string ammoSelect, string weaponsSelect, string waterSelect, int menuItems)
        {
            Planet planet = new Planet();
            Story  story  = new Story();

            int index = 0;

            string[] menu = new string[] { plumbusSelect, goldSelect, ammoSelect, weaponsSelect, waterSelect };

            ConsoleKeyInfo ckey;
            string         selection;

            Console.CursorVisible = false;
            do
            {
                for (int i = 0; i < menuItems; i++)
                {
                    if (i == index)
                    {
                        Console.BackgroundColor = ConsoleColor.Gray;
                        Console.ForegroundColor = ConsoleColor.Black;

                        Console.WriteLine(menu[i]);
                    }

                    else
                    {
                        Console.WriteLine(menu[i]);
                    }
                    Console.ResetColor();
                    selection = menu[i];
                }

                ckey = Console.ReadKey();

                if (ckey.Key == ConsoleKey.DownArrow)
                {
                    if (index == menu.Length - 1)
                    {
                        index = 0;

                        // Console.BackgroundColor = ConsoleColor.Blue;
                    }
                    else
                    {
                        index++;
                    }
                }

                if (ckey.Key == ConsoleKey.UpArrow)
                {
                    if (index == 0)
                    {
                        index = menu.Length - 1;
                    }
                    else
                    {
                        index--;
                    }
                }
                if (ckey.Key == ConsoleKey.Enter && menu[index] == "Plumbus")
                {
                    Inventory(0);
                }
                else if (ckey.Key == ConsoleKey.Enter && menu[index] == "Gold")
                {
                    Inventory(0);
                }
                else if (ckey.Key == ConsoleKey.Enter && menu[index] == "Ammo")
                {
                    Inventory(0);
                }
                else if (ckey.Key == ConsoleKey.Enter && menu[index] == "Weapons")
                {
                    Inventory(0);
                }
                else if (ckey.Key == ConsoleKey.Enter && menu[index] == "Water")
                {
                    Inventory(0);
                }
                else if (ckey.Key == ConsoleKey.Backspace)
                {
                    ;
                }
                choice.ClearLine();
            } while (ckey.Key != ConsoleKey.Escape);
        }