/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { inputManager = new InputManager(this, keyboardListener = new KeyboardInputListener(), gamepadListeners = new GamepadInputListener[] { new GamepadInputListener(PlayerIndex.One), new GamepadInputListener(PlayerIndex.Two), new GamepadInputListener(PlayerIndex.Three), new GamepadInputListener(PlayerIndex.Four) }, mouseListener = new MouseListener()); scriptEngine = new ScriptEngine(this, "scripteng.cfg") { LoggingMethod = LoggingMethod.Console }; windowManager = new WindowManager(this) { DrawOrder = 0 }; stateManager = new GameStateManager(this) { DrawOrder = 1 }; stateManager.GameStateChanging += stateManager_GameStateChanging; stateManager.OnGameStatePushing += stateManager_OnGameStatePushing; stateManager.OnGameStatePopping += stateManager_OnGameStatePopping; world = new World(this, new BruteForceBroadphase(), new SeparatingAxisTheorem()); Components.Add(inputManager); Components.Add(windowManager); Components.Add(stateManager); Components.Add(scriptEngine); base.Initialize(); camera = new Camera(Vector2.Zero, this.GraphicsDevice.Viewport); scriptEngine.CompileAll(); objectCreators.Add(new ObjectCreator("ObjectFiles\\Maps.xml")); objectCreators.Add(new ObjectCreator("ObjectFiles\\Entities.xml")); string[] objectFiles = Directory.GetFiles(AppDomain.CurrentDomain.BaseDirectory + "ObjectFiles\\") .Where(f => f.EndsWith(".xml")) .ToArray(); for (int i = 0; i < objectFiles.Length; i++) { objectCreators.Add(new ObjectCreator(objectFiles[i])); } //stateManager.(new GameplayState("City1.xml")); stateManager.ChangeState(new SplashMenuState()); }
private void InitializeMappings() { KeyboardInputListener keylistener = Owner.Game.KeyboardListener; /* * keylistener.Map("Left", MoveLeft, new KeyTrigger(Keys.A), new KeyTrigger(Keys.Left)); * keylistener.Map("Right", MoveRight, new KeyTrigger(Keys.D), new KeyTrigger(Keys.Right)); * keylistener.Map("Up", MoveUp, new KeyTrigger(Keys.W), new KeyTrigger(Keys.Up)); * keylistener.Map("Down", MoveDown, new KeyTrigger(Keys.S), new KeyTrigger(Keys.Down)); * keylistener.Map("Attack", Attack, new KeyTrigger(Keys.Space)); * keylistener.Map("Buy", InitiateBuy, Keys.E); */ }
private void KeyboardInputCreated(object sender, KeyboardInputListener e) { var bindings = KeyBinds.DefaultBindings; if (Storage.TryReadJson($"controls", out Dictionary <InputCommand, Keys> loadedBindings)) { bindings = loadedBindings; } foreach (var binding in bindings) { e.RegisterMap(binding.Key, binding.Value); } }
public InputManager(KeyboardInputListener keylistener, MouseInputListener mil) { Listeners = new List <InputListener>(); if (keylistener != null) { Listeners.Add(keylistener); } if (mil != null) { Listeners.Add(mil); } }
private void RemoveMappings() { if (!hasMappings) { return; } hasMappings = false; KeyboardInputListener keyboardListener = Game.KeyboardListener; keyboardListener.RemoveMapping("Up"); keyboardListener.RemoveMapping("Down"); keyboardListener.RemoveMapping("Left"); keyboardListener.RemoveMapping("Right"); keyboardListener.RemoveMapping("Select"); }
private void InitianizeMappings() { if (hasMappings) { return; } hasMappings = true; KeyboardInputListener keyboardListener = Game.KeyboardListener; keyboardListener.Map("Up", MoveUp, new KeyTrigger(Keys.W)); keyboardListener.Map("Down", MoveDown, new KeyTrigger(Keys.S)); keyboardListener.Map("Left", MoveLeft, new KeyTrigger(Keys.A)); keyboardListener.Map("Right", MoveRight, new KeyTrigger(Keys.D)); keyboardListener.Map("Select", Select, new KeyTrigger(Keys.Enter)); }
public TileEditor(TileEngine tileEngine) : base() { this.tileEngine = tileEngine; layers = new LayerManager <TileLayer>(); tilesets = new TilesetManager(); view = new BasicView(); keyboardInputListener = new KeyboardInputListener(); mouseInputListener = new MouseInputListener(); inputManager = new InputManager(keyboardInputListener, mouseInputListener); brushBuckets = new Dictionary <Tileset, BrushBucket>(); backgroundColor = Color.CornflowerBlue; }
public InputManager(Game game, KeyboardInputListener keylistener, GamepadInputListener[] padListeners, MouseListener mil) : base(game) { Listeners = new List <InputListener>(); if (keylistener != null) { Listeners.Add(keylistener); } foreach (var listener in padListeners) { if (listener == null || Listeners.Contains(listener)) { continue; } Listeners.Add(listener); } if (mil != null) { Listeners.Add(mil); } }
protected override void OnInitialize() { keyboardListener = Game.KeyboardListener; gamepadListenenr = Game.GamepadListeners.FirstOrDefault(l => l.IsConnected); if (gamepadListenenr != null) { keyboardListener.Map("Skip", Skip, new KeyTrigger(Keys.Enter)); if (gamepadListenenr != null) { gamepadListenenr.Map("Skip", Skip, new ButtonTrigger(Buttons.A)); } } textures.Add(Game.Content.Load <Texture2D>("team")); textures.Add(Game.Content.Load <Texture2D>("game")); alpha = 255; current = textures.First(); textures.Remove(current); }
public KeyboardInputBuffer(KeyboardInputListener kil) : base() { this.listener = kil; }