Example #1
0
    public override ExtendedEventArgs process()
    {
        ResponseJoinEventArgs args = new ResponseJoinEventArgs
        {
            status = status
        };

        if (status == 0)
        {
            args.user_id  = user_id;
            args.op_id    = op_id;
            args.op_name  = op_name;
            args.op_ready = op_ready;
        }

        return(args);
    }
Example #2
0
    public void OnResponseJoin(ExtendedEventArgs eventArgs)
    {
        ResponseJoinEventArgs args = eventArgs as ResponseJoinEventArgs;

        if (args.status == 0)
        {
            Debug.Log("status is 0");
            if (args.user_id == 1)
            {
                PlayerPrefs.SetString("Player", "Player1");
                Debug.Log("Welcome, Player" + args.user_id);
            }
            else if (args.user_id == 2)
            {
                PlayerPrefs.SetString("Player", "Player2");
                Debug.Log("Welcome, Player" + args.user_id);
            }
            else
            {
                Debug.Log("Error : invalid user_id in ResponseJoin " + args.user_id);
                return;
            }
        }
    }
Example #3
0
    public void OnResponseJoin(ExtendedEventArgs eventArgs)
    {
        ResponseJoinEventArgs args = eventArgs as ResponseJoinEventArgs;

        if (args.status == 0)
        {
            if (args.user_id == 1)
            {
                playerName    = player1Name;
                opponentName  = player2Name;
                playerInput   = player1Input;
                opponentInput = player2Input;
            }
            else if (args.user_id == 2)
            {
                playerName    = player2Name;
                opponentName  = player1Name;
                playerInput   = player2Input;
                opponentInput = player1Input;
            }
            else
            {
                Debug.Log("ERROR: Invalid user_id in ResponseJoin: " + args.user_id);
                messageBoxMsg.text = "Error joining game. Network returned invalid response.";
                messageBox.SetActive(true);
                return;
            }
            Constants.USER_ID = args.user_id;
            Constants.OP_ID   = 3 - args.user_id;

            if (args.op_id > 0)
            {
                if (args.op_id == Constants.OP_ID)
                {
                    opponentName.text = args.op_name;
                    opReady           = args.op_ready;
                }
                else
                {
                    Debug.Log("ERROR: Invalid op_id in ResponseJoin: " + args.op_id);
                    messageBoxMsg.text = "Error joining game. Network returned invalid response.";
                    messageBox.SetActive(true);
                    return;
                }
            }
            else
            {
                opponentName.text = "Waiting for opponent";
            }

            playerInput.SetActive(true);
            opponentName.gameObject.SetActive(true);
            playerName.gameObject.SetActive(false);
            opponentInput.SetActive(false);

            rootMenuPanel.SetActive(false);
            networkMenuPanel.SetActive(true);
        }
        else
        {
            messageBoxMsg.text = "Server is full.";
            messageBox.SetActive(true);
        }
    }