Beispiel #1
0
 /// <summary>
 /// game info res
 /// </summary>
 /// <param name="response"></param>
 public void ResponseShowGame(ResponseShowGame response)
 {
     is_myself_turn = PlayerSession.user_id == response.turn_mover_user_id;
     is_first       = PlayerSession.user_id == response.first_mover_user_id;
     game_status    = response.status;
     turn_counta    = response.turn_count;
 }
Beispiel #2
0
    public void ResponseShowGame(ResponseShowGame response)
    {
        UserInfo.game_status = response.status;
        if (UserInfo.flg_spectator)
        {
            UserInfo.game_user_id = response.first_mover_user_id;
        }

        // 終了処理
        if (response.status == "finished")
        {
            waiting.SetActive(false);
            if (UserInfo.flg_spectator)
            {
                return;
            }

            if (response.winner_user_id == UserInfo.game_user_id)
            {
                GetPiecesInfo();
                win_panel.SetActive(true);
            }
            else
            {
                GetPiecesInfo();
                lose_panel.SetActive(true);
            }
            return;
        }

        if (response.status == "exited")
        {
            waiting.SetActive(false);
            if (response.winner_user_id == UserInfo.game_user_id)
            {
                win_panel.SetActive(true);
            }
        }


        // 先手後手格納
        if (response.first_mover_user_id == UserInfo.game_user_id)
        {
            m_flgFirst = true;
        }
        else
        {
            m_flgFirst = false;
        }

        if (!m_flgMatched)
        {
            m_flgMatched = true;
            waiting.SetActive(false);
            if (!UserInfo.flg_spectator)
            {
                GameObject.Find("Canvas/Panel/Button").SetActive(true);
                GameObject.Find("Canvas/Panel/Button_Shuffle").SetActive(true);
            }
            InitPieces();
        }

        // ターン進行
        if (response.status == "playing")
        {
            if (!m_flgStart)
            {
                GetPiecesInfo();
                return;
            }

            if (m_turn != response.turn_count)
            {
                m_turn = response.turn_count;
                GetPiecesInfo();
                UserInfo.flg_turn = (response.turn_mover_user_id == UserInfo.game_user_id);
                if (UserInfo.flg_spectator)
                {
                    return;
                }
                waiting.SetActive(!UserInfo.flg_turn);
            }
        }
    }