Exemplo n.º 1
0
    public void OnNotify(Firebase.Database.DataSnapshot dataSnapShot)
    {
        try {
            Dictionary <string, System.Object> rpcReceive = (Dictionary <string, System.Object>)dataSnapShot.Value;
            if (rpcReceive.ContainsKey(MyConst.RPC_DATA_PARAM))
            {
                bool userHome = (bool)rpcReceive [MyConst.RPC_DATA_USERHOME];

                Dictionary <string, System.Object> param = (Dictionary <string, System.Object>)rpcReceive [MyConst.RPC_DATA_PARAM];
                if (param.ContainsKey(MyConst.RPC_DATA_ATTACK))
                {
                    AttackModel attack = JsonUtility.FromJson <AttackModel> (param [MyConst.RPC_DATA_ATTACK].ToString());

                    if (userHome.Equals(GameManager.isHost))
                    {
                        playerAttack = attack;
                    }
                    else
                    {
                        enemyAttack = attack;
                    }
                }
            }
        } catch (System.Exception e) {
            //do something later
        }
    }
Exemplo n.º 2
0
    public void OnNotify(Firebase.Database.DataSnapshot dataSnapShot)
    {
        try {
            Dictionary <string, System.Object> rpcReceive = (Dictionary <string, System.Object>)dataSnapShot.Value;
            if (rpcReceive.ContainsKey(MyConst.RPC_DATA_PARAM))
            {
                bool userHome = (bool)rpcReceive [MyConst.RPC_DATA_USERHOME];

                Dictionary <string, System.Object> param = (Dictionary <string, System.Object>)rpcReceive [MyConst.RPC_DATA_PARAM];
                if (param.ContainsKey(MyConst.RPC_DATA_ANSWER_INDICATOR))
                {
                    if (userHome.Equals(GameManager.isHost))
                    {
                        playerAnswerCounter++;
                        playerAnswerText.text = playerAnswerCounter.ToString();
                    }
                    else
                    {
                        enemyAnswerCounter++;
                        enemyAnswerText.text = enemyAnswerCounter.ToString();
                    }
                }
            }
        } catch (System.Exception e) {
            //do something with exception in future
        }
    }
Exemplo n.º 3
0
 //Do something when receives rpc from facade
 public void OnNotify(Firebase.Database.DataSnapshot dataSnapShot)
 {
     //TEMPORARY SOLUTION FOR PLAYER DETAILS
     if (dataSnapShot.Key.ToString().Equals("Home"))
     {
         Debug.Log("hi");
         if (GameData.Instance.isHost)
         {
             BattleView.Instance.SetStateParam(dataSnapShot, true);
         }
         else
         {
             BattleView.Instance.SetStateParam(dataSnapShot, false);
         }
     }
     //TEMPORARY SOLUTION FOR PLAYER DETAILS
     if (dataSnapShot.Key.ToString().Equals("Visitor"))
     {
         isMatchMakeSuccess = true;
         onSuccessMatchMake(true);
         if (GameData.Instance.isHost)
         {
             BattleView.Instance.SetStateParam(dataSnapShot, false);
         }
         else
         {
             BattleView.Instance.SetStateParam(dataSnapShot, true);
         }
         Debug.Log("Matching Success!");
     }
 }
Exemplo n.º 4
0
    public void OnNotify(Firebase.Database.DataSnapshot dataSnapShot)
    {
        try {
            Dictionary <string, System.Object> rpcReceive = (Dictionary <string, System.Object>)dataSnapShot.Value;
            if (rpcReceive.ContainsKey("param"))
            {
                bool userHome = (bool)rpcReceive ["userHome"];
                GameData.Instance.attackerBool = userHome;

                Dictionary <string, System.Object> param = (Dictionary <string, System.Object>)rpcReceive ["param"];
                if (param.ContainsKey("SkillParam"))
                {
                    string stringParam = param ["SkillParam"].ToString();
                    if (GameData.Instance.attackerBool.Equals(GameData.Instance.isHost))
                    {
                        SetPlayerSkillParameter(stringParam);
                    }
                    else
                    {
                        SetEnemySkillParameter(stringParam);
                    }
                }
                if (param.ContainsKey("SkillName"))
                {
                    string stringParam = param ["SkillName"].ToString();
                    CheckSkillName(stringParam);
                }
            }
        } catch (System.Exception e) {
            //do something with exception in future
        }
    }
