当前位置: 首页>>代码示例>>C#>>正文


C# SteamSDK.Lobby类代码示例

本文整理汇总了C#中SteamSDK.Lobby的典型用法代码示例。如果您正苦于以下问题:C# Lobby类的具体用法?C# Lobby怎么用?C# Lobby使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Lobby类属于SteamSDK命名空间,在下文中一共展示了Lobby类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: JoinGame

        public static void JoinGame(Lobby lobby, bool requestData = true)
        {
            // Data not received
            if (requestData && String.IsNullOrEmpty(lobby.GetLobbyData(MyMultiplayer.AppVersionTag)))
            {
                var helper = new MyLobbyHelper(lobby);
                helper.OnSuccess += (l) => JoinGame(l, false);
                if (helper.RequestData())
                    return;
            }

            if (!JoinGameTest(lobby))
                return;

            if (MyMultiplayerLobby.GetLobbyScenario(lobby))
            {
                MyJoinGameHelper.JoinScenarioGame(lobby.LobbyId);
            }
            else if (MyFakes.ENABLE_BATTLE_SYSTEM && MyMultiplayerLobby.GetLobbyBattle(lobby))
            {
                bool canBeJoined = MyMultiplayerLobby.GetLobbyBattleCanBeJoined(lobby);
                // Check also valid faction ids in battle lobby.
                long faction1Id = MyMultiplayerLobby.GetLobbyBattleFaction1Id(lobby);
                long faction2Id = MyMultiplayerLobby.GetLobbyBattleFaction2Id(lobby);

                if (canBeJoined && faction1Id != 0 && faction2Id != 0)
                    MyJoinGameHelper.JoinBattleGame(lobby.LobbyId);
            }
            else
            {
                JoinGame(lobby.LobbyId);
            }
        }
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:33,代码来源:MyJoinGameHelper.cs

示例2: JoinGameTest

        private static bool JoinGameTest(Lobby lobby)
        {
            if (!lobby.IsValid)
                return false;

            if (lobby.GetLobbyType() == LobbyTypeEnum.FriendsOnly && !MySteam.API.Friends.HasFriend(lobby.GetOwner()))
            {
                MyGuiSandbox.Show(MyCommonTexts.OnlyFriendsCanJoinThisGame);
                return false;
            }
            if (!MyMultiplayerLobby.IsLobbyCorrectVersion(lobby))
            {
                var formatString = MyTexts.GetString(MyCommonTexts.MultiplayerError_IncorrectVersion);
                var myVersion = MyBuildNumbers.ConvertBuildNumberFromIntToString(MyFinalBuildConstants.APP_VERSION);
                var serverVersion = MyBuildNumbers.ConvertBuildNumberFromIntToString(MyMultiplayerLobby.GetLobbyAppVersion(lobby));
                MyGuiSandbox.Show(new StringBuilder(String.Format(formatString, myVersion, serverVersion)));
                return false;
            }
            if (MyFakes.ENABLE_MP_DATA_HASHES && !MyMultiplayerLobby.HasSameData(lobby))
            {
                MyGuiSandbox.Show(MyCommonTexts.MultiplayerError_DifferentData);
                MySandboxGame.Log.WriteLine("Different game data when connecting to server. Local hash: " + MyDataIntegrityChecker.GetHashBase64() + ", server hash: " + MyMultiplayerLobby.GetDataHash(lobby));
                return false;
            }
            return true;
        }
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:26,代码来源:MyJoinGameHelper.cs

示例3: JoinGame_LobbyUpdate

 void JoinGame_LobbyUpdate(bool success, Lobby lobby, ulong memberOrLobby)
 {
     if (lobby.LobbyId == m_lobby.LobbyId)
     {
         SteamAPI.Instance.Matchmaking.LobbyDataUpdate -= m_dataUpdateHandler;
         var handler = OnSuccess;
         if (handler != null) handler(lobby);
     }
 }
开发者ID:ChristianHeinz71,项目名称:SpaceEngineers,代码行数:9,代码来源:MyJoinGameHelper.cs

