Exemplo n.º 1
0
        public void Play()
        {
            Console.WriteLine("Hello!");
            characters = new Character[2];

            //Read Files
            JsonSaver.LoadAbilityCatalog("swordofthewanderer/abilitycatalog.json");
            Console.WriteLine("loaded abilities");
            characters = JsonSaver.LoadCharacters("swordofthewanderer/playablecharacters.json");
            Console.WriteLine("loaded characters");

            Battle battle   = new Battle();
            Team   goodGuys = new Team(characters[0]);

            Console.WriteLine("Created Team: " + goodGuys.Members[0]);
            Team badGuys = new Team(characters[1]);

            Console.WriteLine("Created Team: " + badGuys.Members[0]);

            battle.AddTeam(goodGuys);
            battle.AddTeam(badGuys);
            battle.SortTurnTemp();
            while (characters[0].Stats.Health.Current > 0 &&
                   characters[1].Stats.Health.Current > 0)
            {
                Console.WriteLine("Current Character: " + battle.CurrentCharacter);
                TakeTurn(battle.CurrentCharacter, battle.NextCharacter());
                Console.WriteLine("Stats Now:\n" + characters[0] + "\n" + characters[1]);
            }
            Console.WriteLine("Game Over");
        }
Exemplo n.º 2
0
 public void SaveAction()
 {
     foreach (var data in _saveDataList)
     {
         JsonSaver.SaveAction <DBData>(data.Value, data.Key);
     }
 }
Exemplo n.º 3
0
 public void LoadAction()
 {
     foreach (var db in _variableDbList)
     {
         _saveDataList[db.name] = JsonSaver.LoadAction_list <DBData>(db.name);
     }
     SetMemberSet();
 }
Exemplo n.º 4
0
    void Loader()
    {
        string loadedWorld   = JsonSaver.Load("");
        int    dataSeparator = loadedWorld.IndexOf("+", 0);
        string mapData       = loadedWorld.Substring(0, dataSeparator);
        string characterData = loadedWorld.Substring(dataSeparator, loadedWorld.Length - dataSeparator);

        World.LoadFromString(mapData);
    }
Exemplo n.º 5
0
        public static async Task <IDataPortal> CreateLocalDataPortal()
        {
            var jsonImporter = JsonDataImporter.CreateJsonDataImporter();
            var jsonSaver    = JsonSaver.CreateJsonSaver();

            await Task.WhenAll(jsonImporter, jsonSaver);

            return(new LocalDataPortal(jsonImporter.Result, jsonSaver.Result));
        }
    protected void SaveJson(ref string FileName, string title, Entry entry, string data)
    {
        JsonSaver.Title = title;

        JsonSaver.SelectFilename(FileName);

        string directory;

        // Add most recent directory
        if (!string.IsNullOrEmpty(JsonSaver.Filename))
        {
            directory = System.IO.Path.GetDirectoryName(JsonSaver.Filename);

            if (Directory.Exists(directory))
            {
                JsonSaver.SetCurrentFolder(directory);
            }
        }

        if (JsonSaver.Run() == (int)ResponseType.Accept)
        {
            if (!string.IsNullOrEmpty(JsonSaver.Filename))
            {
                FileName = JsonSaver.Filename;

                directory = GetDirectory(FileName);

                var ext = JsonSaver.Filter.Name;

                FileName = String.Format("{0}.{1}", GetBaseFileName(FileName), ext);

                if (!string.IsNullOrEmpty(data))
                {
                    var fullpath = String.Format("{0}/{1}", directory, FileName);

                    try
                    {
                        using (var file = new StreamWriter(fullpath, false))
                        {
                            file.Write(data);
                        }

                        FileName = fullpath;

                        entry.Text = FileName;
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine("Error saving {0}: {1}", FileName, ex.Message);
                    }
                }
            }
        }

        JsonSaver.Hide();
    }
Exemplo n.º 7
0
    public void SaveJson(T dataObject, bool overrideExisting)
    {
        Debug.Log(this + " Create Json");
        JsonSaver.SaveAsJson(
            dataObject,
            DataObjectPath(dataObject),
            overrideExisting);

        OnSaveCompleted?.Invoke(dataObject);
    }
Exemplo n.º 8
0
 public void LoadAction(bool actBridge = true)
 {
     foreach (var db in _variableDbList)
     {
         _saveDataList[db.name] = JsonSaver.LoadAction_list <SavedDBData>(db.name);
     }
     if (actBridge)
     {
         WaitAction.Instance.CoalWaitAction(() => Bridge_data2mono(), 0.5f);
     }
 }
Exemplo n.º 9
0
 public void SaveAction(bool actBridge = true)
 {
     if (actBridge)
     {
         Bridge_mono2data();
     }
     foreach (var data in _saveDataList)
     {
         JsonSaver.SaveAction <SavedDBData>(data.Value, data.Key);
     }
     Debug.Log("saved");
 }
Exemplo n.º 10
0
        public static void TestAbilityCatalogSave()
        {
            Ability a1 = new Ability("1", "one", 1, Element.Air);
            Ability a2 = new Ability("2", "two", 1, Element.Fire);
            Ability a3 = new Ability("3", "three", 1, Element.Earth);
            Ability a4 = new Ability("4", "four", 1, Element.Water);

            AbilityCatalog.Add(a1);
            AbilityCatalog.Add(a2);
            AbilityCatalog.Add(a3);
            AbilityCatalog.Add(a4);

            JsonSaver.SaveAbilityCatalog("abilitycatalog.data");
            JsonSaver.LoadAbilityCatalog("abilitycatalog.data");
        }
