public DesktopInputManager(IJoystickInput joystickInput, IKeyboardInput keyboardInput, IMouseScreenInput mouseScreenInput, IControlManager controlManager)
 {
     this.joystickInput    = joystickInput;
     this.keyboardInput    = keyboardInput;
     this.mouseScreenInput = mouseScreenInput;
     this.controlManager   = controlManager;
 }
 public PlayerMind()
 {
     // set args
     _args = new KeyboardHandler();
     // set gravity
     _gravity = 10;
     // set speed
     _speed = 12;
     // set jump
     _jump = 0;
     // set counterforce
     _counterForce = 0;
     // set velocity
     _velocity.X = 1;
     _velocity.Y = -1;
     // set facing direction
     _facingDirectionX = 1;
     // set player mind ID
     _mindID = "Player";
     // set collision flags
     _floorCollide = false;
     _inAir        = true;
     _onFloor      = false;
     _rightCollide = false;
     _leftCollide  = false;
     // set starting score
     _score = 0;
 }
Exemple #3
0
        /// <summary>
        /// Receives keyboard event data to control entity movement
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        public void OnNewKeyboardInput(object sender, IKeyboardInput args)
        {
            // SET '_args' to 'args'
            _args = args;

            // SET '_inputFlag' to true
            _inputFlag = true;

            // IF '_inputFlag' is set to true
            if (_inputFlag)
            {
                // FOR each key that is currently being pressed
                foreach (Keys k in _args.GetInputKey())
                {
                    // IF the UP key is pressed AND the paddle is not at the top border THEN move the paddle up
                    if (k == Keys.Up && ((IPosition)args.GetEntityComponents()[_guid][typeof(Position)]).YPos > 0)
                    {
                        ((IPosition)args.GetEntityComponents()[_guid][typeof(Position)]).YPos -= ((IMove)args.GetEntityComponents()[_guid][typeof(Move)]).Speed.Y;
                    }
                    // IF the DOWN key is pressed AND the paddle is not at the bottom of the screen THEN move the paddle down
                    if (k == Keys.Down && ((IPosition)args.GetEntityComponents()[_guid][typeof(Position)]).YPos < 900 - 100)
                    {
                        ((IPosition)args.GetEntityComponents()[_guid][typeof(Position)]).YPos += ((IMove)args.GetEntityComponents()[_guid][typeof(Move)]).Speed.Y;
                    }
                }
            }
        }
Exemple #4
0
 public Player(GameData gameData, IKeyboardInput keyboardInput, List <IAGameObject> weapon)
 {
     _keyboardInput = keyboardInput;
     _gameData      = gameData;
     _weapon        = weapon;
     PlayerSetup();
 }
Exemple #5
0
        public void OnNewKeyboardInput(object sender, IKeyboardInput args)
        {
            if (!_ignoreInput)
            {
                if (args.GetInputKey().Contains(Keys.P))
                {
                    _ignoreInput = true;

                    // Spawn Player
                    _demo.Spawn <Player>("Player", _demo.LoadTexture("Smiley"), 0, 500);
                }
                else if (args.GetInputKey().Contains(Keys.H))
                {
                    _ignoreInput = true;

                    // Spawn Hostile
                    _demo.Spawn <Hostile>("Hostile", _demo.LoadTexture("Hostile"), 100, 300);
                }
                else if (args.GetInputKey().Contains(Keys.M))
                {
                    _ignoreInput = true;

                    // Load background music
                    _demo.PlaySong("Background_Music", 1.0f, true);
                }
            }
        }
Exemple #6
0
        public InputManager(IConfigurationManager configurationManage, IKeyboardInput keyboardInput)
        {
            _keyboardInput  = keyboardInput;
            _mappingActions = LoadActionMappings(configurationManage);
            _actions        = new Dictionary <InputActionType, InputAction>();

            _keyboardInput.KeyPressed += IsKeyPressed;
        }
Exemple #7
0
 private void NextLevelPreprocess()
 {
     _gameManager.DeInitialise();
     _gameEngine.DeInitialise();
     _levelManager.DeInitialise();
     (_keyboardInput as KeyboardInput).Dispose();
     _keyboardInput = null;
 }
        public InputComponent(Dictionary <Keys, InputAction> keyboardMappings, IKeyboardInput keyboardInput, params IMovementComponent[] movementComponent)
        {
            _keyboardMappings = keyboardMappings;

            Contract.Assert(movementComponent != null, "InputComponent has a dependency on the MovementComponent");
            _movementComponent = movementComponent;
            _keyboardInput     = keyboardInput;
        }
Exemple #9
0
 public void DeInitialise()
 {
     _gameData = null;
     _gameManager.DeInitialise();
     _gameEngine.DeInitialise();
     _levelManager.DeInitialise();
     (_keyboardInput as KeyboardInput).Dispose();
     _keyboardInput = null;
 }
