public void ThenSWallShouldDisplay(string userWallInput, Table wallContentTable)
        {
            var wallContent = String.Join(Environment.NewLine, wallContentTable.Rows.Select(r => r["Message"]));

            InputTranslator.TranslateIntoAction(userWallInput);
            Assert.That(WallPresenter.ViewModel.Output, Is.EqualTo(wallContent));
        }
Ejemplo n.º 2
0
                private static bool PreUpdateDoubleAxisCommand(
                    InputBinding ____gamepadHorzBinding,
                    InputBinding ____gamepadVertBinding,
                    ref Vector2 ____value,
                    ref Vector2 ____cameraLookValue
                    )
                {
                    var axisX = InputTranslator.GetAxisName(____gamepadHorzBinding.axisID);
                    var axisY = InputTranslator.GetAxisName(____gamepadVertBinding.axisID);

                    if (_singleAxes.ContainsKey(axisX))
                    {
                        ____value.x           = _singleAxes[axisX];
                        ____cameraLookValue.x = _singleAxes[axisX];
                    }
                    if (_singleAxes.ContainsKey(axisY))
                    {
                        ____value.y           = _singleAxes[axisY];
                        ____cameraLookValue.y = _singleAxes[axisY];
                    }
                    if (____value.sqrMagnitude > 1f)
                    {
                        ____value.Normalize();
                    }
                    return(false);
                }
        public void TranslatesIntoGetWall()
        {
            var inputTranslator = new InputTranslator(controller, presenter);

            inputTranslator.TranslateIntoAction(UserName);

            presenter.Received().PrepareWallFor(Arg.Is <string>(userName => userName == UserName));
        }
Ejemplo n.º 4
0
 private static SteamVR_Action_Single.ChangeHandler CreateSingleAxisHandler(AxisIdentifier axis, int axisDirection = 1)
 {
     return((SteamVR_Action_Single fromAction, SteamVR_Input_Sources fromSource, float newAxis, float newDelta) =>
     {
         var axisName = InputTranslator.GetAxisName(axis);
         _axes[axisName] = axisDirection * Mathf.Round(newAxis * 10) / 10;
     });
 }
Ejemplo n.º 5
0
 public void SetUp()
 {
     translator = new InputTranslator();
     data = "3 3\n" +
            "...\n" +
            "...\n" +
            "...";
 }
Ejemplo n.º 6
0
        public static string KeyCodeToString(KeyCode key)
        {
            var config = OWInput.GetActivePadConfig() ?? InputUtil.GamePadConfig_Xbox;

            key = NormalizeKeyCode(key);
            return((int)key >= MinGamepadKey ?
                   XboxPrefix + JoystickButtonToXboxButton(InputTranslator.ConvertKeyCodeToButton(key, config)) :
                   key.ToString());
        }
Ejemplo n.º 7
0
 /// <summary>
 /// Checks the input mode.
 /// TODO: refactor the Menu logic to a menuLogic class or use a partial class definition as this file seems to become messy
 /// </summary>
 void CheckInputMode(InputTranslator translator)
 {
     if (rawInput)
     {
         translator.Mode = InputTranslator.InputMode.RAW;
         ButtonRepeat.Stop();
         ButtonDelay.Stop();
     }
 }
        public void TranslatesIntoFollowing()
        {
            var inputTranslator = new InputTranslator(controller, presenter);

            inputTranslator.TranslateIntoAction($"{UserName} follows {AnotherUserName}");

            controller.Received().FollowUser(Arg.Is <FollowUser>(follow => follow.SourceUser == UserName &&
                                                                 follow.TargetUser == AnotherUserName));
        }
        public void TranslatesIntoPostMessage()
        {
            var inputTranslator = new InputTranslator(controller, presenter);

            inputTranslator.TranslateIntoAction($"{UserName} -> {Message}");

            controller.Received().PostMessage(Arg.Is <PostMessage>(postMessage => postMessage.UserName == UserName &&
                                                                   postMessage.Message == Message));
        }
Ejemplo n.º 10
0
 public void Initialize(IPlayerLoopProcessor playerLoopProcessor, Labyrinth labyrinth)
 {
     PlayerLoopProcessor = playerLoopProcessor;
     _labyrinth          = labyrinth;
     _effectFactory      = new EffectFactory();
     _collectibleFactory = new CollectibleFactory();
     radar = new Radar();
     RotationManager?.Initialize(playerLoopProcessor);
     InputTranslator?.Initialize(playerLoopProcessor);
     InputListener?.Initialize(InputTranslator);
 }
