Example #1
0
    public void GetSceneCharacters(int sceneId)
    {
        _databaseRef.Child(DB_NODE_CHARACTERS).GetValueAsync().ContinueWith(task =>
        {
            if (task.IsCompleted)
            {
                var data = JSONSerialization <CharacterData> .CreateDictionaryFromJSON(task.Result.GetRawJsonValue());

                if (GetCharactersEvent != null)
                {
                    GetCharactersEvent.Invoke(task.IsCompleted, data);
                }
            }
            else if (task.IsFaulted)
            {
            }
        });
    }
Example #2
0
    private void handleGetCharactersEvent(bool result, Dictionary <string, CharacterData> data)
    {
        DatabaseService.Instance.GetCharactersEvent -= handleGetCharactersEvent;

        var characters = new Dictionary <string, CharacterData>();

        foreach (var kvp in data)
        {
            var characterName = kvp.Key;
            var characterData = kvp.Value;

            if (!characterData.scenes.ContainsKey("scene_" + _selectedSceneData.id))
            {
                continue;
            }

            characters.Add(characterName, characterData);
        }

        if (GetCharactersEvent != null)
        {
            GetCharactersEvent.Invoke(result, characters);
        }
    }