private void BlockPaint(object sender, MouseEventArgs e) { XNA.Point selected_tile = HelperClass.TileSnapToGrid(Camera.WorldPosition(e.Location)); Tile tile_in_map = GLB_Data.TileMap[0, selected_tile.X, selected_tile.Y]; Block Block = new Block(); Block.x = tile_in_map.grid_location.X; Block.y = tile_in_map.grid_location.Y; Block.name = ""; bool BlockFound = false; Block deadBlock = new Block(); foreach (Block n in GLB_Data.blocks) { if (Block.x == n.x && Block.y == n.y) { BlockFound = true; deadBlock = n; } } if (BlockFound) { GLB_Data.blocks.Remove(deadBlock); } else { GLB_Data.blocks.Add(Block); } }
public EditBlock(Point spawnPoint, ref Block Block) { InitializeComponent(); this.Location = spawnPoint; selectedBlock = Block; txtName.Text = Block.name; }
private void btnOK_Click(object sender, EventArgs e) { for (int i = 0; i < GLB_Data.blocks.Count; i++) { if (GLB_Data.blocks[i].x == selectedBlock.x && GLB_Data.blocks[i].y == selectedBlock.y) { Block newBlock = new Block(); newBlock.name = txtName.Text; newBlock.x = selectedBlock.x; newBlock.y = selectedBlock.y; GLB_Data.blocks[i] = newBlock; } } this.Close(); }
private void xna_renderer_MouseDown(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left) { if (GLB_Data.TilesTexture == null) { return; } if (GLB_Data.Brush == PaintTool.MarqueeBrush || GLB_Data.Brush == PaintTool.MarqueeEraser || GLB_Data.Brush == PaintTool.MarqueeWalk || GLB_Data.Brush == PaintTool.MarqueeTerrain) { // Marquee is beign created, save initial point GLB_Data.MarqueeSelection.Show = true; GLB_Data.MarqueeSelection.InitialLocation = Camera.SystemPointTransform(e.Location); return; } if (!ValidTileSelected() && GLB_Data.Brush != PaintTool.Walk && GLB_Data.Brush != PaintTool.Eraser && GLB_Data.Brush != PaintTool.Portal && GLB_Data.Brush != PaintTool.Chest && GLB_Data.Brush != PaintTool.NPC && GLB_Data.Brush != PaintTool.FixedCombat) { // no selected tile return; } XNA.Point bounds = Camera.Transform(e.Location); if (bounds.X > GLB_Data.MapSize.Width * Camera.ScaledTileSize || bounds.Y > GLB_Data.MapSize.Height * Camera.ScaledTileSize || bounds.X < 0 || bounds.Y < 0) { // out of bounds return; } previous_location = e.Location; // Map is about to change , save current status undo_redo.AddUndoHistory(); CheckUndoRedo(); DoBrushLogic(sender, e); } else if (e.Button == MouseButtons.Right) { // Right mouse button pressed, user is starting to do // a map scroll operation. // Store the initial point of the Scroll //mouse_scroll_initial = Cursor.Position; XNA.Point selected_tile = HelperClass.TileSnapToGrid(Camera.WorldPosition(e.Location)); //chests Chest selectedChest = new Chest(); bool chestFound = false; foreach (Chest chest in GLB_Data.chests) { if (chest.x == selected_tile.X && chest.y == selected_tile.Y) { selectedChest = chest; chestFound = true; } } if (chestFound) { editChest = new EditChest(new System.Drawing.Point(e.X, e.Y), ref selectedChest); editChest.ShowDialog(); } //NPCs NPC selectedNPC = new NPC(); bool NPCFound = false; foreach (NPC NPC in GLB_Data.npcs) { if (NPC.x == selected_tile.X && NPC.y == selected_tile.Y) { selectedNPC = NPC; NPCFound = true; } } if (NPCFound) { editNPC = new EditNPC(new System.Drawing.Point(e.X, e.Y), ref selectedNPC); editNPC.ShowDialog(); } //Monsters FixedCombatNPC selectedFixedCombatNPC = new FixedCombatNPC(); bool FixedCombatNPCFound = false; foreach (FixedCombatNPC FixedCombatNPC in GLB_Data.fixedCombatNPCs) { if (FixedCombatNPC.x == selected_tile.X && FixedCombatNPC.y == selected_tile.Y) { selectedFixedCombatNPC = FixedCombatNPC; FixedCombatNPCFound = true; } } if (FixedCombatNPCFound) { //editMonster = new EditBlock(new System.Drawing.Point(e.X, e.Y), ref selectedFixedCombatNPC); editMonster.ShowDialog(); } //Blocks Block selectedBlock = new Block(); bool BlockFound = false; foreach (Block Block in GLB_Data.blocks) { if (Block.x == selected_tile.X && Block.y == selected_tile.Y) { selectedBlock = Block; BlockFound = true; } } if (BlockFound) { editBlock = new EditBlock(new System.Drawing.Point(e.X, e.Y), ref selectedBlock); editBlock.ShowDialog(); } //Switches Switch selectedSwitch = new Switch(); bool SwitchFound = false; foreach (Switch Switch in GLB_Data.switches) { if (Switch.x == selected_tile.X && Switch.y == selected_tile.Y) { selectedSwitch = Switch; SwitchFound = true; } } if (SwitchFound) { editSwitches = new EditSwitches(new System.Drawing.Point(e.X, e.Y), ref selectedSwitch); editSwitches.ShowDialog(); } } }