Beispiel #1
0
        private static void DoSettingsActions()
        {
            Printer.DrawSettings();

            ConsoleKeyInfo key;
            int            position = 0;
            int            prePosition;

            do
            {
                prePosition = position;

                key = Console.ReadKey(true);

                MoveCursorInSettingsMeny(ref position, key);

                if (prePosition != position)
                {
                    Console.SetCursorPosition(0, prePosition);
                    Printer.DrawSettringsItem(prePosition, false);

                    Console.SetCursorPosition(0, position);
                    Printer.DrawSettringsItem(position, true);
                }

                ChangeSetting(position, key);
            } while (key.Key != ConsoleKey.Escape);

            DataWorker.UpdateSettingsFile(DataWorker.SettingsSavePath);
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            Console.CursorVisible = false;
            DataWorker.ReadWordsFromFile(DataWorker.WordsDictionaryPath);
            DataWorker.ReadUserScoreFromFile(DataWorker.UserScoreSavePath);
            DataWorker.ReadSettingsFromFile(DataWorker.SettingsSavePath);

            //Главный цикл
            do
            {
                Printer.DrawMenu();
                KeyInteractions.DoMenuActions();
            } while (true);
        }
Beispiel #3
0
        public static void ActionsIfWin(Field field)
        {
            if (DataWorker.UserScoreDict.ContainsKey(Player.Name))
            {
                DataWorker.UserScoreDict[Player.Name] += Player.Score;
            }
            else
            {
                DataWorker.UserScoreDict.Add(Player.Name, Player.Score);
            }

            DataWorker.UpdateUsetScoreFile(DataWorker.UserScoreSavePath);
            if (field.IsLoaded)
            {
                DataWorker.DeleteSave(DataWorker.FieldSavePath);
                DataWorker.DeleteSave(DataWorker.PlayerSavePath);
            }
        }
Beispiel #4
0
        private static void SelectMenuItem(int position)
        {
            Console.Clear();

            if (position == 1)
            {
                GetUserName();

                Field field = new Field();
                field.CreateNewField(Settings.XSize, Settings.YSize, new WordsSet(DataWorker.WordsSet.AllWords));
                Player.CreateNewPlayer();
                DoGameActions(field);
            }
            if (position == 2)
            {
                if (DataWorker.IsSaveExist(DataWorker.FieldSavePath) && DataWorker.IsSaveExist(DataWorker.PlayerSavePath))
                {
                    Field field = DataWorker.LoadField(DataWorker.FieldSavePath);
                    Player.CreateNewPlayer();
                    DataWorker.LoadPlayer(DataWorker.PlayerSavePath);
                    DoGameActions(field);
                }
                else
                {
                    Printer.DrawPopupWindow("Нет сохранённых игр");
                    Console.ReadKey(true);
                }
            }
            if (position == 3)
            {
                Printer.DrawTableOfRecords();
                Console.ReadKey(true);
            }
            if (position == 4)
            {
                DoSettingsActions();
            }
            if (position == 5)
            {
                Environment.Exit(0);
            }
        }
Beispiel #5
0
        private static void IfEscapePressed(Field field, ConsoleKeyInfo key, ref bool isEnter, out bool isBreak)
        {
            isBreak = false;

            if (key.Key == ConsoleKey.Escape)
            {
                if (isEnter)
                {
                    AdditionalPrinterMetods.BrakeFilling(field);
                    Printer.DrawText(new string(' ', Console.WindowWidth - (field.XSize * 4 + 2)), Player.WordsList.Count);

                    isEnter = false;
                }
                else
                {
                    Printer.DrawPopupWindow("Вы уверены, что хотите выйти? (прогресс будет сохранён)");

                    key = Console.ReadKey(true);
                    if (key.Key == ConsoleKey.Enter || key.Key == ConsoleKey.Spacebar)
                    {
                        DataWorker.SaveField(field, DataWorker.FieldSavePath);
                        DataWorker.SavePlayer(DataWorker.PlayerSavePath);
                        isBreak = true;
                    }
                    else
                    {
                        Console.Clear();
                        Printer.DrawField(field);
                        Printer.DrawFieldItem(Player.X, Player.Y, ConsoleColor.DarkGray, ConsoleColor.White, field);
                        for (int i = 0; i < Player.WordsList.Count; i++)
                        {
                            Printer.DrawText(Player.WordsList[i], i);
                        }
                    }
                }
            }
        }