Exemplo n.º 5
0
 //Send notifications if something has happened
 public static void NotifyQuery(Firebase.Database.DataSnapshot dataSnapshot)
 {
     for (int i = 0; i < observers.Count; i++)
     {
         //Notify all observers even though some may not be interested in what has happened
         //Each observer should check if it is interested in this event
         observers [i].OnNotifyQuery(dataSnapshot);
     }
 }
 void HandleValueChanged(object sender, Firebase.Database.ValueChangedEventArgs args)
 {
     if (args.DatabaseError != null)
     {
         Debug.LogError(args.DatabaseError.Message);
         return;
     }
     mDataSnapshot = args.Snapshot;
 }
Exemplo n.º 7
0
 public void OnNotify(Firebase.Database.DataSnapshot dataSnapShot)
 {
     try {
         Dictionary <string, System.Object> rpcReceive = (Dictionary <string, System.Object>)dataSnapShot.Value;
         ReceiveBattleStatus(rpcReceive);
     } catch (System.Exception e) {
         //do something with exception
     }
 }
Exemplo n.º 8
0
    public void CheckUserDB(string userId, string email)
    {
        mDatabaseRef.Child("users").GetValueAsync().ContinueWith(task => {
            if (task.IsFaulted)
            {
                Debug.Log(task.Exception);
                Debug.Log("failed");
            }
            else if (task.IsCompleted)
            {
                Firebase.Database.DataSnapshot snapshot = task.Result;
                bool idExist = false;
                Debug.Log("CheckUserDB");
                TextLog.text = "CheckUserDB";
                foreach (var childSnapshot in snapshot.Children)
                {
                    string uid = childSnapshot.Child("userId").Value.ToString();
                    Debug.Log(uid);
                    if (uid == userId)
                    {
                        TextLog.text = "ID 존재함";
                        idExist      = true;
                    }
                    else
                    {
                        // InsertUserDB(userId, email);
                    }
                }
                if (idExist == false)
                {
                    InsertUserDB(userId, email);
                }

                // TextLog.text = "snapshot.ChildrenCount";
                // Firebase.Database.DataSnapshot snapshot = task.Result;

                // TextLog.text = snapshot.ToString();
                // // TextLog.text = "snapshot.ChildrenCount2";
                // int ct = 0;

                // if(snapshot.HasChildren){
                //  TextLog.text = "ID 존재함";
                // }else{
                //  TextLog.text = "No Has Child";
                //  InsertUserDB(userId, email);
                // }
                // TextLog.text = ct.ToString();
                // if(ct == 0){
                //  // TextLog.text = "snapshot.ChildrenCount  " + snapshot.ChildrenCount;

                // }else{

                // }
            }
        });
    }
Exemplo n.º 9
0
    public void SetStateParam(Firebase.Database.DataSnapshot dataSnapShot, bool isHome)
    {
        Dictionary <string, System.Object> rpcReceive = (Dictionary <string, System.Object>)dataSnapShot.Value;

        if (rpcReceive.ContainsKey("param"))
        {
            Dictionary <string, System.Object> param = (Dictionary <string, System.Object>)rpcReceive ["param"];
            ReceiveInitialState(param, isHome);
        }
    }