示例4: JoinBattleGame

        public static void JoinBattleGame(Lobby lobby, bool requestData = true)
        {
            // Data not received
            if (requestData && String.IsNullOrEmpty(lobby.GetLobbyData(MyMultiplayer.AppVersionTag)))
            {
                var helper = new MyLobbyHelper(lobby);
                helper.OnSuccess += (l) => JoinBattleGame(l, false);
                if (helper.RequestData())
                    return;
            }

            if (!JoinGameTest(lobby))
                return;

            JoinBattleGame(lobby.LobbyId);
        }
开发者ID:leandro1129,项目名称:SpaceEngineers,代码行数:16,代码来源:MyJoinGameHelper.cs

示例5: GetLobbyBattleCanBeJoined

 public static bool GetLobbyBattleCanBeJoined(Lobby lobby)
 {
     return GetLobbyBool(MyMultiplayer.BattleCanBeJoinedTag, lobby, false);
 }
开发者ID:rem02,项目名称:SpaceEngineers,代码行数:4,代码来源:MyMultiplayerLobby.cs

示例6: GetLobbyBattle

 public static bool GetLobbyBattle(Lobby lobby)
 {
     return GetLobbyBool(MyMultiplayer.BattleTag, lobby, false);
 }
开发者ID:rem02,项目名称:SpaceEngineers,代码行数:4,代码来源:MyMultiplayerLobby.cs

示例7: GetLobbyScenario

 public static bool GetLobbyScenario(Lobby lobby)
 {
     return GetLobbyBool(MyMultiplayer.ScenarioTag, lobby, false);
 }
开发者ID:rem02,项目名称:SpaceEngineers,代码行数:4,代码来源:MyMultiplayerLobby.cs

示例8: GetLobbyMods

        public static List<MyObjectBuilder_Checkpoint.ModItem> GetLobbyMods(Lobby lobby)
        {
            var modsCount = GetLobbyModCount(lobby);
            var mods = new List<MyObjectBuilder_Checkpoint.ModItem>(modsCount);
            for (int i = 0; i < modsCount; ++i)
            {
                string modInfo = lobby.GetLobbyData(MyMultiplayer.ModItemTag + i);

                var index = modInfo.IndexOf("_");
                if (index != -1)
                {
                    ulong publishedFileId = 0;
                    ulong.TryParse(modInfo.Substring(0, index), out publishedFileId);
                    var name = modInfo.Substring(index + 1);
                    mods.Add(new MyObjectBuilder_Checkpoint.ModItem(name, publishedFileId, name));
                }
                else
                {
                    MySandboxGame.Log.WriteLineAndConsole(string.Format("Failed to parse mod details from LobbyData. '{0}'", modInfo));
                }

            }
            return mods;
        }
开发者ID:rem02,项目名称:SpaceEngineers,代码行数:24,代码来源:MyMultiplayerLobby.cs

示例9: HasSameData

        public static bool HasSameData(Lobby lobby)
        {
            string remoteHash = GetDataHash(lobby);

            // If the data hash is not set, the server does not want to check the data consistency
            if (remoteHash == "") return true;

            if (remoteHash == MyDataIntegrityChecker.GetHashBase64()) return true;

            return false;
        }
开发者ID:rem02,项目名称:SpaceEngineers,代码行数:11,代码来源:MyMultiplayerLobby.cs

示例10: GetLobbyAppVersion

 public static int GetLobbyAppVersion(Lobby lobby)
 {
     int result;
     return int.TryParse(lobby.GetLobbyData(MyMultiplayer.AppVersionTag), out result) ? result : 0;
 }
开发者ID:rem02,项目名称:SpaceEngineers,代码行数:5,代码来源:MyMultiplayerLobby.cs

示例11: Matchmaking_LobbyChatMsg

 void Matchmaking_LobbyChatMsg(Lobby lobby, ulong steamUserID, byte chatEntryTypeIn, uint chatID)
 {
     string messageText;
     ChatEntryTypeEnum chatEntryType;
     GetChatMessage((int)chatID, out messageText, out chatEntryType);
     RaiseChatMessageReceived(steamUserID, messageText, chatEntryType);
 }