Ejemplo n.º 11
0
 private static SteamVR_Action_Vector2.ChangeHandler CreateDoubleAxisHandler(AxisIdentifier axisX, AxisIdentifier axisY)
 {
     return((SteamVR_Action_Vector2 fromAction, SteamVR_Input_Sources fromSource, Vector2 axis, Vector2 delta) =>
     {
         var axisNameX = InputTranslator.GetAxisName(axisX);
         var axisNameY = InputTranslator.GetAxisName(axisY);
         var x = Mathf.Round(axis.x * 100) / 100;
         var y = Mathf.Round(axis.y * 100) / 100;
         _axes[axisNameX] = x;
         _axes[axisNameY] = y;
     });
 }
Ejemplo n.º 12
0
        private Ballz()
        {
            Teamnames = new List <string>();
            Graphics  = new GraphicsDeviceManager(this);
            InitSettings();
            Content.RootDirectory = "Content";
            if (Settings.MSAASamples > 1)
            {
                Graphics.PreferMultiSampling = true;
                msaaSettingsHandler          = (object sender, PreparingDeviceSettingsEventArgs args) =>
                {
                    args.GraphicsDeviceInformation.PresentationParameters.MultiSampleCount = Settings.MSAASamples;
                };
                Graphics.PreparingDeviceSettings += msaaSettingsHandler;
            }
            Graphics.IsFullScreen = Settings.Fullscreen;
            Graphics.PreferredBackBufferHeight = Settings.ScreenResolution.Height;
            Graphics.PreferredBackBufferWidth  = Settings.ScreenResolution.Width;
            Window.AllowUserResizing           = true;
            IsFixedTimeStep = false;

            Camera = new Camera();
            // create the Game Components
            GuiRenderer = new GuiRenderer(this);
            //var physics = new PhysicsControl(this);
            Input   = new InputTranslator(this);
            Network = new Network.Network(this);

            Components.Add(Input);
            //Components.Add(physics);
            Components.Add(Network);
            Components.Add(GuiRenderer);
            Components.Add(new PerformanceRenderer(this));

            Logic = new LogicControl(this);

            Services.AddService(Logic);
            Services.AddService(Input);

            Services.AddService(new SoundControl(this));

            //add eventhandlers to events
            Input.Input += Logic.HandleInputMessage;
            //input.Input += physics.HandleMessage;
            Input.Input += Network.HandleMessage;

            //Logic.Message += physics.HandleMessage;
            Logic.Message += Network.HandleMessage;
            //Logic.Message += gameRendering.HandleMessage;
            Logic.Message += GuiRenderer.HandleMessage;

            Network.Message += Logic.HandleNetworkMessage;
        }
        public UserFeatures()
        {
            WallPresenter  = new WallPresenter(Clock, new UserViewModel());
            UserController = new UserController(Bus);

            Bus.RegisterHandlers(new PostMessageHandler(Bus));
            Bus.RegisterHandlers(new FollowUserHandler(Bus));
            Bus.RegisterHandlers((IHandleMessagesOf <MessagePosted>)WallPresenter);
            Bus.RegisterHandlers((IHandleMessagesOf <UserFollowed>)WallPresenter);

            InputTranslator = new InputTranslator(UserController, WallPresenter);
        }
