Exemple #1
0
    //レートランキング取得
    public IEnumerator getRateRanking(UnityEngine.Events.UnityAction <reqSQL.uinfoP> callback)
    {
        isFin   = false;
        isError = false;

        www     = null;
        command = "/getRateRanking";
        StartCoroutine(ReqSQL.retSQL(command, (r) => www = r));

        //res待ち
        while (true)
        {
            if (www != null)
            {
                break;
            }
            yield return(null);
        }
        if (www.error != null)
        {
            Debug.Log("error");
            isFin   = true;
            isError = true;
            yield break;
        }

        //json全体をdownMapJsonに変換
        reqSQL.uinfoP retUinfoP = JsonUtility.FromJson <reqSQL.uinfoP>(www.text);

        callback(retUinfoP);
        isFin = true;
        yield return(retUinfoP);
    }
Exemple #2
0
    //サーバーから端末に落とす
    public IEnumerator uinfoSync()
    {
        int uid = PlayerPrefs.GetInt("uid");

        //

        isFin   = false;
        isError = false;

        WWW www = null;

        command = "/getUinfo " + uid.ToString();
        StartCoroutine(ReqSQL.retSQL(command, (r) => www = r));

        //res待ち
        while (true)
        {
            if (www != null)
            {
                break;
            }
            yield return(null);
        }
        if (www.error != null)
        {
            Debug.Log("error");
            isFin   = true;
            isError = true;
            yield break;
        }
        //Debug.Log(www.text);

        //json全体をdownMapJsonに変換
        reqSQL.uinfoP ret = JsonUtility.FromJson <reqSQL.uinfoP>(www.text);
        //

        string uname         = ret.data[0].uname;
        int    score         = ret.data[0].score;
        int    rate          = ret.data[0].rate;
        int    highestRate   = ret.data[0].highestrate;
        int    wins          = ret.data[0].wins;
        int    matchesPlayed = ret.data[0].matchesplayed;

        //uid uname highscore rate
        PlayerPrefs.SetInt("highscore", score);
        PlayerPrefs.SetInt("rate", rate);
        PlayerPrefs.SetInt("highestrate", highestRate);

        PlayerPrefs.SetInt("wins", wins);                   //this has no sync so is needless too?
        PlayerPrefs.SetInt("matchesplayed", matchesPlayed); //as follow

        PlayerPrefs.Save();

        yield break;
    }
Exemple #3
0
    void refresh()
    {
        if (!rankingMode)
        {
            StartCoroutine(Transceive.getScoreRanking((r) => ret = r));
        }
        else
        {
            StartCoroutine(Transceive.getRateRanking((r) => ret = r));
        }

        //btnの削除とかをする
        removeBtn();
        isPutBtn = false;
    }
Exemple #4
0
    //
    public IEnumerator getUinfo(int uid, UnityEngine.Events.UnityAction <reqSQL.uinfoP> callback)
    {
        isFin   = false;
        isError = false;

        www = null;

        command = "/getUinfo " + uid.ToString();
        StartCoroutine(ReqSQL.retSQL(command, (r) => www = r));

        //res待ち
        while (true)
        {
            if (www != null)
            {
                break;
            }
            yield return(null);
        }
        if (www.error != null)
        {
            Debug.Log("error");
            syncUserInfo.isConnection = false;
            isFin   = true;
            isError = true;
            yield break;
        }
        yield return(new WaitForSeconds(0.5F));

        syncUserInfo.isConnection = true;

        //json全体をdownMapJsonに変換
        reqSQL.uinfoP retUinfoP = JsonUtility.FromJson <reqSQL.uinfoP>(www.text);

        callback(retUinfoP);
        isFin = true;
        yield return(retUinfoP);
    }
Exemple #5
0
    // Use this for initialization
    void Start()
    {
        enabled = false;

        isConnection = true;

        if (PlayerPrefs.GetInt("uid", -1) != -1)
        {
            Debug.Log("User data has been updated");
            ret = new reqSQL.uinfoP();

            //ユーザー情報取得コルーチン、ここでerrorならisconnection=falseにする
            StartCoroutine(Transceive.getUinfo(PlayerPrefs.GetInt("uid"), (r) => ret = r));
            StartCoroutine(Transceive.uinfoSync());
        }
        else
        {
            Debug.Log("Data Sync failed, please confirm Internet connection OR first of all register User Data");
        }

        retCheckConnection = StartCoroutine(checkConnection());

        enabled = true;
    }
Exemple #6
0
    public IEnumerator checkConnection()
    {
        if (PlayerPrefs.GetInt("uid", -1) == -1)
        {
            yield break;
        }

        yield return(new WaitForSeconds(3));

        while (true)
        {
            //Debug.Log("req thrown");
            retGetUinfo = StartCoroutine(Transceive.getUinfo(PlayerPrefs.GetInt("uid"), (r) => ret = r));

            //Debug.Log("checkCoennection 3s wait");
            yield return(new WaitForSeconds(3));
            //Debug.Log("checkCoennection 3s end");
        }
    }