Exemplo n.º 1
0
    public void SendAllClientsPlayerIDsUpdate(int playerId, string playerName)
    {
        NWMPlayerIDUpdate _playerUpdate = new NWMPlayerIDUpdate();

        _playerUpdate.playerId   = playerId;
        _playerUpdate.playerName = playerName;
        SendAllClientsMessage(host_id, reliable, _playerUpdate);
    }
Exemplo n.º 2
0
 public void ReceivePlayerDataUpdate(NWMPlayerIDUpdate playerIdUpdate)
 {
     playerManager.AddPlayerToList(playerIdUpdate.playerId, playerIdUpdate.playerName);
 }
Exemplo n.º 3
0
    private void OnDataReceived(int channel_id, int host_id, NetworkMessage message)
    {
        switch (message.operation)
        {
        case NetworkOperation.none:

            break;

        case NetworkOperation.set_ready:
            break;

        case NetworkOperation.cart_data:
            NWMCartData cart_data = (NWMCartData)message;
            ReceiveCartData(cart_data);
            break;

        case NetworkOperation.grid_single:
            NWMGridData grid_data = (NWMGridData)message;
            ReceiveSingleGridData(grid_data);
            break;

        case NetworkOperation.user_counter:
            NWMUserCount user_counter = (NWMUserCount)message;
            ReceiveUserCount(user_counter);
            break;

        case NetworkOperation.scene_load:
            NWMSceneLoad scene_load = (NWMSceneLoad)message;
            ReceiveSceneToLoad(scene_load);
            break;

        case NetworkOperation.assign_num:
            NWMAssignPlayerNum assigner = (NWMAssignPlayerNum)message;
            player_id = assigner.num;
            Debug.Log(client_id);
            break;

        case NetworkOperation.gold_pos:
            NWMGoldUpdate goldUpdate = (NWMGoldUpdate)message;
            ReceiveGoldPositionUpdate(goldUpdate);
            break;

        case NetworkOperation.player_score:
            NWMScoreUpdate scoreUpdate = (NWMScoreUpdate)message;
            ReceiveScoreUpdate(scoreUpdate);
            break;

        case NetworkOperation.player_info:
            NWMPlayerIDUpdate idUpdate = (NWMPlayerIDUpdate)message;
            ReceivePlayerDataUpdate(idUpdate);
            break;

        case NetworkOperation.game_start:
            NWMGameStart start_msg = (NWMGameStart)message;
            SetClientGameStarted(start_msg);

            break;

        case NetworkOperation.player_respawn:
            NWMPlayerRespawn respawn_data = (NWMPlayerRespawn)message;
            ReceivePlayerRepsawnData(respawn_data);
            break;

        case NetworkOperation.timer_seconds:
            NWMTimerUpdate timer_data = (NWMTimerUpdate)message;
            ReceiveUpdateTimer(timer_data);
            break;

        case NetworkOperation.game_finished:
            NWMGameFinishedSendInfo game_finished_info = (NWMGameFinishedSendInfo)message;
            ReceiveGameFinishedInfo(game_finished_info);
            break;
        }
    }