Ejemplo n.º 14
0
    private void Awake()
    {
        _eventSystem = new EventSystem();
        _eventSystem.Initialize();

        _inputSystem = new InputSystem();

        _inputTranslator = new InputTranslator();

        _audioManager = new AudioManager();
        _audioManager.Initialize();

        _bookManager = new BookManager(bookObject, bookCanvas);

        _worldCanvasManager = new WorldCanvasManager(worldCanvas, textField, scoreImage, sprites);
        _worldCanvasManager.Initialize();

        _inventoryManager = new InventoryManager();
        _inventoryManager.Initialize();

        _inventoryUIManager = new InventoryUIManager(inventoryCanvas);

        _sceneMenuUIManager = new SceneMenuUIManager(menuPanel, icon);

        _jsonManager = new JSONReadManager();
        _jsonManager.Initialize();
        _jsonManager.LoadFile("FoodObjectFile");
        _jsonManager.LoadFile("SceneObjectFile");

        _sceneManager = new SceneManager(mainCamera);
        _sceneManager.Initialize();

        // Assign EventTypes to EventListeners
        // and Add them to the EventSystem's list
        _eventSystem.addListener(EventType.KEY_PRESSED, _inputTranslator);

        _eventSystem.addListener(EventType.BOOK_INTERACT, _bookManager);
        _eventSystem.addListener(EventType.NUM_EVENT_TYPES, _bookManager);

        _eventSystem.addListener(EventType.BOOK_INTERACT, _audioManager);
        _eventSystem.addListener(EventType.PAGE_FLIPPED, _audioManager);
        _eventSystem.addListener(EventType.KNIFE_CUT, _audioManager);

        _eventSystem.addListener(EventType.POINTS_SCORED, _worldCanvasManager);

        _eventSystem.addListener(EventType.FOOD_INVENTORY, _inventoryUIManager);
        _eventSystem.addListener(EventType.SCREEN_PRESSED, _inventoryUIManager);

        _eventSystem.addListener(EventType.SCENE_MENU, _sceneMenuUIManager);
        _eventSystem.addListener(EventType.SCREEN_PRESSED, _sceneMenuUIManager);
    }
Ejemplo n.º 15
0
        void KeyPress(Area area, IPointer pointer, SharpMedia.Input.KeyCodes code,
                      SharpMedia.Input.KeyboardModifiers modeifiers, InputEventModifier inputModifier)
        {
            char chr = InputTranslator.Translate(code, modeifiers);

            buffer.Append(chr);
            currentLine.Append(chr);

            // FIXME: maximum buffer size.

            if (chr == '\n')
            {
                // We signal line read.
            }
        }
Ejemplo n.º 16
0
        public void Shutdown()
        {
            Radar?.Shutdown();
            ActivePlayer?.Shutdown();
            ActivePlayer = null;
            CameraController?.Shutdown();
            CameraController    = null;
            _collectibleFactory = null;
            radar = null;

            RotationManager?.Shutdown();
            InputTranslator?.Shutdown();
            InputListener?.Shutdown(inputManagerTranslator);
            UserInputManager?.Shutdown();
            ShutdownUI();
        }
Ejemplo n.º 17
0
                private static bool SingleAxisUpdate(
                    SingleAxisCommand __instance,
                    InputBinding ____gamepadBinding,
                    ref float ____value,
                    ref bool ____newlyPressedThisFrame,
                    ref float ____lastValue,
                    ref float ____lastPressedDuration,
                    ref float ____pressedDuration,
                    ref float ____realtimeSinceLastUpdate
                    )
                {
                    if (!IsInputEnabled)
                    {
                        return(false);
                    }

                    var positive = ____gamepadBinding.gamepadButtonPos;
                    var negative = ____gamepadBinding.gamepadButtonNeg;

                    ____newlyPressedThisFrame = false;
                    ____lastValue             = ____value;
                    ____value = 0f;


                    if (_buttons.ContainsKey(positive))
                    {
                        ____value += _buttons[positive];
                    }

                    if (_buttons.ContainsKey(negative))
                    {
                        ____value -= _buttons[negative];
                    }

                    var axis = InputTranslator.GetAxisName(____gamepadBinding.axisID);

                    if (_axes.ContainsKey(axis))
                    {
                        ____value += DeadzonedValue(_axes[axis] * ____gamepadBinding.axisDirection);
                    }

                    ____lastPressedDuration     = ____pressedDuration;
                    ____pressedDuration         = ((!__instance.IsPressed()) ? 0f : (____pressedDuration + (Time.realtimeSinceStartup - ____realtimeSinceLastUpdate)));
                    ____realtimeSinceLastUpdate = Time.realtimeSinceStartup;

                    return(false);
                }
Ejemplo n.º 18
0
        public Texture2D KeyTexture(KeyCode key)
        {
            if (_loadedTextures == null)
            {
                FillTextureLibrary();
            }
            var keyName = ModInputLibrary.KeyCodeToString(key);

            if (_loadedTextures.ContainsKey(keyName))
            {
                return(_loadedTextures[keyName]);
            }
            var config  = OWInput.GetActivePadConfig() ?? InputUtil.GamePadConfig_Xbox;
            var toStore = (int)key >= ModInputLibrary.MinGamepadKey ?
                          ButtonPromptLibrary.SharedInstance.GetButtonTexture(InputTranslator.ConvertKeyCodeToButton(key, config)) :
                          ButtonPromptLibrary.SharedInstance.GetButtonTexture(key);

            _loadedTextures.Add(keyName, toStore);
            return(toStore);
        }
