Example #1
0
        public EditMonster(Point spawnPoint, ref FixedCombatNPC FixedCombatNPC)
        {
            InitializeComponent();

            this.Location = spawnPoint;
            selectedFixedCombatNPC = FixedCombatNPC;

            txtName.Text = FixedCombatNPC.name;
        }
Example #2
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            for (int i = 0; i < GLB_Data.fixedCombatNPCs.Count; i++)
            {
                if (GLB_Data.fixedCombatNPCs[i].x == selectedFixedCombatNPC.x &&
                    GLB_Data.fixedCombatNPCs[i].y == selectedFixedCombatNPC.y)
                {
                    FixedCombatNPC newFixedCombatNPC = new FixedCombatNPC();
                    newFixedCombatNPC.name = txtName.Text;
                    newFixedCombatNPC.x = selectedFixedCombatNPC.x;
                    newFixedCombatNPC.y = selectedFixedCombatNPC.y;

                    GLB_Data.fixedCombatNPCs[i] = newFixedCombatNPC;
                }
            }

            this.Close();
        }
Example #3
0
        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();
                }
            }
        }
Example #4
0
        private void FixedCombatPaint(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];

            FixedCombatNPC FixedCombat = new FixedCombatNPC();
            FixedCombat.x = tile_in_map.grid_location.X;
            FixedCombat.y = tile_in_map.grid_location.Y;
            FixedCombat.name = "";

            bool FixedCombatFound = false;
            FixedCombatNPC deadFixedCombat = new FixedCombatNPC();

            foreach (FixedCombatNPC f in GLB_Data.fixedCombatNPCs)
            {
                if (FixedCombat.x == f.x && FixedCombat.y == f.y)
                {
                    FixedCombatFound = true;
                    deadFixedCombat = f;
                }
            }

            if (FixedCombatFound)
            {
                GLB_Data.fixedCombatNPCs.Remove(deadFixedCombat);
            }
            else
            {
                GLB_Data.fixedCombatNPCs.Add(FixedCombat);
            }
        }