Beispiel #1
0
    private void Client_OnStateChangeAction(ClientState clientState)
    {
        switch (clientState)
        {
        case ClientState.JoinedLobby:
            LocalPlayerID = LocalPlayer.ID;
            OnJoinedLobby?.Invoke();
            break;

        case ClientState.DisconnectingFromMasterserver:
            OnDisconnectedFromMasterServer?.Invoke();
            break;

        case ClientState.ConnectedToGameserver:
            OnConnectedToGameServer?.Invoke();
            break;

        case ClientState.Joining:
            OnJoinedGame?.Invoke();
            break;

        case ClientState.Joined:
            LocalPlayerID = LocalPlayer.ID;
            OnJoinedRoom?.Invoke();
            break;

        case ClientState.Leaving:
            OnLeftRoom?.Invoke();
            break;

        case ClientState.Disconnected:
            OnDisconnected?.Invoke();
            break;

        case ClientState.ConnectedToMasterserver:
            CreateOrJoinRoom();
            OnConnectedToMasterServer?.Invoke();
            break;

        case ClientState.ConnectedToNameServer:
            if (string.IsNullOrEmpty(client.CloudRegion))
            {
                client.OpGetRegions();
            }
            break;
        }
    }