Exemplo n.º 10
0
    private static void SetStateParam(Firebase.Database.DataSnapshot dataSnapShot, bool isPlayer)
    {
        Dictionary <string, System.Object> rpcReceive = (Dictionary <string, System.Object>)dataSnapShot.Value;

        if (rpcReceive.ContainsKey(MyConst.RPC_DATA_PARAM))
        {
            Dictionary <string, System.Object> param = (Dictionary <string, System.Object>)rpcReceive [MyConst.RPC_DATA_PARAM];

            ReceiveInitialState(param, isPlayer);
        }
    }
Exemplo n.º 11
0
    public void levelComp(Firebase.Database.DataSnapshot snapShot)
    {
        var result = JsonUtility.FromJson <PlayerData>(snapShot.GetRawJsonValue());

        data = result;


        //Actualizese();



        //
    }
Exemplo n.º 12
0
    void DownloadMyHandDB(Firebase.Database.DataSnapshot handSnap)
    {
        int handCnt = (int)handSnap.ChildrenCount;

        handCards.RemoveAll(x => true);
        for (int i = 0; i < handCnt; i++)
        {
            Firebase.Database.DataSnapshot cardRef
                = handSnap.Child(Card.dbName + i.ToString());
            int markNo = int.Parse(cardRef.Child("markNo").GetRawJsonValue());
            int value  = int.Parse(cardRef.Child("value").GetRawJsonValue());
            //Debug.Log(string.Format("{0}:{1}", markNo, value));
            handCards.Add(new Card(markNo, value));
        }
        //handCards.SyncCardObjects();
    }
Exemplo n.º 13
0
    public void OnNotify(Firebase.Database.DataSnapshot dataSnapShot)
    {
        Dictionary <string, System.Object> rpcReceive = (Dictionary <string, System.Object>)dataSnapShot.Value;

        if (rpcReceive.ContainsKey("param"))
        {
            bool userHome = (bool)rpcReceive ["userHome"];
            GameData.Instance.attackerBool = userHome;

            Dictionary <string, System.Object> param = (Dictionary <string, System.Object>)rpcReceive ["param"];
            if (param.ContainsKey("AnswerIndicator"))
            {
                string stringParam = param ["AnswerIndicator"].ToString();
                SetAnswerParameter(stringParam);
            }
        }
    }
    public void OnNotify(Firebase.Database.DataSnapshot dataSnapShot)
    {
        try {
            Dictionary <string, System.Object> rpcReceive = (Dictionary <string, System.Object>)dataSnapShot.Value;
            if (rpcReceive.ContainsKey(MyConst.RPC_DATA_PARAM))
            {
                bool userHome = (bool)rpcReceive [MyConst.RPC_DATA_USERHOME];

                Dictionary <string, System.Object> param = (Dictionary <string, System.Object>)rpcReceive [MyConst.RPC_DATA_PARAM];
                if (param.ContainsKey(MyConst.RPC_DATA_CHARACTER))
                {
                    CharacterModelList     characterList         = JsonUtility.FromJson <CharacterModelList> (param [MyConst.RPC_DATA_CHARACTER].ToString());
                    Queue <CharacterModel> characterReceiveQueue = new Queue <CharacterModel> ();

                    for (int i = 0; i < characterList.list.Count; i++)
                    {
                        if (characterList.list [i].iD != 0)
                        {
                            characterReceiveQueue.Enqueue(characterList.list [i]);
                        }
                    }


                    if (characterReceiveQueue.Count > 0)
                    {
                        if (userHome.Equals(GameManager.isHost))
                        {
                            playerCharacterQueue = characterReceiveQueue;
                        }
                        else
                        {
                            enemyCharacterQueue = characterReceiveQueue;
                        }
                    }

                    BattleManager.CountCharacters();
                }
            }
        } catch (System.Exception e) {
            //do something with exception in future
        }
    }
