Esempio n. 1
0
    public static void SetPlayNum(int num)
    {
        DatabaseReference reference = PlayerInformation.GetDatabaseReference()
                                      .Child("user")
                                      .Child(PlayerInformation.auth.CurrentUser.UserId)
                                      .Child("playNum");

        PlayNum playNum     = new PlayNum(num, GetTimestamp());
        string  jsonPlayNum = JsonUtility.ToJson(playNum);

        reference.SetRawJsonValueAsync(jsonPlayNum);
    }
Esempio n. 2
0
    public static void SetNewUserData()
    {
        string            userId    = PlayerInformation.auth.CurrentUser.UserId;
        DatabaseReference reference = PlayerInformation.GetDatabaseReference()
                                      .Child("user");

        reference.GetValueAsync().ContinueWith(task =>
        {
            if (task.IsCompleted)
            {
                DataSnapshot snapshot = task.Result;
                // New User
                if (!snapshot.Child(userId).Exists)
                {
                    Charge charge     = new Charge(GetTimestamp());
                    string jsonCharge = JsonUtility.ToJson(charge);

                    Custom custom     = new Custom(0, 0, 0);
                    string jsonCustom = JsonUtility.ToJson(custom);

                    SoulMoney soulMoney = new SoulMoney(0);
                    string jsonMoney    = JsonUtility.ToJson(soulMoney);

                    Score score      = new Score(0, GetTimestamp());
                    string jsonScore = JsonUtility.ToJson(score);

                    EasyScore easyScore  = new EasyScore(0, GetTimestamp());
                    string jsonEasyScore = JsonUtility.ToJson(easyScore);

                    PlayNum playNum    = new PlayNum(0, GetTimestamp());
                    string jsonPlayNum = JsonUtility.ToJson(playNum);

                    reference.Child(userId).Child("charge").Child("boat").Child("0").SetRawJsonValueAsync(jsonCharge);
                    reference.Child(userId).Child("charge").Child("face").Child("0").SetRawJsonValueAsync(jsonCharge);
                    reference.Child(userId).Child("charge").Child("wave").Child("0").SetRawJsonValueAsync(jsonCharge);
                    reference.Child(userId).Child("custom").SetRawJsonValueAsync(jsonCustom);
                    reference.Child(userId).Child("money").SetRawJsonValueAsync(jsonMoney);
                    reference.Child(userId).Child("score").SetRawJsonValueAsync(jsonScore);
                    reference.Child(userId).Child("easyScore").SetRawJsonValueAsync(jsonEasyScore);
                    reference.Child(userId).Child("playNum").SetRawJsonValueAsync(jsonPlayNum);
                }
            }
        });
    }