示例#1
0
        /// <summary>
        /// Creates and returns a keyboard definition object based on the layout and locale.
        /// </summary>
        /// <remarks>The keyboard controller implementing this method will have to check the
        /// availability of the keyboard and what engine provides it.</remarks>
        public virtual IKeyboardDefinition CreateKeyboard(string id, KeyboardFormat format, IEnumerable <string> urls)
        {
            DefaultKeyboardDefinition keyboard;

            if (!_keyboards.TryGetValue(id, out keyboard))
            {
                string[] parts = id.Split('_');
                string   layout, locale = null;
                if (parts.Length == 1)
                {
                    layout = parts[0];
                }
                else
                {
                    locale = parts[0];
                    layout = parts[1];
                }
                keyboard       = new DefaultKeyboardDefinition(id, layout, layout, locale, true);
                _keyboards[id] = keyboard;
            }

            keyboard.Format = format;

            // Clear any exisiting URL list
            keyboard.Urls.Clear();
            foreach (string url in urls)
            {
                keyboard.Urls.Add(url);
            }
            return(keyboard);
        }
        /// <summary>
        /// Creates and returns a keyboard definition object based on the ID.
        /// </summary>
        public IKeyboardDefinition CreateKeyboard(string id, KeyboardFormat format, IEnumerable <string> urls)
        {
            KeyboardDescription keyboard;

            if (!_keyboards.TryGet(id, out keyboard))
            {
                var firstCompatibleAdapter = _adaptors.Values.FirstOrDefault(adaptor => adaptor.CanHandleFormat(format));
                if (firstCompatibleAdapter == null)
                {
                    throw new ArgumentException(string.Format("Did not find {0} in {1} adapters", format, _adaptors.Count), "format");
                }
                keyboard = firstCompatibleAdapter.CreateKeyboardDefinition(id);
                _keyboards.Add(keyboard);
            }

            keyboard.Format = format;
            if (urls != null)
            {
                foreach (string url in urls)
                {
                    keyboard.Urls.Add(url);
                }
            }
            return(keyboard);
        }
示例#3
0
        /// <summary>
        /// Creates and returns a keyboard definition object based on the ID.
        /// </summary>
        public IKeyboardDefinition CreateKeyboard(string id, KeyboardFormat format, IEnumerable <string> urls)
        {
            KeyboardDescription keyboard;

            if (!_keyboards.TryGet(id, out keyboard))
            {
                var firstCompatibleAdapter = _adaptors.Values.FirstOrDefault(adaptor => adaptor.CanHandleFormat(format));
                if (firstCompatibleAdapter == null)
                {
                    Debug.Fail($"Could not load keyboard for {id}. Did not find {format} in {_adaptors.Count} adapters");
                    return(new UnsupportedKeyboardDefinition(id));
                }
                keyboard = firstCompatibleAdapter.CreateKeyboardDefinition(id);
                _keyboards.Add(keyboard);
            }

            keyboard.Format = format;
            if (urls != null)
            {
                foreach (string url in urls)
                {
                    keyboard.Urls.Add(url);
                }
            }
            return(keyboard);
        }
示例#4
0
        //Constructor
        public PlayerKeyboardInputSource(PlayerInputListener target, KeyboardFormat format)
        {
            //Set target player
            this.target = target;

            //Initialize keybindings
            setupKeybindings(format);
        }
 public bool CanHandleFormat(KeyboardFormat format)
 {
     switch (format)
     {
     case KeyboardFormat.Msklc:
     case KeyboardFormat.Unknown:
         return(true);
     }
     return(false);
 }
 public bool CanHandleFormat(KeyboardFormat format)
 {
     CheckDisposed();
     switch (format)
     {
     case KeyboardFormat.CompiledKeyman:
     case KeyboardFormat.Keyman:
         return(true);
     }
     return(false);
 }
示例#7
0
        public bool CanHandleFormat(KeyboardFormat format)
        {
            if (!HasKeyman)
            {
                return(false);
            }

            switch (format)
            {
            case KeyboardFormat.CompiledKeyman:
            case KeyboardFormat.Keyman:
            case KeyboardFormat.KeymanPackage:
                return(true);
            }
            return(false);
        }
示例#8
0
		public bool CanHandleFormat(KeyboardFormat format)
		{
			CheckDisposed();
			switch (format)
			{
				case KeyboardFormat.Msklc:
				case KeyboardFormat.Unknown:
					return true;
			}
			return false;
		}
		public bool CanHandleFormat(KeyboardFormat format)
		{
			CheckDisposed();
			switch (format)
			{
				case KeyboardFormat.CompiledKeyman:
				case KeyboardFormat.Keyman:
					return true;
			}
			return false;
		}
		/// <summary>
		/// Creates and returns a keyboard definition object based on the layout and locale.
		/// </summary>
		/// <remarks>The keyboard controller implementing this method will have to check the
		/// availability of the keyboard and what engine provides it.</remarks>
		public virtual IKeyboardDefinition CreateKeyboard(string id, KeyboardFormat format, IEnumerable<string> urls)
		{
			DefaultKeyboardDefinition keyboard;
			if (!_keyboards.TryGetValue(id, out keyboard))
			{
				string[] parts = id.Split('_');
				string layout, locale = null;
				if (parts.Length == 1)
				{
					layout = parts[0];
				}
				else
				{
					locale = parts[0];
					layout = parts[1];
				}
				keyboard = new DefaultKeyboardDefinition(id, layout, layout, locale, true);
				_keyboards[id] = keyboard;
			}

			keyboard.Format = format;
			
			// Clear any exisiting URL list
			keyboard.Urls.Clear();
			foreach (string url in urls)
				keyboard.Urls.Add(url);
			return keyboard;
		}
