Exemple #1
0
    // -----

    // Packet Handling
    public void OnPacketReceived(RTPacket _packet)
    {
        switch (_packet.OpCode)
        {
        // Add here a case for each OpCode. OpCodes documentation is available at drive/Code/OpCodes
        case 100:     //All players connected to the server
            Debug.Log("Loading Game scene...");
            UnityEngine.SceneManagement.SceneManager.LoadScene("2.Game");
            break;

        case 101:     //Sync Clock
        {
            if (match_manager == null)
            {
                match_manager = GameObject.FindGameObjectWithTag("MatchManager").GetComponent <MatchManager>();
            }
            match_manager.CalculateConnectionDelays(_packet);
        }
        break;

        case 102:    //player match initial info
        {
            if (match_manager == null)
            {
                match_manager = GameObject.FindGameObjectWithTag("MatchManager").GetComponent <MatchManager>();
            }
            match_manager.SetPlayersInfo(_packet);
        }
        break;

        case 120:     //Change turn to the actual one
            Debug.Log("Start Turn " + _packet.Data.GetString(1));
            match_manager.StartNewTurn(_packet);
            break;

        case 122:
            match_manager.UpdatePlayersPosition(_packet);
            break;

        case 123:
            match_manager.CardUseRecieved(_packet);
            break;

        case 124:
            match_manager.ClientCardObtained(_packet);
            break;
        }
    }