private void HandleCameraViewsReply(ReplyWrapper replyWrapper) { if (!replyWrapper.RequestHasMoreReplies) { ApplyNextView(); return; } CameraViewsReply viewDef = replyWrapper.CameraViewsReply; var eye = new Vector3d(viewDef.EyePointX, viewDef.EyePointY, viewDef.EyePointZ); var entry = new Entry { DisplayLabel = viewDef.DisplayLabel, Position = _coordinateUtility.ConvertPointFromIModel(eye), Rotation = Quaternion.AngleAxis((float)viewDef.Roll + 90.0f, Vector3.right) * Quaternion.AngleAxis((float)-viewDef.Pitch, Vector3.up) * Quaternion.AngleAxis((float)-viewDef.Yaw, Vector3.forward) }; _entries.Add(entry); }
private void OnReceiveNetworkMessage(object info) { var wrapper = (ReceiveWrapper)info; var message = wrapper.message as AMultiplayerMessage; if (_hosting) { /* * Поведение хоста при приеме сообщения */ switch (message.highType) { case MultiplayerMessageType.LogIn: { var except = new ExceptWrapper { message = wrapper.message, channel = 0, }; EventManager.Singleton.Publish(GameEventType.SendNetworkExceptMessage, except); var reply = new ReplyWrapper { message = RegisterPlayer(message as LogIn), connection = wrapper.connection, channel = 0, }; EventManager.Singleton.Publish(GameEventType.SendNetworkReplyMessage, reply); foreach (var value in _playerModels.Values) { var player = new ReplyWrapper { message = new LogIn(value.playerName), connection = wrapper.connection, channel = 0, }; EventManager.Singleton.Publish(GameEventType.SendNetworkReplyMessage, player); } break; } case MultiplayerMessageType.Move: { _multiplayerScene.Move(message as Move); break; } case MultiplayerMessageType.LogOut: { var send = new SendWrapper { message = wrapper.message, channel = 0, }; EventManager.Singleton.Publish(GameEventType.SendNetworkMessage, send); var reply = new ReplyWrapper { message = UnregisterPlayer(message as LogOut), connection = wrapper.connection, channel = 0, }; EventManager.Singleton.Publish(GameEventType.SendNetworkReplyMessage, reply); break; } } return; } /* * Поведение клиента при приеме сообщения */ switch (message.highType) { case MultiplayerMessageType.LogIn: { if (_actualPlayer.Logged) { RegisterPlayer(message as LogIn); } break; } case MultiplayerMessageType.LoggedIn: { _actualPlayer.LoggedIn(message as LoggedIn); break; } case MultiplayerMessageType.SessionStarted: { EventManager.Singleton.Publish(GameEventType.SessionStarted, null); break; } case MultiplayerMessageType.TransformSync: { _multiplayerScene.UpdateRigidbody(message as TransformSync, wrapper.ping); break; } case MultiplayerMessageType.LogOut: { UnregisterPlayer(message as LogOut); break; } case MultiplayerMessageType.SessionEnded: { _actualPlayer.LoggedOut(); break; } case MultiplayerMessageType.LoggedOut: { _actualPlayer.LoggedOut(); break; } } }