Exemple #10
0
 public static void InitializeServices(IServiceProvider serviceProvider)
 {
     KeyboardInput   = (IKeyboardInput)serviceProvider.GetService(typeof(IKeyboardInput));
     MouseInput      = (IMouseInput)serviceProvider.GetService(typeof(IMouseInput));
     CursorManager   = (ICursorManager)serviceProvider.GetService(typeof(ICursorManager));
     GraphicsManager = (IGraphicsManager)serviceProvider.GetService(typeof(IGraphicsManager));
     ResourceManager = (IResourceManager)serviceProvider.GetService(typeof(IResourceManager));
     Debug           = (IDebug)serviceProvider.GetService(typeof(IDebug));
 }
Exemple #11
0
        public static void Initialise(IKeyboardInput input)
        {
            if (_instance != null)
            {
                throw new System.InvalidOperationException("Already Created");
            }

            _instance = new Keyboard(input);
        }
 private void PostLoadInitialise()
 {
     _keyboardInput = new KeyboardInput(new MenuKeyManager());
     //_keyboardInput.KBPreviewEventInitialise();
     _keyboardInput.KBEventInitialise();
     _gameMain = new GameMain(this);
     _gameMain.Initialise(GameGrid);
     SetupDataContext();
 }
Exemple #13
0
 /// <summary>
 /// Constructor for PlayerIdleState
 /// </summary>
 /// <param name="pAnimator"></param>
 /// <param name="pAudioPlayer"></param>
 /// <param name="pArgs"></param>
 public PlayerIdleState(int pEntityID, IAnimator pAnimator, IAudioPlayer pAudioPlayer, IKeyboardInput pArgs)
 {
     _animator    = pAnimator;
     _audioPlayer = pAudioPlayer;
     _args        = pArgs;
     // INSTANTIATE _frameTime
     _frameTime = 0.009f;
     _entityUID = pEntityID;
 }
Exemple #14
0
        public void ShowKeyBoard(IKeyboardInput j_InputField)
        {
            if (j_InputField == j_input)
            {
                return;
            }

            if (!isListeningForVoiceCommand)
            {
                JMRVoiceManager.OnSpeechResults   += OnSpeechResult;
                JMRVoiceManager.OnSpeechError     += OnSpeechError;
                JMRVoiceManager.OnSpeechCancelled += OnSpeechCancelled;
            }

            if (!gameObject.activeInHierarchy)
            {
                gameObject.SetActive(true);
            }

            if (j_InputField != null && j_InputField != j_input)
            {
                if (j_input != null)
                {
                    j_input.OnDeselect();
                }

                MonoBehaviour inputField = (MonoBehaviour)j_InputField;
                if (j_InputField.j_KeyboardPosition != null)
                {
                    transform.position = j_InputField.j_KeyboardPosition.position;
                    transform.rotation = j_InputField.j_KeyboardPosition.rotation;
                }
                else
                {
                    if (inputField.transform.position.y >= 0)
                    {
                        transform.position = inputField.transform.position + Vector3.down * 0.4f;
                        transform.rotation = inputField.transform.rotation;
                    }
                    else
                    {
                        transform.position = inputField.transform.position + Vector3.up * 0.4f;
                        transform.rotation = inputField.transform.rotation;
                    }
                }

                this.j_input = j_InputField;
                cachedTex    = string.IsNullOrEmpty(j_input.Text) ? "" : j_input.Text;
                if (string.IsNullOrEmpty(cachedTex))
                {
                    StartCoroutine(WaitTillEOF());
                }
                prevText          = "";
                isShown           = true;
                showInputfieldTxt = true;
            }
        }
Exemple #15
0
 private void OnSpeechCancelled(string arg1, long arg2)
 {
     JMRVoiceManager.Instance.HideVoiceToolkit();
     if (isListeningForVoiceCommand && voiceCommandField != null)
     {
         isListeningForVoiceCommand = false;
         HideKeyBoard();
     }
     voiceCommandField = null;
 }
Exemple #16
0
 private void OnSpeechResult(string command, long timestamp)
 {
     JMRVoiceManager.Instance.HideVoiceToolkit();
     if (isListeningForVoiceCommand && voiceCommandField != null)
     {
         prevText = voiceCommandField.Text = command;
         isListeningForVoiceCommand = false;
         HideKeyBoard(false, false, true);
     }
     voiceCommandField = null;
 }
Exemple #17
0
        public TextInputMachine(IKeyboardInput _keyboardInput, MonoFont font)
        {
            keyboardInput = _keyboardInput;

            Font         = font;
            AllowedChars = "";
            foreach (string line in font.Characters)
            {
                AllowedChars += line;
            }
        }