Exemplo n.º 15
0
    public void CategoryPush()
    {
        FirebaseDatabase.DefaultInstance.GetReference("furniture").GetValueAsync().ContinueWith(task => {
            if (task.IsFaulted)
            {
                Debug.Log("failed");
            }
            else if (task.IsCompleted)
            {
                Firebase.Database.DataSnapshot snapshot = task.Result;
                Debug.Log(snapshot.Value.ToString());
                Debug.Log(FurnitureText_1.text);
                FurnitureText_1.text = snapshot.Child("furniture_1").Child("furniture_name").Value.ToString();
                Debug.Log(FurnitureText_1.text);

                /*
                 * foreach (var childSnapshot in snapshot.Children)
                 * {
                 *  Debug.Log(FurnitureText_1.text);
                 *
                 *  FurnitureText_1.text = childSnapshot.Key.ToString() + "\n color : " +
                 *      childSnapshot.Child("color").Value.ToString() +
                 *      " texture : " +
                 *      childSnapshot.Child("texture").Value.ToString() +
                 *      " type : " +
                 *      childSnapshot.Child("type").Value.ToString();
                 *
                 *  //FurnitureText_1.GetComponent<Image>.sor
                 *  FurnitureText_1.text = childSnapshot.Child("furniture_name").Value.ToString();
                 *
                 *
                 *  Debug.Log(FurnitureText_1.text);
                 *
                 *
                 * }*/
            }
        });

        ARPanel.SetActive(false);
        MenuPanel.SetActive(true);
        isMenuOpen = true;
    }
Exemplo n.º 16
0
    /*
     * void Update()
     * {
     *  if (Input.GetKeyDown(KeyCode.Q))
     *  {
     *      writeNewUser("USERID1234", "unitytest");
     *  }
     *  else if (Input.GetKeyDown(KeyCode.W))
     *  {
     *      loadFacility();
     *  }
     * }
     */
    void loadFacility()
    {
        ftyList.Clear();
        Debug.Log("loadFacility");
        FirebaseDatabase.DefaultInstance.GetReference("facility").GetValueAsync().ContinueWith(task => {
            if (task.IsFaulted)
            {
                Debug.Log("failed");
                dbSt = -1;
            }
            else if (task.IsCompleted)
            {
                Firebase.Database.DataSnapshot snapshot = task.Result;

                foreach (var childSnapshot in snapshot.Children)
                {
                    string fID   = childSnapshot.Key;
                    string fName = childSnapshot.Child("name").Value.ToString();
                    string fLat  = childSnapshot.Child("latitude").Value.ToString();
                    string fLong = childSnapshot.Child("longitude").Value.ToString();

                    Debug.Log(fID + " " + fName + " " + fLat + " " + fLong + " theaters : " + childSnapshot.Child("theater").ChildrenCount);
                    Facility fty = new Facility(fID, fName, double.Parse(fLat), double.Parse(fLong));

                    foreach (var _childSnapshot in childSnapshot.Child("theater").Children)
                    {
                        string tID      = _childSnapshot.Key;
                        string tName    = _childSnapshot.Child("name").Value.ToString();
                        string tLat     = _childSnapshot.Child("latitude").Value.ToString();
                        string tLong    = _childSnapshot.Child("longitude").Value.ToString();
                        string tKeyName = _childSnapshot.Child("keyName").Value.ToString();
                        //Debug.Log(tID + " " + tName + " " + tLat);
                        Debug.Log(tID + " " + tName + " " + tLat + " " + tLong);
                        Theater tht = new Theater(tID, tName, double.Parse(tLat), double.Parse(tLong), tKeyName);
                        fty.theaterList.Add(tht);
                    }
                    ftyList.Add(fty);
                }
                dbSt = 1;
            }
        });
    }
Exemplo n.º 17
0
    public void InsertUserDB(string userId, string email)
    {
        mDatabaseRef.Child("users").GetValueAsync().ContinueWith(task => {
            if (task.IsFaulted)
            {
                Debug.Log("failed");
            }
            else if (task.IsCompleted)
            {
                Firebase.Database.DataSnapshot snapshot = task.Result;
                TotalUserCount  = snapshot.ChildrenCount.ToString();
                TextLog.text    = "InsertUserDB";
                string[] strArr = email.Split('@');

                string curretTime = DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss");
                writeNewUser(TotalUserCount, TotalUserCount, strArr[0], "0", userId, 0, email, curretTime);
                // Debug.Log(snapshot.ChildrenCount);
            }
        });
    }