Ejemplo n.º 19
0
                private static bool PreUpdateDoubleAxisCommand(
                    InputBinding ____gamepadHorzBinding,
                    InputBinding ____gamepadVertBinding,
                    ref Vector2 ____value,
                    ref Vector2 ____cameraLookValue
                    )
                {
                    if (!IsInputEnabled)
                    {
                        return(false);
                    }

                    var   axisX = InputTranslator.GetAxisName(____gamepadHorzBinding.axisID);
                    var   axisY = InputTranslator.GetAxisName(____gamepadVertBinding.axisID);
                    float x     = 0;
                    float y     = 0;

                    if (_axes.ContainsKey(axisX))
                    {
                        x = DeadzonedValue(_axes[axisX]);
                    }
                    if (_axes.ContainsKey(axisY))
                    {
                        y = DeadzonedValue(_axes[axisY]);
                    }

                    ____value.x           = x;
                    ____cameraLookValue.x = x;
                    ____value.y           = y;
                    ____cameraLookValue.y = y;

                    if (____value.sqrMagnitude > 1f)
                    {
                        ____value.Normalize();
                    }
                    return(false);
                }
Ejemplo n.º 20
0
        internal void FillTextureLibrary()
        {
            _loadedTextures = new Dictionary <string, Texture2D>();
            var config = OWInput.GetActivePadConfig() ?? InputUtil.GamePadConfig_Xbox;

            for (var code = ModInputLibrary.MinUsefulKey; code < ModInputLibrary.MaxUsefulKey; code++)
            {
                var key = (KeyCode)code;
                if (!Enum.IsDefined(typeof(KeyCode), key))
                {
                    continue;
                }
                var keyName = ModInputLibrary.KeyCodeToString(key);
                if (_loadedTextures.ContainsKey(keyName))
                {
                    continue;
                }
                var button  = InputTranslator.ConvertKeyCodeToButton(key, config);
                var toStore = (int)key >= ModInputLibrary.MinGamepadKey ?
                              ButtonPromptLibrary.SharedInstance.GetButtonTexture(button) :
                              ButtonPromptLibrary.SharedInstance.GetButtonTexture(key);
                _loadedTextures.Add(keyName, toStore);
            }
        }
 public void GivenUserPostsMessage(string postInput)
 {
     InputTranslator.TranslateIntoAction(postInput);
 }
 public void GivenIPostTheMessage(string input)
 {
     InputTranslator.TranslateIntoAction(input);
 }
Ejemplo n.º 23
0
 public static void SimulateInput(AxisIdentifier axis, float value)
 {
     _axes[InputTranslator.GetAxisName(axis)] = value;
 }
 public void WhenIVisitSWall(string input)
 {
     InputTranslator.TranslateIntoAction(input);
 }
Ejemplo n.º 25
0
        private static KeyCode StringToKeyCodeGamepad(string xboxKey)
        {
            var gamepadCode = XboxButtonToJoystickButton(xboxKey);

            return(gamepadCode == JoystickButton.None ? KeyCode.None : NormalizeKeyCode(InputTranslator.GetButtonKeyCode(gamepadCode)));
        }
Ejemplo n.º 26
0
        private GameOfLife BuildGame(String rawData)
        {
            var inputTranslator = new InputTranslator();
            var criteria = new GameCriteria
            {
                CellIterator = new CellIterator(),
                GameRules = new DefaultGameRules(),
                AliveValue = '*',
                DeadValue = '.'
            };
            var boardFactory = new BoardFactory(new RowTranslator(criteria.AliveValue, criteria.DeadValue));

            return new GameOfLife(rawData, criteria, inputTranslator, boardFactory);
        }
 public void WhenFollows(string user, string anotherUser)
 {
     InputTranslator.TranslateIntoAction($"{user} follows {anotherUser}");
 }
 public void ThenSWallShouldContain(string userWallInput, string wallContent)
 {
     InputTranslator.TranslateIntoAction(userWallInput);
     Assert.That(WallPresenter.ViewModel.Output, Is.EqualTo(wallContent));
 }