public EditNPC(Point spawnPoint, ref NPC NPC) { InitializeComponent(); this.Location = spawnPoint; selectedNPC = NPC; txtName.Text = NPC.name; }
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(); } } }
private void NPCPaint(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]; NPC NPC = new NPC(); NPC.x = tile_in_map.grid_location.X; NPC.y = tile_in_map.grid_location.Y; NPC.name = ""; bool NPCFound = false; NPC deadNPC = new NPC(); foreach (NPC n in GLB_Data.npcs) { if (NPC.x == n.x && NPC.y == n.y) { NPCFound = true; deadNPC = n; } } if (NPCFound) { GLB_Data.npcs.Remove(deadNPC); } else { GLB_Data.npcs.Add(NPC); } }