Exemplo n.º 18
0
    public void OnNotify(Firebase.Database.DataSnapshot dataSnapShot)
    {
        try {
            Dictionary <string, System.Object> rpcReceive = (Dictionary <string, System.Object>)dataSnapShot.Value;

            bool userHome = (bool)rpcReceive [MyConst.RPC_DATA_USERHOME];

            Dictionary <string, System.Object> param = (Dictionary <string, System.Object>)rpcReceive [MyConst.RPC_DATA_PARAM];

            if (param.ContainsKey(MyConst.RPC_DATA_GESTURE))
            {
                GestureModel gesture = JsonUtility.FromJson <GestureModel> (param [MyConst.RPC_DATA_GESTURE].ToString());
                if (userHome.Equals(!GameManager.isHost))
                {
                    SetEnemyGesture(gesture.gestureNumber);
                }
            }
        } catch (System.Exception e) {
            //do something with exception in future
        }
    }
Exemplo n.º 19
0
    public void OnNotify(Firebase.Database.DataSnapshot dataSnapShot)
    {
        Dictionary <string, System.Object> rpcReceive = (Dictionary <string, System.Object>)dataSnapShot.Value;

        if (rpcReceive.ContainsKey("param"))
        {
            bool userHome = (bool)rpcReceive ["userHome"];
            GameData.Instance.attackerBool = userHome;

            Dictionary <string, System.Object> param = (Dictionary <string, System.Object>)rpcReceive ["param"];
            string stringParam = param ["Attack"].ToString();

            Dictionary <string, System.Object> attackerParam = JsonConverter.JsonStrToDic(stringParam);
            thisCurrentParameter.Add(GameData.Instance.attackerBool, attackerParam);
            if (thisCurrentParameter.Count == 2)
            {
                Attack(thisCurrentParameter);
                thisCurrentParameter.Clear();
            }
        }
    }
Exemplo n.º 20
0
    // void Update () {
    //  if (Input.GetKeyDown(KeyCode.Q)) {
    //      writeNewUser ("2","name", "asdmalskd.jpg", "id", 110,"email");
    //  }
    //  else if(Input.GetKeyDown(KeyCode.W))
    //  {
    //      FirebaseDatabase.DefaultInstance.GetReference("assetbundles").GetValueAsync().ContinueWith(task => {
    //          if (task.IsFaulted) {
    //              Debug.Log ("failed");
    //          }
    //          else if (task.IsCompleted) {
    //              Firebase.Database.DataSnapshot snapshot = task.Result;
    //              Debug.Log (snapshot.Value.ToString());
    //              foreach (var childSnapshot in snapshot.Children) {
    //                  Debug.Log("users name : " +
    //                      childSnapshot.Child("bundleUrl").Value.ToString() + "," + childSnapshot.Child("bundleVersion").Value.ToString());
    //              }
    //          }
    //      });
    //  }
    //  else if(Input.GetKeyDown(KeyCode.E)){
    //      for(int i = 1 ; i <3; i ++){
    //          updateScore(i , 0);
    //          updateUsername(i , "qqq");
    //      }
    //  }
    // }

    void LoadBundleInfo()
    {
        mDatabaseRef.Child("assetbundles").GetValueAsync().ContinueWith(task => {
            if (task.IsFaulted)
            {
                Debug.Log("failed");
            }
            else if (task.IsCompleted)
            {
                Firebase.Database.DataSnapshot snapshot = task.Result;
                // Debug.Log (snapshot.Value.ToString());
                foreach (var childSnapshot in snapshot.Children)
                {
                    AssetBundleUrl = childSnapshot.Child("bundleUrl").Value.ToString();
                    // Debug.Log((int)childSnapshot.Child("bundleVersion").Value);
                    AssetBundleVersion = int.Parse(childSnapshot.Child("bundleVersion").Value.ToString());
                    Debug.Log(AssetBundleUrl + ", " + AssetBundleVersion);
                    OnClickShowBundleInfo();
                }
            }
        });
    }