Exemple #18
0
    void Start()
    {
        mGui = guiMain;
        mKeyboardInput = kbInput;
        mPlayer = player;
        mBullet = bullet;
        mPlayer.BulletRefresh(mBullet);
        mPlayerCtrl = new PlayerCtrl(mPlayer, camera, Setting.PLAYER_SPEED);
        mEngine = new Engine();

        mKeyboardInput.Init(mPlayerCtrl);
        mGui.Init(mPlayerCtrl, mEngine);
    }
Exemple #19
0
        /// <summary>
        /// PlayerJumpState constructor
        /// </summary>
        /// <param name="pAnimator"></param>
        /// <param name="pArgs"></param>
        public PlayerJumpState(int pEntityID, IAnimator pAnimator, IAudioPlayer pAudioPlayer, IKeyboardInput pArgs, IPhysicsComponent pPhysicsComponent)
        {
            _animator    = pAnimator;
            _audioPlayer = pAudioPlayer;
            _args        = pArgs;
            // INSTANTIATE _frameTime
            _frameTime = 0.009f;
            _entityUID = pEntityID;

            _ySpeed = 3;

            _physicsComponent = pPhysicsComponent;
        }
Exemple #20
0
        public GameScene(IDynamicRenderer renderer, IKeyboardInput keyboardInput, IMouseInput mouseInput)
        {
            this.renderer = renderer;
            renderer.Tick += (s, e) => Tick();

            this.keyboardInput = keyboardInput;
            this.mouseInput = mouseInput;
            this.mouseInput.OnMouseMoved += (s, e) => lastMousePosition = e;
            lastMousePosition = this.mouseInput.MousePosition;

            obstacles = GenerateObstacles();
            TestTriangulation();
        }
Exemple #21
0
 private void HandleMultiLine(IKeyboardInput input)
 {
     if (input.isMultiLineSupported())
     {
         cachedTex          = j_input.Text;
         suggestedText.text = "";
     }
     else
     {
         HideKeyBoard();
     }
     j_prevButton = "";
 }
Exemple #22
0
    void Start()
    {
        mGui           = guiMain;
        mKeyboardInput = kbInput;
        mPlayer        = player;
        mBullet        = bullet;
        mPlayer.BulletRefresh(mBullet);
        mPlayerCtrl = new PlayerCtrl(mPlayer, camera, Setting.PLAYER_SPEED);
        mEngine     = new Engine();

        mKeyboardInput.Init(mPlayerCtrl);
        mGui.Init(mPlayerCtrl, mEngine);
    }
Exemple #23
0
        public Chip8Emulator(IKeyboardInput keyboardInput, ISound audioPlayer)
        {
            DisplayModel = new DisplayModel();

            Memory = new Chip8Memory();

            CPU = new Chip8CPU(Memory);

            random = new Random();

            KeyboardInput = keyboardInput;

            SoundPlayer = audioPlayer;
        }
Exemple #24
0
 public Z48Spectrum()
 {
     _memory = new Z48Memory();
     var registerFile = new RegisterFile();
     var lookupTables = new LookupTables();
     var cpuStack = new CpuStack(_memory, registerFile);
     _keyboard = new Keyboard();
     _video = new Video(_memory);
     var outputDevice = (IOutputDevice)_video;
     var inputDevice = (IInputDevice) _keyboard;
     _inputOutputDevice = new Z48IO(inputDevice, outputDevice) { Keyboard = inputDevice, Video = outputDevice };
     var alu = new Alu(_memory, registerFile, cpuStack, lookupTables);
     var executionUnit = new ExecutionUnit(_memory, registerFile, cpuStack, alu, _inputOutputDevice, lookupTables);
     _zilogZ80Cpu = new ZilogZ80Cpu(_memory, _inputOutputDevice, new CpuStack(_memory, registerFile), lookupTables, executionUnit, registerFile);
 }
Exemple #25
0
 public void SetFocus(IKeyboardInput control)
 {
     if (_focus == control)
     {
         return;
     }
     if (_focus != null)
     {
         _focus.OnLostFocus();
     }
     _focus = control;
     if (_focus != null)
     {
         _focus.OnGotFocus();
     }
 }
Exemple #26
0
    public bool SpawnKeyboard(IKeyboardInput input)
    {
        if (!keyboardPrefab && !supportV2Keyboard)
        {
            return(false);
        }
        else if (!keyboardV2Prefab && supportV2Keyboard)
        {
            return(false);
        }

        JMRVirtualKeyBoard obj = Instantiate(supportV2Keyboard ? keyboardV2Prefab : keyboardPrefab).GetComponent <JMRVirtualKeyBoard>();

        SetRaycastCameraToCanvas(obj.GetComponent <Canvas>());
        obj.ShowKeyBoard(input);
        return(true);
    }
