Пример #1
0
    IEnumerator Reading(StringQueue sq)
    {
        while (_On)
        {
            yield return(null);

            string str = "";
            if (!sq.IsEmpty())
            {
                str = sq.getData();

                if (str != "")
                {
                    Debug.Log(str);
                    if (str[0] == '{')
                    {
                        SendDataFormat data = JsonUtility.FromJson <SendDataFormat>(str);
                        if (data.type == "enemyid")
                        {
                            _EnemyId    = data.data;
                            _getEnemyId = true;
                        }
                    }
                    else if (str[0] == 'o' && str[1] == 'm')
                    {
                        string           data = str.Replace("om", "");
                        OmSendDataFormat dd   = JsonUtility.FromJson <OmSendDataFormat>(data);
                        _GameMng._OmGameMng.StoneSet_GetData(dd);
                    }
                    else if (str[0] == 'o' && str[1] == 'c')
                    {
                        string data = str.Replace("oc", "");
                        _GameMng.GameChange_GetData("toom");
                        JsonData item = JsonMapper.ToObject(data);
                        _GameMng._OmGameMng.SetRePosition_OmGame(item);
                    }
                    else if (str[0] == 's' && str[1] == 'h')
                    {
                        _GameMng._AlGameMng.TurnOffEnemySlot(str[2] - '0');
                    }
                    else if (str[0] == 'a' && str[1] == 'l')
                    {
                        string   data = str.Replace("al", "");
                        JsonData item = JsonMapper.ToObject(data);
                        _GameMng._AlGameMng.SetStones_GetData(item);
                    }
                    else if (str[0] == 'a' && str[1] == 's')
                    {
                        string   data = str.Replace("as", "");
                        JsonData item = JsonMapper.ToObject(data);
                        _GameMng._AlGameMng.SetStones_GetData(item);
                    }
                    else if (str[0] == 'c' && str[1] == 'c')
                    {
                        _GameMng.EnemyChangeStoneCountSet(str[2] - '0');
                    }
                    else if (str == "stonestoped")
                    {
                        _GameMng._AlGameMng.TurnChange_GetData();
                    }
                    else if (str == "black" || str == "white")
                    {
                        Matched_GameStart(str);
                    }
                    else if (str == "youlose")
                    {
                        _GameMng._OmGameMng.LoseAfterEffectCheck();
                    }
                    else if (str == "draw")
                    {
                        _GameMng._OmGameMng.LoseAfterEffectCheck();
                    }
                    else if (str == "getdataoknormal")
                    {
                        _GameMng.EnemyReadyPopupSet_Normal(false);
                    }
                    else if (str == "getdataokchange")
                    {
                        _GameMng.EnemyReadyPopupSet_Change(false);
                    }
                    else if (str == "changetoal")
                    {
                        _GameMng.GameChange_GetData("toal");
                    }
                    else if (str == "youwintime")
                    {
                        _SceneMng.OpenWinnerPopup_Time();
                    }
                    else if (str == "youlosetime")
                    {
                        _SceneMng.OpenLoserPopup_Time();
                    }
                    else if (str == "youwindisconnect")
                    {
                        WinThisGame_Disconnect();
                    }
                }
                else
                {
                    SendDataToServer("enemyout");
                    Debug.Log("empty");
                }
            }
        }
    }