예제 #1
0
    private void ChatCharacters_ChildAdded(object sender, ChildChangedEventArgs e)
    {
        var parent = e.Snapshot.Key;

        if (!_chatCharacterDataDict.ContainsKey(parent))
        {
            _chatCharacterDataDict.Add(parent, new List <ChatCharacterData>());
        }

        var data = JSONSerialization <ChatCharacterData> .CreateDictionaryFromJSON(e.Snapshot.GetRawJsonValue());

        foreach (var character in data)
        {
            character.Value.Key = character.Key;
            _chatCharacterDataDict[parent].Add(character.Value);
        }

        foreach (var character in _chatCharacterDataDict[parent])
        {
            _databaseRef.Child(DB_NODE_CHARACTERS).Child(character.CharacterId).GetValueAsync().ContinueWith(innerTask =>
            {
                character.Data = JSONSerialization <CharacterData> .CreateFromJSON(innerTask.Result.GetRawJsonValue());
            });
        }
    }
예제 #2
0
 public void GetAvailableScenes()
 {
     _databaseRef.Child(DB_NODE_SCENES).OrderByKey().GetValueAsync().ContinueWith(task =>
     {
         if (task.IsCompleted)
         {
             var data = JSONSerialization <SceneData> .CreateDictionaryFromJSON(task.Result.GetRawJsonValue());
             if (GetScenesEvent != null)
             {
                 GetScenesEvent.Invoke(task.IsCompleted, data);
             }
         }
         else if (task.IsFaulted)
         {
         }
     });
 }
예제 #3
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)
            {
            }
        });
    }