コード例 #1
0
ファイル: Input.cs プロジェクト: TomasVoskovec/LittleFighter
        public string GetElementName()
        {
            bool   nameSelection = true;
            string elementName   = "";

            while (nameSelection)
            {
                nameSelection = false;

                Console.Write("Element name: ");
                elementName = Console.ReadLine();

                Console.Clear();

                List <Element> loadedElements = new JsonFileManager().LoadElements("../../../../AppData/Elements.json");

                if (loadedElements != null && loadedElements.Any())
                {
                    foreach (Element element in new JsonFileManager().LoadElements("../../../../AppData/Elements.json"))
                    {
                        if (element.Name == elementName)
                        {
                            nameSelection = true;
                            Console.WriteLine("This element already exist");
                        }
                    }
                }
            }

            return(elementName);
        }