开发者ID:rem02,项目名称:SpaceEngineers,代码行数:7,代码来源:MyMultiplayerLobby.cs

示例12: Matchmaking_LobbyChatUpdate

        void Matchmaking_LobbyChatUpdate(Lobby lobby, ulong changedUser, ulong makingChangeUser, ChatMemberStateChangeEnum stateChange)
        {
            //System.Diagnostics.Debug.Assert(MySession.Static != null);

            if (lobby.LobbyId == Lobby.LobbyId)
            {
                if (stateChange == ChatMemberStateChangeEnum.Entered)
                {
                    MySandboxGame.Log.WriteLineAndConsole("Player entered: " + MySteam.API.Friends.GetPersonaName(changedUser) + " (" + changedUser + ")");
                    MyTrace.Send(TraceWindow.Multiplayer, "Player entered");
                    Peer2Peer.AcceptSession(changedUser);

                    // When some clients connect at the same time then some of them can have already added clients 
                    // (see function MySyncLayer.RegisterClientEvents which registers all Members in Lobby).
                    if (Sync.Clients == null || !Sync.Clients.HasClient(changedUser))
                    {
                        RaiseClientJoined(changedUser);

                        // Battles - send all clients, identities, players, factions as first message to client
                        if ((Battle || Scenario) && changedUser != Sync.MyId)
                        {
                            SendAllMembersDataToClient(changedUser);
                        }
                    }

                    if (MySandboxGame.IsGameReady && changedUser != ServerId)
                    {
                        // Player is able to connect to the battle which already started - player is then kicked and we do not want to show connected message in HUD.
                        bool showMsg = true;
                        if (MyFakes.ENABLE_BATTLE_SYSTEM && MySession.Static != null && MySession.Static.Battle && !BattleCanBeJoined)
                            showMsg = false;

                        if (showMsg)
                        {
                            var playerJoined = new MyHudNotification(MyCommonTexts.NotificationClientConnected, 5000, level: MyNotificationLevel.Important);
                            playerJoined.SetTextFormatArguments(MySteam.API.Friends.GetPersonaName(changedUser));
                            MyHud.Notifications.Add(playerJoined);
                        }
                    }
                }
                else
                {
                    // Kicked client can be already removed from Clients
                    if (Sync.Clients == null || Sync.Clients.HasClient(changedUser))
                        RaiseClientLeft(changedUser, stateChange);

                    if (changedUser == ServerId)
                    {
                        MyTrace.Send(TraceWindow.Multiplayer, "Host left: " + stateChange.ToString());
                        RaiseHostLeft();

                        MyGuiScreenMainMenu.UnloadAndExitToMenu();
                        MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(
                            messageCaption: MyTexts.Get(MyCommonTexts.MessageBoxCaptionError),
                            messageText: MyTexts.Get(MyCommonTexts.MultiplayerErrorServerHasLeft)));

                        // Set new server
                        //ServerId = Lobby.GetOwner();

                        //if (ServerId == Sync.MyId)
                        //{
                        //    Lobby.SetLobbyData(HostNameTag, Sync.MyName);
                        //}
                    }
                    else if (MySandboxGame.IsGameReady)
                    {
                        var playerLeft = new MyHudNotification(MyCommonTexts.NotificationClientDisconnected, 5000, level: MyNotificationLevel.Important);
                        playerLeft.SetTextFormatArguments(MySteam.API.Friends.GetPersonaName(changedUser));
                        MyHud.Notifications.Add(playerLeft);
                    }
                }
            }
        }
开发者ID:rem02,项目名称:SpaceEngineers,代码行数:73,代码来源:MyMultiplayerLobby.cs

示例13: MyMultiplayerLobby

        internal MyMultiplayerLobby(Lobby lobby, MySyncLayer syncLayer)
            : base(syncLayer, new EndpointId(Sync.MyId))
        {
            Lobby = lobby;
            ServerId = Lobby.GetOwner();

            SyncLayer.RegisterClientEvents(this);

            HostName = MySteam.UserName;
           
            Debug.Assert(IsServer, "Wrong object created");

            MySteam.API.Matchmaking.LobbyChatUpdate += Matchmaking_LobbyChatUpdate;
            MySteam.API.Matchmaking.LobbyChatMsg += Matchmaking_LobbyChatMsg;
            ClientLeft += MyMultiplayerLobby_ClientLeft;
            AcceptMemberSessions();
        }
