Exemple #1
0
    public IEnumerator getMapToLoadScene_()
    {
        AudioSource AS = this.GetComponent <AudioSource>();

        AS.clip   = matching;
        AS.volume = 0.4F;
        AS.pitch  = 0.5F;
        AS.Play();

        retDMap = null;
        StartCoroutine(Transceive.getMap(PlayerPrefs.GetInt("uid"), new int[] { 4, 5, 6 }, (r) => retDMap = r));

        while (true)
        {
            if (Transceive.isFin)
            {
                if (Transceive.isError)
                {
                    isLoading = false;
                    Debug.Log("error");
                    yield break;
                }
                else
                {
                    if (!isGetMap)
                    {
                        data.mapcodeVisualList = new List <string>();
                        data.mapcodeVisualList.AddRange(retDMap.mapcode);
                        isGetMap         = true;
                        Transceive.isFin = false;
                        StartCoroutine(Transceive.getUname(retDMap.uid, (r) => vsUname = r));
                    }
                    else
                    {
                        //勇者なのでここを消してアニメーションつけることで一秒遅らせる
                        //yield return new WaitForSeconds(0.5f);//0.5s遅らせればエラー出ない?かな?
                        Debug.Log("getMapToLoadScene 1s wait");
                        yield return(new WaitForSeconds(1));

                        Debug.Log("getMapToLoadScene 1s end");
                        Debug.Log(vsUname);
                        StartCoroutine(loadScene("RateMatch"));
                    }
                }
            }
            //Debug.Log("waiting now");
            yield return(null);
        }
    }
Exemple #2
0
    //自分の近いrateのmapデータを取得する 戻り値はreqSQL.mapA
    //引数:自分のレート
    //自分のuidとrateと戦績(プレイ済みのhandle配列)を送信
    //自分のrateに近いかつ未プレイのマップを返す
    public IEnumerator getMap(int uid, int[] playedhandle, UnityEngine.Events.UnityAction <reqSQL.downMap> callback)
    {
        yield return(new WaitForSeconds(0.5F));

        isFin   = false;
        isError = false;

        //リクエストプロフィールを作成
        reqSQL.profile prof = new reqSQL.profile();
        prof.uid          = uid;
        prof.playedhandle = playedhandle;

        string profJson = JsonUtility.ToJson(prof);

        //送信
        www     = null;
        command = "/getMap " + profJson;
        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("getMap 1s wait");
        yield return(new WaitForSeconds(1));

        Debug.Log("getMap 1s end");

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

        Debug.Log(retDownMapJson);

        reqSQL.downMap retDownMap = new reqSQL.downMap();

        retDownMap.uid    = retDownMapJson.uid;
        retDownMap.uname  = retDownMapJson.uname;
        retDownMap.rate   = retDownMapJson.rate;
        retDownMap.handle = retDownMapJson.handle;

        Debug.Log(retDownMap.uid);
        //Debug.Log(retA.uname);

        //ここで\"を"に変換
        retDownMapJson.mapcodejson = retDownMapJson.mapcodejson.Replace("\\" + ((char)(34)).ToString(), ((char)(34)).ToString());
        string MCJson = "{" + '"' + "mapcode" + '"' + ":" + retDownMapJson.mapcodejson + '}';

        //jsonから直接配列にできないので仲介する
        reqSQL.mediation med = JsonUtility.FromJson <reqSQL.mediation>(MCJson);

        retDownMap.mapcode = med.mapcode;

        //Debug.Log(retA.mapcode[0]);

        callback(retDownMap);
        isFin = true;
        yield return(retDownMap);
    }