Esempio n. 1
0
        public void ChoseMenuTest()
        {
            Element[,] elements = new Element[5, 5];
            for (int i = 0; i < elements.GetLength(0); i++)
            {
                for (int j = 0; j < elements.GetLongLength(1); j++)
                {
                    elements[i, j] = new Element(Guid.NewGuid().ToString());
                }
            }
            ChoseMenu TestMenu = new ChoseMenu(elements);
            int       k        = 0;

            for (int i = 0; i < elements.GetLength(0); i++)
            {
                for (int j = 0; j < elements.GetLongLength(1); j++)
                {
                    if (elements[i, j].IsSelected)
                    {
                        k++;
                    }
                    if (k > 1)
                    {
                        Assert.Fail();
                    }
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Создание меню выбора с кнопками да и нет.
        /// </summary>
        public void CreateYesNoMenu()
        {
            Element[,] elements =
            { {
                  new Element("Yes"),
                  new Element("No")
              } };
            ChoseMenu Menu = new ChoseMenu(elements);

            Menu.MenuButtonSet();
            switch (Menu.ChosenElement.Text)
            {
            case "Yes":
                Registration();
                break;

            case "No":
                break;
            }
            Console.Clear();
            Authorization();
        }
Esempio n. 3
0
        public static void OptionMenu()
        {
            Element[,] MenuButton = new Element[, ]
            {
                {
                    new Element(" Цвет корабля"),
                    new Element(" "),
                    new Element(" Белый "),
                    new Element(" Зеленый "),
                    new Element(" Синий "),
                    new Element(" Красный ")
                }
            };
            ChoseMenu choseMenu = new ChoseMenu(MenuButton);

            choseMenu.Elements[0, 0].IsSelected = false;
            choseMenu.Elements[0, 2].IsSelected = true;
            choseMenu.IndexX = 2;
            choseMenu.MenuButtonSet();
            if (choseMenu.Elements[0, 2].IsSelected == true)
            {
                PlayInterface.ShipColor = ConsoleColor.White;
            }
            if (choseMenu.Elements[0, 3].IsSelected == true)
            {
                PlayInterface.ShipColor = ConsoleColor.Green;
            }
            if (choseMenu.Elements[0, 4].IsSelected == true)
            {
                PlayInterface.ShipColor = ConsoleColor.Blue;
            }
            if (choseMenu.Elements[0, 5].IsSelected == true)
            {
                PlayInterface.ShipColor = ConsoleColor.Red;
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Вызов инвентаря (по умолчанию кл E).
        /// </summary>
        /// <param name="A"> Объект вызова. </param>
        private static void CallInventory(PlayInterface A)
        {
            Console.Clear();
            ItemsCollections       = LoadData();
            Element[,] ListElement = new Element[0, 0];
            foreach (var s in ItemsCollections)
            {
                ListElement = TheLastElement(ListElement, s);
            }
            Element[,] AddListElement = new Element[ListElement.GetLength(0) + 2, ListElement.GetLength(1)];
            for (int i = 0; i < ListElement.GetLength(0); i++)
            {
                for (int j = 0; j < ListElement.GetLength(1); j++)
                {
                    AddListElement[i, j] = ListElement[i, j];
                }
            }
            for (int i = 0; i < ListElement.GetLength(1) - 1; i++)
            {
                AddListElement[ListElement.GetLength(0), i] = new Element(" ");
            }
            AddListElement[ListElement.GetLength(0), ListElement.GetLength(1) - 1] = new Element("Выход");

            AddListElement[ListElement.GetLength(0) + 1, 0] = new Element("Balance");
            AddListElement[ListElement.GetLength(0) + 1, 1] = new Element(UserController.ReturnCurentUser(UserController.CurentUserName).Balance.ToString());
            for (int i = 2; i < ListElement.GetLength(1); i++)
            {
                AddListElement[ListElement.GetLength(0) + 1, i] = new Element(" ");
            }
            ListElement = AddListElement;
            ChoseMenu ListOfItems = new ChoseMenu(ListElement)
            {
                IndexX = Item.Number - 1
            };

            ListOfItems.Elements[0, 0].IsSelected = false;
            ListOfItems.Elements[0, Item.Number - 1].IsSelected = true;
            ListOfItems.MenuButtonSet();
            while (ListOfItems.IndexY < ItemsCollections.Count)
            {
                if (ListOfItems.IndexX == Item.Number - 1)
                {
                    if (UserController.ReturnCurentUser(UserController.CurentUserName).Count[ListOfItems.IndexY] > 0)
                    {
                        UserController.ReturnCurentUser(UserController.CurentUserName).Count[ListOfItems.IndexY]--;
                        ListOfItems.Elements[ListOfItems.IndexY, 0].Text = (int.Parse(ListOfItems.Elements[ListOfItems.IndexY, 0].Text) - 1).ToString();
                        UserController.ReturnCurentUser(UserController.CurentUserName).Balance += int.Parse(ListOfItems.Elements[ListOfItems.IndexY, 3].Text);
                    }
                }
                else
                {
                    if (UserController.ReturnCurentUser(UserController.CurentUserName).Balance >= int.Parse(ListOfItems.Elements[ListOfItems.IndexY, 3].Text))
                    {
                        UserController.ReturnCurentUser(UserController.CurentUserName).Count[ListOfItems.IndexY]++;
                        ListOfItems.Elements[ListOfItems.IndexY, 0].Text = (int.Parse(ListOfItems.Elements[ListOfItems.IndexY, 0].Text) + 1).ToString();
                        UserController.ReturnCurentUser(UserController.CurentUserName).Balance -= int.Parse(ListOfItems.Elements[ListOfItems.IndexY, 3].Text);
                    }
                }
                UserController.SaveData();
                ListOfItems.Elements[ListElement.GetLength(0) - 1, 1] = new Element(UserController.ReturnCurentUser(UserController.CurentUserName).Balance.ToString());
                ListOfItems.MenuButtonSet();
            }
            A.CreateBorder();
            A.Draw();
        }
Esempio n. 5
0
        //Проблема с паролями.
        static void Main(string[] args)
        {
            Console.Title = "Первая игра";
            UserController.Authorization();
            string name = UserController.CurentUserName;

            Console.Clear();
            User CurentUser = UserController.ReturnCurentUser(name);

            Console.WriteLine("Авторизация прошла успешно!");
            Console.WriteLine($"Вы вошли под логином {CurentUser.Login}");
            Console.WriteLine("Для продолжения нажмите любую клавишу...");
            Console.ReadKey();
            Console.Clear();
            while (true)
            {
                const string PlayButton       = "Играть.";
                const string StatisticsButton = "Статистика.";
                const string OptionButton     = "Настройки.";
                const string ExitButton       = "Выход.";
                Element[,] elements = new Element[, ]
                {
                    {
                        new Element(PlayButton)
                    },
                    {
                        new Element(StatisticsButton)
                    },
                    {
                        new Element(OptionButton)
                    },
                    {
                        new Element(ExitButton)
                    }
                };
                ChoseMenu MainMenu = new ChoseMenu(elements);
                MainMenu.MenuButtonSet();
                switch (MainMenu.ChosenElement.Text)
                {
                case PlayButton:
                    PlayInterface A = new PlayInterface();
                    A.CreateBorder();
                    A.PositionSet(50, 50);
                    GameController.KeyAssignment(A);
                    break;

                case StatisticsButton:
                    StaticsController.StaticList();
                    break;

                case OptionButton:
                    OptionController.OptionMenu();
                    break;

                case ExitButton:
                    Thread.CurrentThread.Abort();
                    Thread.Sleep(1000);
                    break;
                }
                Console.Clear();
            }
        }