public override void keyRelease(object sender) { Input.CInput input = Master.GetInputManager().GetCurrentInputHandler() as Input.CInput; if (_state == ACTOR_STATES.IDLE) { if (input.keysReleased.Contains(Microsoft.Xna.Framework.Input.Keys.E)) { _shiftLeft(); } else if (input.keysReleased.Contains(Microsoft.Xna.Framework.Input.Keys.Q)) { _shiftRight(); } else if (input.keysReleased.Contains(Microsoft.Xna.Framework.Input.Keys.Left)) { _setLeftItem(); } else if (input.keysReleased.Contains(Microsoft.Xna.Framework.Input.Keys.Right)) { _setRightItem(); } else if (input.keysReleased.Contains(Microsoft.Xna.Framework.Input.Keys.D) && _focused) { int activeMenuIndex = _menu.GetActiveMenuIndex(); if (activeMenuIndex >= 0) { CPauseMenuElement currentElement = (CPauseMenuElement)_menu.MenuElements[activeMenuIndex]; _moveCursor(currentElement.rightNeighbor); } } else if (input.keysReleased.Contains(Microsoft.Xna.Framework.Input.Keys.A) && _focused) { int activeMenuIndex = _menu.GetActiveMenuIndex(); if (activeMenuIndex >= 0) { CPauseMenuElement currentElement = (CPauseMenuElement)_menu.MenuElements[activeMenuIndex]; _moveCursor(currentElement.leftNeighbor); } } else if (input.keysReleased.Contains(Microsoft.Xna.Framework.Input.Keys.S) && _focused) { int activeMenuIndex = _menu.GetActiveMenuIndex(); if (activeMenuIndex >= 0) { CPauseMenuElement currentElement = (CPauseMenuElement)_menu.MenuElements[activeMenuIndex]; _moveCursor(currentElement.downNeighbor); } } else if (input.keysReleased.Contains(Microsoft.Xna.Framework.Input.Keys.W) && _focused) { int activeMenuIndex = _menu.GetActiveMenuIndex(); if (activeMenuIndex >= 0) { CPauseMenuElement currentElement = (CPauseMenuElement)_menu.MenuElements[activeMenuIndex]; _moveCursor(currentElement.upNeighbor); } } } }
public override void keyDown(object sender) { Input.CInput input = (Input.CInput)sender; _wading = input.keysPressed.Contains(input.getKey(Input.CInput.KEY_WALK_DOWN)) || input.keysPressed.Contains(input.getKey(Input.CInput.KEY_WALK_UP)) || input.keysPressed.Contains(input.getKey(Input.CInput.KEY_WALK_LEFT)) || input.keysPressed.Contains(input.getKey(Input.CInput.KEY_WALK_RIGHT)); }
private void pictureBox1_Click(object sender, EventArgs e) { System.Drawing.Point clientPoint = pictureBox1.PointToClient(MousePosition); cursorCoords = new Vector2((int)clientPoint.X, (int)clientPoint.Y); //snap the coordinates to the grid float snapX = (float)Math.Floor(cursorCoords.X / cellSize.X), snapY = (float)Math.Floor(cursorCoords.Y / cellSize.Y); cursorCoords.X = (snapX * cellSize.X) + (snapX * cellSpacing); cursorCoords.Y = (snapY * cellSize.Y) + (snapY * cellSpacing); topLeft = cursorCoords; selectedTile = new Microsoft.Xna.Framework.Rectangle[1, 1]; selectedTile[0, 0] = new Microsoft.Xna.Framework.Rectangle((int)cursorCoords.X + hScrollBar1.Value, (int)cursorCoords.Y + vScrollBar1.Value, (int)cellSize.X, (int)cellSize.Y); Input.CInput input = Gears.Cloud.Master.GetInputManager().GetCurrentInputHandler() as Input.CInput; if (!multiSelect && input.keysPressed.Contains(Microsoft.Xna.Framework.Input.Keys.LeftShift)) { multiSelect = true; multiSelections[0] = cursorCoords; btnSetMain.Text = "Cancel Multi Select"; btnSetMain.BackColor = System.Drawing.Color.Red; } else if (multiSelect) { multiSelect = false; btnSetMain.Text = "Make Main Tileset;"; btnSetMain.BackColor = System.Drawing.Color.White; multiSelections[1] = cursorCoords; //do some math here to determine which is the top left of the selection _determineTopLeft(); Microsoft.Xna.Framework.Rectangle selectionRect = _buildSelectionRect(); //build the selection int selectionWidth = (int)(selectionRect.Width / cellSize.X); int selectionHeight = (int)(selectionRect.Height / cellSize.Y); selectedTile = new Microsoft.Xna.Framework.Rectangle[selectionWidth, selectionHeight]; for (int i = 0; i < selectionWidth; i++) { for (int j = 0; j < selectionHeight; j++) { selectedTile[i, j] = new Microsoft.Xna.Framework.Rectangle(selectionRect.X + i * (int)cellSize.X, selectionRect.Y + j * (int)cellSize.Y, (int)cellSize.X, (int)cellSize.Y); } } } pictureBox1.Invalidate(); }
public override void Update(Microsoft.Xna.Framework.GameTime gameTime) { Input.CInput input = Master.GetInputManager().GetCurrentInputHandler() as Input.CInput; if (!_justOpened && input.keysReleased.Contains(Microsoft.Xna.Framework.Input.Keys.Enter)) { CMasterControl.audioPlayer.addSfx(CMasterControl.audioPlayer.soundBank["menu:closeMenu"]); Master.Pop(); } for (int i = 0; i < 2; i++) { _pauseBackdrops[i].update(gameTime); } if (_justOpened) { _justOpened = false; } }
public override void Update(Microsoft.Xna.Framework.GameTime gameTime) { _controlManager.Update(gameTime); Input.CInput input = Gears.Cloud.Master.GetInputManager().GetCurrentInputHandler() as Input.CInput; if (_tileEditor.selectorChange) { _currentTileSet = new Graphics.CSprite(_tileEditor.Controls["cmbTexture"].Text, Graphics.CTextures.textures[_tileEditor.Controls["cmbTexture"].Text]); } if (((Actors.Controllers.CEditorInputController)_controlManager.root)._shutDown) { _componentEditor.Visible = false; _tileEditor.Visible = false; Gears.Cloud.Master.Pop(); } _selectedTiles = _tileEditor.tileRect; if (((Actors.Controllers.CEditorNew)_controlManager.actors["btnNew"]).createNew) { layers = null; layers = new Map.CLayer[1]; } if (_tileEditor.tileSetChanged) { //apply the current tileSet to all tiles that use it foreach (Map.CLayer layer in layers) { layer.updateTileSet(_currentTileSet); } } if (((Actors.Controllers.CEditorInputController)_controlManager.root).dropTile) { Vector2 mouseCoords = new Vector2(input.mouseX, input.mouseY); string tileSet = ""; if (mouseCoords.Y <= 64) { return; } //if (_tileEditor.Controls["cmbTexture"].Text == _tileEditor.defaultTileSet) //tileSet = null; //else tileSet = _tileEditor.Controls["cmbTexture"].Text; Map.CTile[,] temp = new Map.CTile[_selectedTiles.GetUpperBound(0) + 1, _selectedTiles.GetUpperBound(1) + 1]; for (int i = 0; i < _selectedTiles.GetUpperBound(0) + 1; i++) { for (int j = 0; j < _selectedTiles.GetUpperBound(1) + 1; j++) { temp[i, j] = new Map.CTile(new Vector2(_selectedTiles[i, j].X, _selectedTiles[i, j].Y), mouseCoords + new Vector2(i * _selectedTiles[0, 0].Width, j * _selectedTiles[0, 0].Height), tileSet); layers[0].addTile(temp[i, j]); } } if (!layers[0].otherImages.ContainsKey(_currentTileSet.atlasName)) { layers[0].otherImages.Add(_currentTileSet.atlasName, _currentTileSet); } } if (input.mouseRightClick) { Vector2 mouseCoords = new Vector2(input.mouseX, input.mouseY); int index = 0; if ((index = layers[0].indexOfTile(mouseCoords)) > -1) { layers[0].removeTile(index); } } }