public IEnumerator Get(string url, System.Action <playerList> callBack)
    {
        using (UnityWebRequest www = UnityWebRequest.Get(url))
        {
            yield return(www.SendWebRequest());

            if (www.isNetworkError)
            {
                Debug.Log(www.error);
            }
            else
            {
                if (www.isDone)
                {
                    string jsonResult = System.Text.Encoding.UTF8.GetString(www.downloadHandler.data);

                    jsonResult = jsonResult.Replace("[", "{\"players\": [");
                    jsonResult = jsonResult.Replace("]", "]}");


                    // jsonResult = "{ \"Scores\": [" + jsonResult;
                    //  jsonResult = jsonResult + "]}";


                    playerList pl = JsonUtility.FromJson <playerList>(jsonResult);
                    callBack(pl);
                }
            }
        }
    }
Exemplo n.º 2
0
 public bool AddFriend(string username)
 {
     if (myList.Count >= myListMaxSize)
     {
         return(false);
     }
     else
     {
         bool found = false;
         for (int i = 0; i < myList.Count; i++)
         {
             if (myList[i].name.ToLower() == username.ToLower())
             {
                 found = true;
                 playerList temp = myList[i];
                 temp.friend = true;
                 myList[i]   = temp;
             }
         }
         if (!found)
         {
             playerList temp = new playerList();
             temp.name   = username;
             temp.friend = true;
             myList.Add(temp);
         }
         return(true);
     }
 }
Exemplo n.º 3
0
        public bool SetInform(string username)
        {
            bool ret = false;

            for (int i = 0; i < myList.Count(); i++)
            {
                if (myList[i].name.ToLower() == username.ToLower())
                {
                    ret = true;
                    playerList temp = myList[i];
                    temp.inform = true;
                    myList[i]   = temp;
                }
            }
            if (!ret)
            {
                if (myList.Count > myListMaxSize)
                {
                    ret = true;
                    playerList temp = new playerList();
                    temp.name   = username;
                    temp.inform = true;
                    myList.Add(temp);
                }
            }
            return(ret);
        }
Exemplo n.º 4
0
 void GetPlayers(playerList pl)
 {
     yetkili = PlayerPrefs.GetInt("yetkili");
     if (yetkili == 1)
     {
         int i = 0;
         foreach (player player in pl.players)
         {
             skorListesi.text = skorListesi.text + "\n" + (i + 1) + ".    " + "id: " + player.skor_id + "      " + player.skor_adi + " ---> " + player.skor;
             skor_id[i]       = player.skor_id;
             skor_adi[i]      = player.skor_adi;
             skor[i]          = player.skor;
             i++;
         }
     }
     else
     {
         int i = 0;
         foreach (player player in pl.players)
         {
             skorListesi.text = skorListesi.text + "\n" + (i + 1) + ".    " + player.skor_adi + " ---> " + player.skor;
             skor_id[i]       = player.skor_id;
             skor_adi[i]      = player.skor_adi;
             skor[i]          = player.skor;
             i++;
         }
     }
 }
Exemplo n.º 5
0
        public bool RemoveInform(string username)
        {
            bool ret = false;

            for (int i = 0; i < myList.Count(); i++)
            {
                if (myList[i].name.ToLower() == username.ToLower())
                {
                    ret = true;
                    playerList temp = myList[i];
                    temp.inform = false;
                    myList[i]   = temp;
                }
            }
            CleanMyList();
            return(ret);
        }
Exemplo n.º 6
0
        public Main(string name, string surname)
        {
            time = 0;
            InitializeComponent();
            //t = new Tetris();
            p = new playerList();
            timer.Start();
            this.Focus();
            lblPlayer.Text = name + " " + surname;

            this.name    = name;
            this.surname = surname;

            tetris1.TabIndex = 0;
            //lblPoints.Text = "0";
            setHighScore();
            gameStarted = true;
        }
Exemplo n.º 7
0
        public Main()
        {
            time = 0;
            InitializeComponent();
            p = new playerList();
            timer.Start();
            this.Focus();
            lblPlayer.Text = "UNKNOWN";

            this.name    = "UNKNOWN";
            this.surname = "UNKNOWN";

            tetris1.TabIndex = 0;

            //lblPoints.Text = "0";
            setHighScore();
            gameStarted = true;
        }
Exemplo n.º 8
0
        public int UpdateList(string username, string flag)
        {
            playerList target = new playerList();
            bool       update = false;

            foreach (playerList p in myList)
            {
                if (p.name.ToLower() == username.ToLower())
                {
                    target = p;
                    update = true;
                }
            }
            if (!update)
            {
                target.name = username;
            }

            int ret = -1;

            switch (flag)
            {
            case "bar":
                target.bar = !target.bar;
                ret        = target.bar ? 1 : 0;
                break;

            case "beep":
                target.beep = !target.beep;
                ret         = target.beep ? 1 : 0;
                break;

            case "block":
                target.block = !target.block;
                ret          = target.block ? 1 : 0;
                break;

            case "find":
                target.find = !target.find;
                ret         = target.find ? 1 : 0;
                break;

            case "friend":
                target.friend = !target.friend;
                ret           = target.friend ? 1 : 0;
                break;

            case "grab":
                target.grabme = !target.grabme;
                ret           = target.grabme ? 1 : 0;
                break;

            case "ignore":
                target.ignore = !target.ignore;
                ret           = target.ignore ? 1 : 0;
                break;

            case "inform":
                target.inform = !target.inform;
                ret           = target.inform ? 1 : 0;
                break;

            case "mblock":
                target.mailblock = !target.mailblock;
                ret = target.mailblock ? 1 : 0;
                break;

            case "noisy":
                target.noisy = !target.noisy;
                ret          = target.noisy ? 1 : 0;
                break;

            case "key":
                target.key = !target.key;
                ret        = target.key ? 1 : 0;
                break;
            }
            if (ret != -1)
            {
                if (update)
                {
                    for (int i = 0; i < myList.Count; i++)
                    {
                        if (myList[i].name == target.name)
                        {
                            myList[i] = target;
                        }
                    }
                }
                else
                {
                    myList.Add(target);
                }

                CleanMyList();
            }
            return(ret);
        }