private void DoRightClickEvents(GameTime gameTime) { if (this.IsActive) { if (Mouse.GetState().RightButton == ButtonState.Pressed && !RightClicked) { bool tool = false; int x = Mouse.GetState().X, y = Mouse.GetState().Y; SpriteObject tmpSprite = GetToolbarByMousePosition(x, y); if (tmpSprite.ID == 50000) { //Window.Title = "Saving..."; SaveMap(); //Window.Title = "Elysian Fields - Map Editor"; } else if (tmpSprite.ID == 51000) { tool = true; if (currentTileset < 2) { if (currentTileset == Tileset_Items) { ClearTilesetPositions(Entity.ItemEntity); } else if (currentTileset == Tileset_Tiles) { ClearTilesetPositions(Entity.TileEntity); } else if (currentTileset == Tileset_Creatures) { ClearTilesetPositions(Entity.CreatureEntity); } currentTileset++; } } else if (tmpSprite.ID == 52000) { tool = true; if (currentTileset > 0) { if (currentTileset == Tileset_Items) { ClearTilesetPositions(Entity.ItemEntity); } else if (currentTileset == Tileset_Tiles) { ClearTilesetPositions(Entity.TileEntity); } else if (currentTileset == Tileset_Creatures) { ClearTilesetPositions(Entity.CreatureEntity); } currentTileset--; } } else if (tmpSprite.ID == 53000) { tool = true; if (currentZ < Utility.MaxZ) currentZ++; } else if (tmpSprite.ID == 54000) { tool = true; if (currentZ > Utility.MinZ) currentZ--; } else if (tmpSprite.ID == 55000) { tool = true; if (currentZ_order < Utility.MaxZ_Order) currentZ_order++; } else if (tmpSprite.ID == 56000) { tool = true; if (currentZ_order > Utility.MinZ_Order) currentZ_order--; } if (!tool) { currentSprite = tmpSprite; } Window.Title = "Sprite ID: " + currentSprite.ID.ToString(); RightClicked = true; } } }
/// <summary> /// Allows the game to run logic such as updating the world, /// checking for collisions, gathering input, and playing audio. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Update(GameTime gameTime) { if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape)) Exit(); // TODO: Add your update logic here if (Mouse.GetState().RightButton == ButtonState.Released && RightClicked) { RightClicked = false; } if (this.IsActive) { if (Mouse.GetState().RightButton == ButtonState.Pressed && !RightClicked) { int x = Mouse.GetState().X, y = Mouse.GetState().Y; currentSprite = GetToolbarByMousePosition(x, y); if(currentSprite.ID == 5) { Window.Title = "Saving..."; SaveMap(); Window.Title = "Elysian Fields - Map Editor"; } // For debug purposes: Window.Title = map.Players[0].TargetID.ToString(); RightClicked = true; } } /*if (Mouse.GetState().LeftButton == ButtonState.Released && LeftClicked) { LeftClicked = false; }*/ if (this.IsActive) { if (Mouse.GetState().LeftButton == ButtonState.Pressed) { int mx = Mouse.GetState().X, my = Mouse.GetState().Y; int x = (mx / 32) * 32; int y = (my / 32) * 32; Coordinates target = new Coordinates(x, y); if (currentSprite.ID != -1 && GetTileByMousePosition(x, y).ID == -1 && currentSprite.ID != 3 && currentSprite.ID != 5) { Tiles.Add(new Tile("grass", currentSprite.ID, target, 1)); } else if(currentSprite.ID == 3) { int tmpint = GetTileIndexByMousePosition(x, y); if (tmpint > -1) { Tiles.RemoveAt(tmpint); } } // For debug purposes: Window.Title = map.Players[0].TargetID.ToString();*/ // For debug purposes: Window.Title = x.ToString() + " " + y.ToString(); } } base.Update(gameTime); }