Exemplo n.º 21
0
 public void ReceiveRPC(Firebase.Database.DataSnapshot dataSnapShot)
 {
     RPCDicObserver.Notify(dataSnapShot);
 }
    private void UpdateSong(int musicIndex)
    {
        // 곡을 바꾸면, 일단 플레이할 수 없도록 막습니다.
        disabled = true;
        disablePanelUI.gameObject.SetActive(true);
        disableAlertUI.text = "데이터를 불러오는 중입니다.";
        purchaseButtonUI.gameObject.SetActive(false);
        startUI.gameObject.SetActive(false);
        AudioSource audioSource = GetComponent <AudioSource>();

        audioSource.Stop();
        // 리소스에서 비트(Beat) 텍스트 파일을 불러옵니다.
        TextAsset    textAsset = Resources.Load <TextAsset>("Beats/" + musicIndex.ToString());
        StringReader reader    = new StringReader(textAsset.text);

        // 첫 번째 줄에 적힌 곡 이름을 읽어 UI를 업데이트합니다.
        musicTitleUI.text = reader.ReadLine();
        // 두 번째 줄은 읽기만 하고 아무 처리도 하지 않습니다.
        reader.ReadLine();
        // 세 번째 줄에 적힌 BPM을 읽어 UI를 업데이트합니다.
        bpmUI.text = "BPM: " + reader.ReadLine().Split(' ')[0];
        // 리소스에서 비트(Beat) 음악 파일을 불러와 재생합니다.
        AudioClip audioClip = Resources.Load <AudioClip>("Beats/" + musicIndex.ToString());

        audioSource.clip = audioClip;
        audioSource.Play();
        // 리소스에서 비트(Beat) 이미지 파일을 불러옵니다.
        musicImageUI.sprite = Resources.Load <Sprite>("Beats/" + musicIndex.ToString());
        // 파이어베이스에 접근합니다.
        DatabaseReference reference = PlayerInformation.GetDatabaseReference().Child("charges")
                                      .Child(musicIndex.ToString());

        // 데이터 셋의 모든 데이터를 JSON 형태로 가져옵니다.
        reference.GetValueAsync().ContinueWith(task => {
            // 성공적으로 데이터를 가져온 경우
            if (task.IsCompleted)
            {
                Firebase.Database.DataSnapshot snapshot = task.Result;
                // 해당 곡이 무료 곡인 경우
                if (!snapshot.Exists)
                {
                    disabled = false;
                    disablePanelUI.gameObject.SetActive(false);
                    disableAlertUI.text = "";
                    startUI.gameObject.SetActive(true);
                }
                else
                {
                    // JSON 데이터의 각 원소에 접근합니다.
                    foreach (Firebase.Database.DataSnapshot data in snapshot.Children)
                    {
                        // 현재 사용자가 구매한 이력이 있는 경우 곡을 플레이할 수 있습니다.
                        if (data.Key == PlayerInformation.auth.CurrentUser.UserId)
                        {
                            disabled = false;
                            disablePanelUI.gameObject.SetActive(false);
                            disableAlertUI.text = "";
                            startUI.gameObject.SetActive(true);
                            purchaseButtonUI.gameObject.SetActive(false);
                            break;
                        }
                    }
                    // 사용자가 해당 곡을 구매했는지 확인하여 처리합니다.
                    if (disabled)
                    {
                        purchaseButtonUI.gameObject.SetActive(true);
                        disableAlertUI.text = "플레이할 수 없는 곡입니다.";
                        startUI.gameObject.SetActive(false);
                    }
                }
            }
        });
    }
    void Start()
    {
        musicTitleUI.text = "" + PlayerInformation.musicTitle;
        scoreUI.text      = "점수: " + (int)PlayerInformation.score;
        maxComboUI.text   = "최대 콤보: " + PlayerInformation.maxCombo;
        // 리소스에서 비트(Beat) 텍스트 파일을 불러옵니다.
        TextAsset    textAsset = Resources.Load <TextAsset>("Beats/" + PlayerInformation.selectedMusic);
        StringReader reader    = new StringReader(textAsset.text);

        // 첫 번째 줄과 두 번째 줄을 무시합니다.
        reader.ReadLine();
        reader.ReadLine();
        // 세 번째 줄에 적힌 비트 정보(S 랭크 점수, A 랭크 점수, B 랭크 점수)를 읽습니다.
        string beatInformation = reader.ReadLine();
        int    scoreS          = Convert.ToInt32(beatInformation.Split(' ')[3]);
        int    scoreA          = Convert.ToInt32(beatInformation.Split(' ')[4]);
        int    scoreB          = Convert.ToInt32(beatInformation.Split(' ')[5]);

        // 성적에 맞는 랭크 이미지를 불러옵니다.
        if (PlayerInformation.score >= scoreS)
        {
            RankUI.sprite = Resources.Load <Sprite>("Sprites/Rank S");
        }
        else if (PlayerInformation.score >= scoreA)
        {
            RankUI.sprite = Resources.Load <Sprite>("Sprites/Rank A");
        }
        else if (PlayerInformation.score >= scoreB)
        {
            RankUI.sprite = Resources.Load <Sprite>("Sprites/Rank B");
        }
        else
        {
            RankUI.sprite = Resources.Load <Sprite>("Sprites/Rank C");
        }
        rank1UI.text = "데이터를 불러오는 중입니다.";
        rank2UI.text = "데이터를 불러오는 중입니다.";
        rank3UI.text = "데이터를 불러오는 중입니다.";
        DatabaseReference reference = PlayerInformation.GetDatabaseReference().Child("ranks")
                                      .Child(PlayerInformation.selectedMusic);

        // 데이터 셋의 모든 데이터를 JSON 형태로 가져옵니다.
        reference.OrderByChild("score").GetValueAsync().ContinueWith(task => {
            // 성공적으로 데이터를 가져온 경우
            if (task.IsCompleted)
            {
                List <string> rankList  = new List <string>();
                List <string> emailList = new List <string>();
                Firebase.Database.DataSnapshot snapshot = task.Result;
                // JSON 데이터의 각 원소에 접근합니다.
                foreach (Firebase.Database.DataSnapshot data in snapshot.Children)
                {
                    IDictionary rank = (IDictionary)data.Value;
                    emailList.Add(rank["email"].ToString());
                    rankList.Add(rank["score"].ToString());
                }
                // 정렬 이후 순서를 뒤집어 내림차순 정렬합니다.
                emailList.Reverse();
                rankList.Reverse();
                // 최대 상위 3명의 순위를 차례대로 화면에 출력합니다.
                rank1UI.text         = "플레이 한 사용자가 없습니다.";
                rank2UI.text         = "플레이 한 사용자가 없습니다.";
                rank3UI.text         = "플레이 한 사용자가 없습니다.";
                List <Text> textList = new List <Text>();
                textList.Add(rank1UI);
                textList.Add(rank2UI);
                textList.Add(rank3UI);
                int count = 1;
                for (int i = 0; i < rankList.Count && i < 3; i++)
                {
                    textList[i].text = count + "위: " + emailList[i] + " (" + rankList[i] + ")";
                    count            = count + 1;
                }
            }
        });
    }
Exemplo n.º 24
0
 public void ReceiveRPCQuery(Firebase.Database.DataSnapshot dataSnapShot)
 {
     RPCQueryObserver.NotifyQuery(dataSnapShot);
 }