예제 #1
0
        private RegistryResponse CallRegisteredFunction(JSMarshallContainer marshallContainer)
        {
            // Check registry for functions that have return values.
            if (_registry.ContainsKey(marshallContainer.MethodName))
            {
                return(WrapException(() =>
                {
                    var result = _registry[marshallContainer.MethodName](marshallContainer);

                    return new RegistryResponse(result);
                }));
            }

            // Check registry for void functions.
            if (_registryVoid.ContainsKey(marshallContainer.MethodName))
            {
                return(WrapException(() =>
                {
                    _registryVoid[marshallContainer.MethodName](marshallContainer);

                    return new RegistryResponse(null, RegistryErrorType.None);
                }));
            }

            // Spit out an error if unhandled.
            return(new RegistryResponse(null, RegistryErrorType.UnknownValue));
        }
예제 #2
0
        private void ChatEntered(JSMarshallContainer container)
        {
            var data = new ChatEntered(container);

            _chatManager.SendChatToServer(data.Chat);

            ClearChatInput();
        }
예제 #3
0
        protected void ChangeZoom(JSMarshallContainer container)
        {
            var data = container as ChangeZoom;

            if (data.ZoomDirection == ZoomDirection.In)
            {
                Camera.Zoom += data.Amount;
            }
            else
            {
                Camera.Zoom -= data.Amount;
            }
        }
예제 #4
0
        protected void ChangeZoom(JSMarshallContainer container)
        {
            var data = container as ChangeZoom;

            if (data.ZoomDirection == ZoomDirection.In)
            {
                Camera.Zoom += data.Amount;
            }
            else
            {
                Camera.Zoom -= data.Amount;
            }


            MathHelper.Clamp(Camera.Zoom, 0.1f, 1f);
        }
예제 #5
0
        private async Task <RegistryResponse> CallRegisteredFunctionAsync(JSMarshallContainer marshallContainer)
        {
            // Spit out error if unhandled.
            if (!_registry.ContainsKey(marshallContainer.MethodName))
            {
                return(new RegistryResponse(null, RegistryErrorType.UnknownValue));
            }

            // Async call function and return response.
            try
            {
                var result = await _registryAsync[marshallContainer.MethodName](marshallContainer);

                return(new RegistryResponse(result));
            }
            catch (Exception e)
            {
                // Toss error in message response and hand it back.
                return(new RegistryResponse(e));
            }
        }
예제 #6
0
        protected void SendStructurePlacementRequest(JSMarshallContainer request)
        {
            var req = request as StructurePlacementRequest;//Hmmm...would be nice to come up with a way to avoid this.

            _messageService.SendStructurePlacementRequest(req.StructureType, new Vector2(req.PosX, req.PosY), _playerShipManager.PlayerShip.Id);
        }
예제 #7
0
 private void FetchChats(JSMarshallContainer container)
 {
     ClearChatInput();
     SetChatHistory(_chatManager.GetChatsJson());
 }
예제 #8
0
 public ChatEntered(JSMarshallContainer container)
 {
     Chat = container.Arguments.FirstOrDefault().ToString();
 }