Esempio n. 1
0
    void SelectThisFile()
    {
        SaveFileMenu parentMenu = GetComponentInParent <SaveFileMenu>();

        if (!parentMenu)
        {
            Debug.LogError("No load menu component found in heirarchy! can't load.");
            return;
        }

        parentMenu.SelectFile(avatar);
    }
Esempio n. 2
0
        static public void SaveFileHandler()
        {
            subDirs = Directory.GetFiles("Saves");
            SaveFileMenu.ShowMenu();

            /*
             * Console.Clear();
             * Console.WriteLine("Выберите название для файла сохранения (Образец: saveFile)");
             * foreach (string subDir in subDirs) Console.WriteLine(subDir);
             * savename = "Saves\\" + Console.ReadLine() + ".RPGSF" + RPG.VERSION;
             * if (isSaving) SaveProgress(false);
             */
        }
Esempio n. 3
0
        static public void SaveProgress(bool currentSave)
        {
            List <object> saveList = new List <object>
            {
                City.cityBank,
                LVL,
                XP,
                HP,
                Money,
                City.currentPlotState,
                questNum,
                City.wasInCity,
                MasteryPoints,
                towerLoc,
                Tower.mageName,
                Tower.wasIntroduced,
                gotAnarchy,
                ahShit,
                brokeOut,
                BHDweller,
            };

            foreach (Item it in Inventory)
            {
                saveList.Add(it.ID);
                saveList.Add(it.LVL);
            }
            ;

            foreach (Item it in Passive_Inventory)
            {
                saveList.Add(it.ID);
                saveList.Add(it.LVL);
            }
            ;

            if (!currentSave)
            {
                if (File.Exists(savename))
                {
                    Console.WriteLine("Данный файл существует. Перезаписать? 1 - Да, 2 - Нет, 3 - Загрузить этот файл");

                    switch (Console.ReadKey().Key)
                    {
                    case ConsoleKey.D1:
                    case ConsoleKey.NumPad1:
                        SaveProgress(true);
                        break;

                    case ConsoleKey.D2:
                    case ConsoleKey.NumPad2:
                        SaveFileHandler();
                        break;

                    case ConsoleKey.D3:
                    case ConsoleKey.NumPad3:
                        LoadProgress(true);
                        break;

                    default:
                        Console.WriteLine("Некорректный ввод");
                        SaveProgress(currentSave);
                        break;
                    }
                }
                else
                {
                    SaveProgress(true);
                }
            }
            else
            {
                try
                {
                    string str = "";

                    foreach (object obj in saveList)
                    {
                        str += obj + "\n";
                    }

                    using (StreamWriter sw = new StreamWriter(savename, false, Encoding.Default)) sw.Write(str);

                    Console.WriteLine("Файл сохранён.");
                }

                catch
                {
                    Console.WriteLine("Некорректный ввод");
                    SaveFileMenu.ShowMenu();
                }
            }
        }