Exemplo n.º 11
0
        public static void TestCharacterSave()
        {
            Character c1 = new Character("Jerma");
            Character c2 = new Character("Steven");

            c1.Abilities.Add("1");
            c2.Abilities.Add("2");
            c1.Stats.Health = new StatValues(10, 10);
            Character[] cList = { c1, c2 };

            JsonSaver.SaveCharacters(cList, "characters.data");
            cList = JsonSaver.LoadCharacters("characters.data");
            Console.WriteLine("SECOND SAAAAAAAAAAAAVE");
            JsonSaver.SaveCharacters(cList, "characters.data");
        }
Exemplo n.º 12
0
    private void Awake()
    {
        if (_instance != null)
        {
            Destroy(gameObject);
        }
        else
        {
            _instance = this;
        }

        // Debug.Log();
        m_saveData  = new SaveData();  //external object can't access data directly.
        m_Jsonsaver = new JsonSaver(); // we can generate new jsonSaver with the new keyword to create new instance. we can do that becaus ewe don't inherited from monobehavior. just plain c# obejct.
                                       //each piece data from save data, needs a corresponding property here. that's we need to add properties for the datas, as if setting menus see them.
    }
Exemplo n.º 13
0
    public void LoadVolumeData()
    {
        try
        {
            serializedData = JsonSaver.GetFile <AudioData>();

            audioMixer.SetFloat("MasterVolume", serializedData.masterVolume);
            audioMixer.SetFloat("MusicVolume", serializedData.musicVolume);
            audioMixer.SetFloat("EffectsVolume", serializedData.effectsVolume);
        }
        catch (FileNotFoundException ex)      //in case of error
        {
            serializedData = new AudioData(); //create the object again
            SaveVolumeData();                 //save data, creating the file
        }
    }
Exemplo n.º 14
0
    private void Awake()
    {
        if (Instance == null)
        {
            Instance = this;
        }
        else if (Instance != this)
        {
            Destroy(gameObject);
            return;
        }

        //DontDestroyOnLoad(gameObject);

        _saveData  = new SaveData();
        _jsonSaver = new JsonSaver();
    }
Exemplo n.º 15
0
    public void SaveVolumeData()
    {
        float volume;

        //we take the actual volume value (for each variable on the mixer) on "volume"
        //float to save it on our serializable class so we can save it later on our json

        audioMixer.GetFloat("MasterVolume", out volume);
        serializedData.masterVolume = volume;

        audioMixer.GetFloat("MusicVolume", out volume);
        serializedData.musicVolume = volume;

        audioMixer.GetFloat("EffectsVolume", out volume);
        serializedData.effectsVolume = volume;

        JsonSaver.SaveObject(serializedData);
    }
Exemplo n.º 16
0
    /// <summary>
    /// Set up persistence
    /// </summary>
    protected void LoadData()
    {
#if UNITY_EDITOR
        m_DataSaver = new JsonSaver <TDataStore>(k_SavedGameFile);
#else
        m_DataSaver = new EncryptedJsonSaver <TDataStore>(k_SavedGameFile);
#endif
        try
        {
            if (!m_DataSaver.Load(out m_DataStore))
            {
                m_DataStore = new TDataStore();
                SaveData();
            }
        }
        catch (Exception)
        {
            Debug.Log("Failed to load data, resetting");
            m_DataStore = new TDataStore();
            SaveData();
        }
    }
Exemplo n.º 17
0
        static void Main(string[] args)
        {
            NeuralNet net;

            net = JsonSaver.ReadFromJsonFile <NeuralNet>("C:\\dev\\Projects\\Tests\\SentenceSplitterTest\\SentenceSplitterTest\\Store\\NetStore.json");
            if (net == null)
            {
                net = new NeuralNet();
                for (var i = 0; i < 100; i++)
                {
                    net.AddHiddenNeuron(new WorkingNeuron());
                }
                JsonSaver.WriteToJsonFile("C:\\dev\\Projects\\Tests\\SentenceSplitterTest\\SentenceSplitterTest\\Store\\NetStore.json", net);
            }

            while (true)
            {
                Console.Write("Gib deinen Text ein.");
                var lines = Console.ReadLine() ?? "";
                Console.WriteLine(string.Concat(Enumerable.Repeat("|", lines.Length)));
                var charArr = string.Join("\n", lines);
                net.CalculateValues(Encoding.ASCII.GetBytes(charArr));
            }
        }
Exemplo n.º 18
0
 public AppViewModel(IDirectoryDialogViewModel directoryDialogRomsPathModel,
     IDirectoryDialogViewModel directoryDialogOutputPathModel)
 {
     _settings = new JsonLoader<Settings>(PathMap.DataPath).Load() ?? new Settings();
     _settingsSaver = new JsonSaver<Settings>(PathMap.DataPath);
     _directoryDialogRomsPathModel = directoryDialogRomsPathModel;
     _directoryDialogOutputPathModel = directoryDialogOutputPathModel;
 }