示例#11
0
        //Sets up the keybindings for player input given the desired format
        private void setupKeybindings(KeyboardFormat format)
        {
            //For the selected format
            switch (format)
            {
            case KeyboardFormat.ARROWS:

                //Setup delegates for the arrow keys
                Keybinding upKeybinding = new Keybinding()
                {
                    key = VirtualKey.Up, function = OnUpInput
                };
                Keybinding downKeybinding = new Keybinding()
                {
                    key = VirtualKey.Down, function = OnDownInput
                };
                Keybinding leftKeybinding = new Keybinding()
                {
                    key = VirtualKey.Left, function = OnLeftInput
                };
                Keybinding rightKeybinding = new Keybinding()
                {
                    key = VirtualKey.Right, function = OnRightInput
                };
                Keybinding attackKeybinding = new Keybinding()
                {
                    key = VirtualKey.M, function = OnAttackInput
                };

                //Add keybindings to list
                keybindings.Add(upKeybinding);
                keybindings.Add(downKeybinding);
                keybindings.Add(leftKeybinding);
                keybindings.Add(rightKeybinding);
                keybindings.Add(attackKeybinding);

                break;

            case KeyboardFormat.WASD:

                //Setup delegates for the WASD keys
                Keybinding WKeybinding = new Keybinding()
                {
                    key = VirtualKey.W, function = OnUpInput
                };
                Keybinding SKeybinding = new Keybinding()
                {
                    key = VirtualKey.S, function = OnDownInput
                };
                Keybinding AKeybinding = new Keybinding()
                {
                    key = VirtualKey.A, function = OnLeftInput
                };
                Keybinding DKeybinding = new Keybinding()
                {
                    key = VirtualKey.D, function = OnRightInput
                };
                Keybinding attackKeybinding2 = new Keybinding()
                {
                    key = VirtualKey.F, function = OnAttackInput
                };

                //Add keybindings to list
                keybindings.Add(WKeybinding);
                keybindings.Add(SKeybinding);
                keybindings.Add(AKeybinding);
                keybindings.Add(DKeybinding);
                keybindings.Add(attackKeybinding2);
                break;
            }
        }
示例#12
0
        //Constructor
        public PlayerGameObject(Vector2 position, GameObjectIndex container, PlayerRegistry players, InputManager inputManager, KeyboardFormat format) : base(position, new BoxCollider(position, HITBOX_SIZE), container)
        {
            //Initialize keyboard input source
            keyboardInput = new PlayerKeyboardInputSource(this, format);

            //Register in subsystems
            players.AddPlayer(this);
            inputManager.registerInputSource(keyboardInput);

            //Set subsystem references
            this.players = players;
            this.input   = inputManager;

            //Get player images
            images = new List <CanvasBitmap>();
            images.Add(ImageManager.getImageByName("red_ghost_up"));
            images.Add(ImageManager.getImageByName("red_ghost_right"));
            images.Add(ImageManager.getImageByName("red_ghost_down"));
            images.Add(ImageManager.getImageByName("red_ghost_left"));

            //Initialize image
            Image = images[1];

            //Initialize movement array
            movement = new bool[4] {
                false, false, false, false
            };

            //Initialize direction
            Direction = CardinalDirection.EAST;
        }
示例#13
0
 public bool CanHandleFormat(KeyboardFormat format)
 {
     return(format == KeyboardFormat.Unknown);
 }
		public bool CanHandleFormat(KeyboardFormat format)
		{
			return format == KeyboardFormat.Unknown;
		}
示例#15
0
		/// <summary>
		/// Creates and returns a keyboard definition object based on the ID.
		/// </summary>
		public IKeyboardDefinition CreateKeyboard(string id, KeyboardFormat format, IEnumerable<string> urls)
		{
			KeyboardDescription keyboard;
			if (!_keyboards.TryGet(id, out keyboard))
			{
				keyboard = _adaptors.Values.First(adaptor => adaptor.CanHandleFormat(format)).CreateKeyboardDefinition(id);
				_keyboards.Add(keyboard);
			}

			keyboard.Format = format;
			if (urls != null)
			{
				foreach (string url in urls)
				{
					keyboard.Urls.Add(url);
				}
			}
			return keyboard;
		}
 public bool CanHandleFormat(KeyboardFormat format)
 {
     return(false);
 }
		public bool CanHandleFormat(KeyboardFormat format)
		{
			return false;
		}