Exemple #27
0
 private void OnSpeechError(string obj)
 {
     JMRVoiceManager.Instance.HideVoiceToolkit();
     if (isListeningForVoiceCommand && voiceCommandField != null)
     {
         isListeningForVoiceCommand = false;
         if (obj == "ERROR_NO_MATCH")
         {
             HideKeyBoard();
         }
         else
         {
             ShowKeyBoard(voiceCommandField);
         }
     }
     voiceCommandField = null;
 }
Exemple #28
0
        private void NextLevelInit()
        {
            _gameData.WriteToConsole.Invoke(new[] { "\rInitialising...\r" });
            _keyboardInput = new KeyboardInput(new PlayKeyManager());
            _keyboardInput.KBPreviewEventInitialise();
            _gameEngine    = new GameEngine(_renderer);
            IsLevelRunning = false;
            IsNewGame      = true;
            UserReady      = false;
            IsNewGame      = false;
            SetupGameData();
            _weaponEnemy = new List <IAGameObject>();
            GameObjectLoader gol = new GameObjectLoader("Assets//Scripts//Gamedat.xml");

            _levelFactory     = new LevelFactory(gol.GetLevelParser(), gol.GetAiParser(), _gameData);
            _munitionsFactory = new MunitionsFactory(_gameData);
            _weaponPlayer     = new List <IAGameObject>();
            _player           = new Player(_gameData, _keyboardInput, _weaponPlayer);
        }
Exemple #29
0
        public static void Initialise(IKeyboardInput keyboardInput, IWindow window, IMouseInput mouseInput, ISoundOutput soundOutput, long seed)
        {
            if (_instance != null)
            {
                throw new System.InvalidOperationException("Already Created");
            }

            Keyboard.Initialise(keyboardInput);
            _instance              = new Engine();
            _instance._root        = new Ent(null);
            _instance._time        = new Time();
            _instance._window      = window;
            _instance._toBeUpdated = new Stack <IEnt>();
            _instance._mouse       = mouseInput;
            _instance._sound       = soundOutput;
            _instance.Seed         = seed;

            _instance._window.OnStart();
            _instance._time.Start();
        }
        /// <summary>
        /// Create the user interface instance.
        /// </summary>
        public UserInterface()
        {
            // sanity test
            if (_content == null)
            {
                throw new Exceptions.InvalidStateException("Cannot create a UserInterface before calling UserInterface.Initialize()!");
            }

            // create default input providers
            MouseInputProvider    = new DefaultInputProvider();
            KeyboardInputProvider = new DefaultInputProvider();

            // create draw utils
            DrawUtils = new DrawUtils();

            // create the root panel
            Root = new RootPanel();

            // set default cursor
            SetCursor(CursorType.Default);
        }
Exemple #31
0
        /// <summary>
        /// Constructor for PlayerRunState
        /// </summary>
        public PlayerRunState(int pEntityID, IAnimator pAnimator, IAudioPlayer pAudioPlayer, IKeyboardInput pArgs, PassFloat pInvertTexture, IPhysicsComponent pPhysicsComponent)
        {
            // INSTANTIATE _animator
            _animator = pAnimator;
            // INSTANTIATE _audioPlayer
            _audioPlayer = pAudioPlayer;
            // INSTANTIATE _args
            _args = pArgs;
            // INSTANTIATE _frameTime
            _frameTime = 0.009f;
            _entityUID = pEntityID;

            // set _xSpeed
            _xSpeed = 7;
            // set _ySpeed
            _ySpeed = 35;
            // set facing direction
            _facingDirectionX = 1;

            _invertTexture    = pInvertTexture;
            _physicsComponent = pPhysicsComponent;
        }
Exemple #32
0
 public PlayerMind()
 {
     // set args
     _args = new KeyboardHandler();
     // set _dLocation
     _dLocation = new Vector2(0, 0);
     // set _xSpeed
     _xSpeed = 7;
     // set _ySpeed
     _ySpeed = 35;
     // set facing direction
     _facingDirectionX = 1;
     // set player mind ID
     _mindID = "Player";
     // set collision flags
     _inAir        = true;
     _onFloor      = false;
     _rightCollide = false;
     _leftCollide  = false;
     // set starting score
     _score = 0;
 }
Exemple #33
0
		public static void SetEngineInput(IMouseInput mouse, IKeyboardInput keyboard)
		{
			DualityApp.Mouse = mouse;
			DualityApp.Keyboard = keyboard;
		}
Exemple #34
0
 public PongInput(IKeyboardInput keyboardInput)
 {
     this.keyboardInput = keyboardInput;
 }