开发者ID:rem02,项目名称:SpaceEngineers,代码行数:17,代码来源:MyMultiplayerLobby.cs

示例14: Matchmaking_LobbyChatUpdate

        void Matchmaking_LobbyChatUpdate(Lobby lobby, ulong changedUser, ulong makingChangeUser, ChatMemberStateChangeEnum stateChange)
        {
            //System.Diagnostics.Debug.Assert(MySession.Static != null);

            if (lobby.LobbyId == Lobby.LobbyId)
            {
                if (stateChange == ChatMemberStateChangeEnum.Entered)
                {
                    MySandboxGame.Log.WriteLineAndConsole("Player entered: " + MySteam.API.Friends.GetPersonaName(changedUser) + " (" + changedUser + ")");
                    MyTrace.Send(TraceWindow.Multiplayer, "Player entered");
                    Peer2Peer.AcceptSession(changedUser);

                    RaiseClientJoined(changedUser);

                    if (MySandboxGame.IsGameReady && changedUser != ServerId)
                    {
                        var playerJoined = new MyHudNotification(MySpaceTexts.NotificationClientConnected, 5000, level: MyNotificationLevel.Important);
                        playerJoined.SetTextFormatArguments(MySteam.API.Friends.GetPersonaName(changedUser));
                        MyHud.Notifications.Add(playerJoined);
                    }
                }
                else
                {
                    // Kicked client can be already removed from Clients
                    if (Sync.Clients.HasClient(changedUser))
                        RaiseClientLeft(changedUser, stateChange);

                    if (changedUser == ServerId)
                    {
                        MyTrace.Send(TraceWindow.Multiplayer, "Host left: " + stateChange.ToString());
                        RaiseHostLeft();

                        MyGuiScreenMainMenu.UnloadAndExitToMenu();
                        MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(
                            messageCaption: MyTexts.Get(MySpaceTexts.MessageBoxCaptionError),
                            messageText: MyTexts.Get(MySpaceTexts.MultiplayerErrorServerHasLeft)));

                        // Set new server
                        //ServerId = Lobby.GetOwner();

                        //if (ServerId == Sync.MyId)
                        //{
                        //    Lobby.SetLobbyData(HostNameTag, Sync.MyName);
                        //}
                    }
                    else if (MySandboxGame.IsGameReady)
                    {
                        var playerLeft = new MyHudNotification(MySpaceTexts.NotificationClientDisconnected, 5000, level: MyNotificationLevel.Important);
                        playerLeft.SetTextFormatArguments(MySteam.API.Friends.GetPersonaName(changedUser));
                        MyHud.Notifications.Add(playerLeft);
                    }
                }
            }
        }
开发者ID:caomw,项目名称:SpaceEngineers,代码行数:54,代码来源:MyMultiplayerLobby.cs

示例15: MyMultiplayerLobby

        internal MyMultiplayerLobby(Lobby lobby, MySyncLayer syncLayer)
            : base(syncLayer)
        {
            Lobby = lobby;
            ServerId = Lobby.GetOwner();

            SyncLayer.RegisterClientEvents(this);

            if (IsServer)
            {
                HostName = MySteam.UserName;
            }
            else
            {
                SyncLayer.TransportLayer.IsBuffering = true;
            }
            MySteam.API.Matchmaking.LobbyChatUpdate += Matchmaking_LobbyChatUpdate;
            MySteam.API.Matchmaking.LobbyChatMsg += Matchmaking_LobbyChatMsg;
            ClientLeft += MyMultiplayerLobby_ClientLeft;
            AcceptMemberSessions();
        }
开发者ID:caomw,项目名称:SpaceEngineers,代码行数:21,代码来源:MyMultiplayerLobby.cs


注:本文中的SteamSDK.Lobby类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。