本文整理汇总了C#中MyMultiplayerBase类的典型用法代码示例。如果您正苦于以下问题:C# MyMultiplayerBase类的具体用法?C# MyMultiplayerBase怎么用?C# MyMultiplayerBase使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MyMultiplayerBase类属于命名空间,在下文中一共展示了MyMultiplayerBase类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: RaiseJoined
public void RaiseJoined(Result result, LobbyEnterInfo info, MyMultiplayerBase multiplayer)
{
Debug.Assert(!Cancelled, "Cancelled action should not raise events");
var handler = JoinDone;
if (handler != null)
handler(result, info, multiplayer);
}
开发者ID:ChristianHeinz71,项目名称:SpaceEngineers,代码行数:7,代码来源:MyMultiplayerJoinResult.cs
示例2: RaiseDone
public void RaiseDone(Result result, MyMultiplayerBase multiplayer)
{
Debug.Assert(!Cancelled, "Action is canceled, it should not raise event");
var handler = Done;
if (handler != null) handler(result, multiplayer);
m_done = true;
}
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:7,代码来源:MyMultiplayerHostResult.cs
示例3: UnregisterChat
public void UnregisterChat(MyMultiplayerBase multiplayer)
{
multiplayer.ChatMessageReceived -= Multiplayer_ChatMessageReceived;
MessagesQueue.Clear();
SetDirty();
}
开发者ID:caomw,项目名称:SpaceEngineers,代码行数:7,代码来源:MyHudChat.cs
示例4: UnregisterChat
public void UnregisterChat(MyMultiplayerBase multiplayer)
{
multiplayer.ChatMessageReceived -= Multiplayer_ChatMessageReceived;
MessagesQueue.Clear();
UpdateTimestamp();
}
开发者ID:ChristianHeinz71,项目名称:SpaceEngineers,代码行数:7,代码来源:MyHudChat.cs
示例5: MyDownloadWorldResult
public MyDownloadWorldResult(int channel, ulong sender, MyMultiplayerBase mp)
{
m_mp = mp;
m_sender = sender;
m_channel = channel;
MyNetworkReader.SetHandler(m_channel, MyDownloadWorldResult_Received);
SteamSDK.Peer2Peer.ConnectionFailed += Peer2Peer_ConnectionFailed;
}
开发者ID:Krulac,项目名称:SpaceEngineers,代码行数:8,代码来源:MyDownloadWorldResult.cs
示例6: OnMultiplayerHost
private static void OnMultiplayerHost(Result hostResult, MyMultiplayerBase multiplayer)
{
if (hostResult == Result.OK)
{
Static.StartServer(multiplayer);
}
else
{
var notification = new MyHudNotification(MyCommonTexts.MultiplayerErrorStartingServer, 10000, MyFontEnum.Red);
notification.SetTextFormatArguments(hostResult.ToString());
MyHud.Notifications.Add(notification);
}
}
开发者ID:liiir1985,项目名称:SpaceEngineers,代码行数:13,代码来源:MySession.cs
示例7: LoadMultiplayerWorld
internal void LoadMultiplayerWorld(MyObjectBuilder_World world, MyMultiplayerBase multiplayerSession)
{
Static.UnloadDataComponents(true);
MyDefinitionManager.Static.UnloadData();
Static.Mods = world.Checkpoint.Mods;
Static.Settings = world.Checkpoint.Settings;
Static.CurrentPath = MyLocalCache.GetSessionSavesPath(MyUtils.StripInvalidChars(world.Checkpoint.SessionName), false, false);
if (!MyDefinitionManager.Static.TryGetDefinition<MyScenarioDefinition>(world.Checkpoint.Scenario, out Static.Scenario))
Static.Scenario = MyDefinitionManager.Static.GetScenarioDefinitions().FirstOrDefault();
FixIncorrectSettings(Static.Settings);
Static.InGameTime = MyObjectBuilder_Checkpoint.DEFAULT_DATE;
MySandboxGame.Static.SessionCompatHelper.FixSessionComponentObjectBuilders(world.Checkpoint, world.Sector);
Static.PrepareBaseSession(world.Checkpoint, world.Sector);
// No controlled object
long hostObj = world.Checkpoint.ControlledObject;
world.Checkpoint.ControlledObject = -1;
Static.Gpss.RegisterChat(multiplayerSession);
Static.CameraController = MySpectatorCameraController.Static;
Static.LoadWorld(world.Checkpoint, world.Sector);
if (Sync.IsServer)
{
Static.InitializeFactions();
}
Static.Settings.AutoSaveInMinutes = 0;
Static.IsCameraAwaitingEntity = true;
MyLocalCache.ClearLastSessionInfo();
Static.BeforeStartComponents();
}
开发者ID:liiir1985,项目名称:SpaceEngineers,代码行数:42,代码来源:MySession.cs
示例8: LoadMembersFromWorld
private void LoadMembersFromWorld(MyObjectBuilder_World world, MyMultiplayerBase multiplayerSession)
{
// CH: This only makes sense on MyMultiplayerClient, because MyMultiplayerLobby takes the connected members from SteamSDK
if (multiplayerSession is MyMultiplayerClient)
(multiplayerSession as MyMultiplayerClient).LoadMembersFromWorld(world.Checkpoint.Clients);
}
开发者ID:liiir1985,项目名称:SpaceEngineers,代码行数:6,代码来源:MySession.cs
示例9: LoadMultiplayerBattleWorld
public static void LoadMultiplayerBattleWorld(MyObjectBuilder_World world, MyMultiplayerBase multiplayerSession)
{
MyLog.Default.WriteLine("LoadMultiplayerBattleWorld() - Start");
if (!MySteamWorkshop.CheckLocalModsAllowed(world.Checkpoint.Mods, false))
{
MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(
messageCaption: MyTexts.Get(MyCommonTexts.MessageBoxCaptionError),
messageText: MyTexts.Get(MyCommonTexts.DialogTextLocalModsDisabledInMultiplayer),
buttonType: MyMessageBoxButtonsType.OK,
callback: delegate(MyGuiScreenMessageBox.ResultEnum result) { MyGuiScreenMainMenu.ReturnToMainMenu(); }));
MyLog.Default.WriteLine("LoadMultiplayerBattleWorld() - End");
return;
}
MySteamWorkshop.DownloadModsAsync(world.Checkpoint.Mods,
onFinishedCallback: delegate(bool success,string mismatchMods)
{
if (success)
{
MyScreenManager.CloseAllScreensNowExcept(null);
MyGuiSandbox.Update(VRage.Game.MyEngineConstants.UPDATE_STEP_SIZE_IN_MILLISECONDS);
CheckMismatchmods(mismatchMods, callback: delegate(VRage.Game.ModAPI.ResultEnum val)
{
MyGuiScreenGamePlay.StartLoading(delegate
{
if (MySession.Static == null)
{
MySession.CreateWithEmptyWorld(multiplayerSession);
MySession.Static.Settings.Battle = true;
}
MySession.Static.LoadMultiplayerWorld(world, multiplayerSession);
Debug.Assert(MySession.Static.Battle);
if (BattleWorldLoaded != null)
BattleWorldLoaded();
});
});
}
else
{
MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(
messageCaption: MyTexts.Get(MyCommonTexts.MessageBoxCaptionError),
messageText: MyTexts.Get(MyCommonTexts.DialogTextDownloadModsFailed),
buttonType: MyMessageBoxButtonsType.OK,
callback: delegate(MyGuiScreenMessageBox.ResultEnum result) { MyGuiScreenMainMenu.ReturnToMainMenu(); }));
}
MyLog.Default.WriteLine("LoadMultiplayerBattleWorld() - End");
},
onCancelledCallback: delegate()
{
MyGuiScreenMainMenu.UnloadAndExitToMenu();
});
}
开发者ID:ChristianHeinz71,项目名称:SpaceEngineers,代码行数:54,代码来源:MyGuiScreenLoadSandbox.cs
示例10: CreateWithEmptyWorld
internal static void CreateWithEmptyWorld(MyMultiplayerBase multiplayerSession)
{
Debug.Assert(!Sync.IsServer);
Static = new MySession(multiplayerSession.SyncLayer, false);
Static.InGameTime = MyObjectBuilder_Checkpoint.DEFAULT_DATE;
MyHud.Chat.RegisterChat(multiplayerSession);
Static.Gpss.RegisterChat(multiplayerSession);
Static.CameraController = MySpectatorCameraController.Static;
Static.Settings = new MyObjectBuilder_SessionSettings();
Static.Settings.Battle = true;
Static.Settings.AutoSaveInMinutes = 0;
Static.IsCameraAwaitingEntity = true;
Static.PrepareBaseSession(new List<MyObjectBuilder_Checkpoint.ModItem>());
multiplayerSession.StartProcessingClientMessagesWithEmptyWorld();
if (Sync.IsServer)
{
Static.InitializeFactions();
}
MyLocalCache.ClearLastSessionInfo();
// Player must be created for selection in factions.
if (!Engine.Platform.Game.IsDedicated && Static.LocalHumanPlayer == null)
{
Sync.Players.RequestNewPlayer(0, MySteam.UserName, null);
}
MyNetworkStats.Static.ClearStats();
Sync.Layer.TransportLayer.ClearStats();
}
开发者ID:liiir1985,项目名称:SpaceEngineers,代码行数:38,代码来源:MySession.cs
示例11: OnJoin
public static void OnJoin(MyGuiScreenProgress progress, Result joinResult, LobbyEnterInfo enterInfo, MyMultiplayerBase multiplayer)
{
// HACK: To hide multiplayer from ME
//if (!MySandboxGame.Services.SteamService.IsActive || MySandboxGame.Services.SteamService.AppId * 2 == 667900)
// return;
MyLog.Default.WriteLine(String.Format("Lobby join response: {0}, enter state: {1}", joinResult.ToString(), enterInfo.EnterState));
if (joinResult == Result.OK && enterInfo.EnterState == LobbyEnterResponseEnum.Success && multiplayer.GetOwner() != Sync.MyId)
{
DownloadWorld(progress, multiplayer);
}
else
{
string status = "ServerHasLeft";
if (joinResult != Result.OK)
{
status = joinResult.ToString();
}
else if (enterInfo.EnterState != LobbyEnterResponseEnum.Success)
{
status = enterInfo.EnterState.ToString();
}
OnJoinFailed(progress, multiplayer, status);
}
}
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:27,代码来源:MyJoinGameHelper.cs
示例12: OnJoinScenario
public static void OnJoinScenario(MyGuiScreenProgress progress, Result joinResult, LobbyEnterInfo enterInfo, MyMultiplayerBase multiplayer)
{
MyLog.Default.WriteLine(String.Format("Lobby join response: {0}, enter state: {1}", joinResult.ToString(), enterInfo.EnterState));
if (joinResult == Result.OK && enterInfo.EnterState == LobbyEnterResponseEnum.Success && multiplayer.GetOwner() != Sync.MyId)
{
// Create session with empty world
if (MySession.Static != null)
{
MySession.Static.Unload();
MySession.Static = null;
}
MySession.CreateWithEmptyWorld(multiplayer);
progress.CloseScreen();
MyScreenManager.CloseAllScreensNowExcept(null);
MyLog.Default.WriteLine("Scenario lobby joined");
if (MyPerGameSettings.GUI.ScenarioLobbyClientScreen != null)
MyGuiSandbox.AddScreen(MyGuiSandbox.CreateScreen(MyPerGameSettings.GUI.ScenarioLobbyClientScreen));
else
Debug.Fail("No scenario lobby client screen");
}
else
{
string status = "ServerHasLeft";
if (joinResult != Result.OK)
{
status = joinResult.ToString();
}
else if (enterInfo.EnterState != LobbyEnterResponseEnum.Success)
{
status = enterInfo.EnterState.ToString();
}
OnJoinBattleFailed(progress, multiplayer, status);
}
}
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:40,代码来源:MyJoinGameHelper.cs
示例13: UnregisterChat
internal void UnregisterChat(MyMultiplayerBase multiplayer)
{
if (MyFakes.ENABLE_GPS)
multiplayer.ChatMessageReceived -= ParseChat;
}
开发者ID:austusross,项目名称:SpaceEngineers,代码行数:5,代码来源:MyGpsCollection.cs
示例14: CheckDx11AndJoin
private static void CheckDx11AndJoin(MyObjectBuilder_World world, MyMultiplayerBase multiplayer)
{
bool needsDx11 = world.Checkpoint.RequiresDX >= 11;
if (!needsDx11 || MySandboxGame.IsDirectX11)
{
if (multiplayer.Battle)
{
if (multiplayer.BattleCanBeJoined)
{
MySessionLoader.LoadMultiplayerBattleWorld(world, multiplayer);
}
else
{
MyLog.Default.WriteLine("World downloaded but battle game ended");
MySessionLoader.UnloadAndExitToMenu();
MyGuiSandbox.Show(MyCommonTexts.MultiplayerErrorSessionEnded);
multiplayer.Dispose();
}
}
else if (multiplayer.Scenario)
{
MySessionLoader.LoadMultiplayerScenarioWorld(world, multiplayer);
}
else
{
MySessionLoader.LoadMultiplayerSession(world, multiplayer);
}
}
else
{
HandleDx11Needed();
}
}
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:33,代码来源:MyJoinGameHelper.cs
示例15: OnDownloadProgressChanged
private static void OnDownloadProgressChanged(MyGuiScreenProgress progress, MyDownloadWorldResult result, MyMultiplayerBase multiplayer)
{
switch (result.State)
{
case MyDownloadWorldStateEnum.Success:
progress.CloseScreen();
var world = multiplayer.ProcessWorldDownloadResult(result);
CheckDx11AndJoin(world, multiplayer);
break;
case MyDownloadWorldStateEnum.InProgress:
if (result.ReceivedBlockCount == 1)
MyLog.Default.WriteLine("First world part received");
string percent = (result.Progress * 100).ToString("0.");
float size = result.ReceivedDatalength;
string prefix = MyUtils.FormatByteSizePrefix(ref size);
string worldSize = size.ToString("0.") + " " + prefix + "B";
if (progress.Text != null)
progress.Text.Clear();
if (float.IsNaN(result.Progress))
{
MyLog.Default.WriteLine("World requested - preemble received");
if (progress.Text != null)
progress.Text.Append(MyTexts.Get(MyCommonTexts.DialogWaitingForWorldData));
}
else
{
if (progress.Text != null)
progress.Text.AppendFormat(MyTexts.GetString(MyCommonTexts.DialogTextDownloadingWorld), percent, worldSize);
}
break;
case MyDownloadWorldStateEnum.WorldNotAvailable:
MyLog.Default.WriteLine("World requested - world not available");
progress.Cancel();
MyGuiSandbox.Show(MyCommonTexts.DialogDownloadWorld_WorldDoesNotExists);
multiplayer.Dispose();
break;
case MyDownloadWorldStateEnum.ConnectionFailed:
MyLog.Default.WriteLine("World requested - connection failed");
progress.Cancel();
MyGuiSandbox.Show(MyTexts.AppendFormat(new StringBuilder(), MyCommonTexts.MultiplayerErrorConnectionFailed, result.ConnectionError));
multiplayer.Dispose();
break;
case MyDownloadWorldStateEnum.DeserializationFailed:
case MyDownloadWorldStateEnum.InvalidMessage:
MyLog.Default.WriteLine("World requested - message invalid (wrong version?)");
progress.Cancel();
MyGuiSandbox.Show(MyCommonTexts.DialogTextDownloadWorldFailed);
multiplayer.Dispose();
break;
default:
throw new InvalidBranchException();
}
}
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:59,代码来源:MyJoinGameHelper.cs
示例16: OnJoinBattleFailed
private static void OnJoinBattleFailed(MyGuiScreenProgress progress, MyMultiplayerBase multiplayer, string status, bool statusFullMessage = false)
{
MySessionLoader.UnloadAndExitToMenu();
progress.Cancel();
StringBuilder error = new StringBuilder();
if (statusFullMessage)
error.Append(status);
else
error.AppendFormat(MySpaceTexts.DialogTextJoinBattleFailed, status);
MyGuiScreenMessageBox mb = MyGuiSandbox.CreateMessageBox(messageText: error, messageCaption: MyTexts.Get(MyCommonTexts.MessageBoxCaptionError));
MyGuiSandbox.AddScreen(mb);
}
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:14,代码来源:MyJoinGameHelper.cs
示例17: OnJoinFailed
private static void OnJoinFailed(MyGuiScreenProgress progress, MyMultiplayerBase multiplayer, string status)
{
if (multiplayer != null)
{
multiplayer.Dispose();
}
progress.Cancel();
StringBuilder error = new StringBuilder();
error.AppendFormat(MyCommonTexts.DialogTextJoinWorldFailed, status);
MyGuiScreenMessageBox mb = MyGuiSandbox.CreateMessageBox(messageText: error, messageCaption: MyTexts.Get(MyCommonTexts.MessageBoxCaptionError));
MyGuiSandbox.AddScreen(mb);
}
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:13,代码来源:MyJoinGameHelper.cs
示例18: DownloadBattleWorld
public static void DownloadBattleWorld(MyMultiplayerBase multiplayer)
{
StringBuilder text = MyTexts.Get(MyCommonTexts.MultiplayerStateConnectingToServer);
MyGuiScreenProgress progress = new MyGuiScreenProgress(text, MyCommonTexts.Cancel);
MyGuiSandbox.AddScreen(progress);
// Set focus to different control than Cancel button (because focused Cancel button can be unexpectedly pressed when sending a chat message - in case server has just started game).
progress.FocusedControl = progress.RotatingWheel;
progress.ProgressCancelled += () =>
{
MySessionLoader.UnloadAndExitToMenu();
};
DownloadWorld(progress, multiplayer);
}
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:16,代码来源:MyJoinGameHelper.cs
示例19: StartServer
/// <summary>
/// Starts multiplayer server with current world
/// </summary>
internal void StartServer(MyMultiplayerBase multiplayer)
{
//Debug.Assert(multiplayer == null, "You've forgot to call UnloadMultiplayer() first");
multiplayer.WorldName = Name;
multiplayer.GameMode = Settings.GameMode;
multiplayer.WorldSize = WorldSizeInBytes;
multiplayer.AppVersion = MyFinalBuildConstants.APP_VERSION;
multiplayer.DataHash = MyDataIntegrityChecker.GetHashBase64();
multiplayer.InventoryMultiplier = Settings.InventorySizeMultiplier;
multiplayer.AssemblerMultiplier = Settings.AssemblerEfficiencyMultiplier;
multiplayer.RefineryMultiplier = Settings.RefinerySpeedMultiplier;
multiplayer.WelderMultiplier = Settings.WelderSpeedMultiplier;
multiplayer.GrinderMultiplier = Settings.GrinderSpeedMultiplier;
multiplayer.MemberLimit = Settings.MaxPlayers;
multiplayer.Mods = Mods;
multiplayer.ViewDistance = Settings.ViewDistance;
multiplayer.Battle = Battle;
multiplayer.Scenario = IsScenario;
if (Engine.Platform.Game.IsDedicated)
(multiplayer as MyDedicatedServerBase).SendGameTagsToSteam();
MyHud.Chat.RegisterChat(multiplayer);
Static.Gpss.RegisterChat(multiplayer);
}
开发者ID:liiir1985,项目名称:SpaceEngineers,代码行数:28,代码来源:MySession.cs
示例20: DownloadWorld
private static void DownloadWorld(MyGuiScreenProgress progress, MyMultiplayerBase multiplayer)
{
if (progress.Text != null)
{
progress.Text.Clear();
progress.Text.Append(MyTexts.Get(MyCommonTexts.MultiplayerStateConnectingToServer));
}
MyLog.Default.WriteLine("World requested");
const float worldRequestTimeout = 40; // in seconds
Stopwatch worldRequestTime = Stopwatch.StartNew();
ulong serverId = multiplayer.GetOwner();
bool connected = false;
progress.Tick += () =>
{
P2PSessionState state = default(P2PSessionState);
Peer2Peer.GetSessionState(multiplayer.ServerId, ref state);
if (!connected && state.ConnectionActive)
{
MyLog.Default.WriteLine("World requested - connection alive");
connected = true;
if (progress.Text != null)
{
progress.Text.Clear();
progress.Text.Append(MyTexts.Get(MyCommonTexts.MultiplayerStateWaitingForServer));
}
}
//progress.Text.Clear();
//progress.Text.AppendLine("Connecting: " + state.Connecting);
//progress.Text.AppendLine("ConnectionActive: " + state.ConnectionActive);
//progress.Text.AppendLine("Relayed: " + state.UsingRelay);
//progress.Text.AppendLine("Bytes queued: " + state.BytesQueuedForSend);
//progress.Text.AppendLine("Packets queued: " + state.PacketsQueuedForSend);
//progress.Text.AppendLine("Last session error: " + state.LastSessionError);
//progress.Text.AppendLine("Original server: " + serverId);
//progress.Text.AppendLine("Current server: " + multiplayer.Lobby.GetOwner());
//progress.Text.AppendLine("Game version: " + multiplayer.AppVersion);
if (serverId != multiplayer.GetOwner())
{
MyLog.Default.WriteLine("World requested - failed, server changed");
progress.Cancel();
MyGuiSandbox.Show(MyCommonTexts.MultiplayerErrorServerHasLeft);
multiplayer.Dispose();
}
if (worldRequestTime.IsRunning && worldRequestTime.Elapsed.TotalSeconds > worldRequestTimeout)
{
MyLog.Default.WriteLine("World requested - failed, server changed");
progress.Cancel();
MyGuiSandbox.Show(MyCommonTexts.MultiplaterJoin_ServerIsNotResponding);
multiplayer.Dispose();
}
};
var downloadResult = multiplayer.DownloadWorld();
downloadResult.ProgressChanged += (result) =>
{
worldRequestTime.Stop();
OnDownloadProgressChanged(progress, result, multiplayer);
};
progress.ProgressCancelled += () =>
{
downloadResult.Cancel();
multiplayer.Dispose();
//var joinScreen = MyScreenManager.GetScreenWithFocus() as MyGuiScreenJoinGame;
//if (joinScreen != null)
// joinScreen.ReloadList();
};
}
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:75,代码来源:MyJoinGameHelper.cs
注:本文中的MyMultiplayerBase类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论