Exemplo n.º 1
0
        private void MainPanel_MouseDown(object sender, MouseEventArgs e)
        {
            bMouseDownMainPanel = true;
            mousePt = getMapMouseLoc(e.X, e.Y);
            if (G.currentMap == null)
                    return;

            if (G.operation == 1)
            {
                if (G.currentTexture == null)
                    return;

                if (G.bAreaBrush)
                {
                    AreaStartI = AreaEndI = mousePt.X / G.tileSize;
                    AreaStartJ = AreaEndJ = mousePt.Y / G.tileSize;
                }
                else
                {
                    updateTile(mousePt.X / G.tileSize, mousePt.Y / G.tileSize);
                }
            }
            else if (G.operation == 2)
            {
                MapGrid grid = new MapGrid(mousePt.X / G.tileSize, mousePt.Y / G.tileSize);
                GridControl gc = new GridControl();
                MainPanel.Controls.Add(gc);
                gc.Location = new Point(mousePt.X, mousePt.Y);
                gc.data = grid;
                G.currentMap.grids.Add(grid);
                G.currentMap.gamePlayes[mousePt.X / G.tileSize, mousePt.Y / G.tileSize] = 2;
            }
            else if (G.operation == 3)
            {
                AreaStartI = AreaEndI = mousePt.X / G.tileSize;
                AreaStartJ = AreaEndJ = mousePt.Y / G.tileSize;
            }
            else if (G.operation == 4)
            {
                MapGrid grid = new MapGrid(mousePt.X / G.tileSize, mousePt.Y / G.tileSize);
                GridControl gc = new GridControl();
                MainPanel.Controls.Add(gc);
                gc.Location = new Point(mousePt.X, mousePt.Y);
                grid.bHospital = true;
                gc.data = grid;
                G.currentMap.grids.Add(grid);
                G.currentMap.gamePlayes[mousePt.X / G.tileSize, mousePt.Y / G.tileSize] = 2;
                G.currentMap.info.hospitalExit = new Point(mousePt.X / G.tileSize, mousePt.Y / G.tileSize);

                G.currentMap.UpdateGrids();
            }
            else if (G.operation == 5)
            {
                MapGrid grid = new MapGrid(mousePt.X / G.tileSize, mousePt.Y / G.tileSize);
                GridControl gc = new GridControl();
                MainPanel.Controls.Add(gc);
                gc.Location = new Point(mousePt.X, mousePt.Y);
                grid.bJail = true;
                gc.data = grid;
                G.currentMap.grids.Add(grid);
                G.currentMap.gamePlayes[mousePt.X / G.tileSize, mousePt.Y / G.tileSize] = 2;
                G.currentMap.info.jailExit = new Point(mousePt.X / G.tileSize, mousePt.Y / G.tileSize);

                G.currentMap.UpdateGrids();
            }
            else if (G.operation == 6)
            {
                MapGrid grid = new MapGrid(mousePt.X / G.tileSize, mousePt.Y / G.tileSize);
                GridControl gc = new GridControl();
                MainPanel.Controls.Add(gc);
                gc.Location = new Point(mousePt.X, mousePt.Y);
                grid.bPlayerStart = true;
                gc.data = grid;
                G.currentMap.grids.Add(grid);
                G.currentMap.gamePlayes[mousePt.X / G.tileSize, mousePt.Y / G.tileSize] = 2;
                G.currentMap.info.playerStarts.Add(new Point(mousePt.X / G.tileSize, mousePt.Y / G.tileSize));

                G.currentMap.UpdateGrids();
            }

            MainPanel.Refresh();
        }
Exemplo n.º 2
0
        private void Dlg_OpenMap_FileOk(object sender, CancelEventArgs e)
        {
            String fileName = Dlg_OpenMap.FileName;
            G.currentMap = new Map();
            G.currentMap.Load(fileName);
            G.currentTexture = new TexturePanel(G.currentMap.textureName, G.currentMap.imgList);
            this.splitContainer1.Panel1.Controls.Add(G.currentTexture);

            int gridCount = G.currentMap.grids.Count();
            for (int i = 0; i < gridCount; i++)
            {
                GridControl gc = new GridControl();
                MainPanel.Controls.Add(gc);
                gc.data = G.currentMap.grids[i];
                gc.Location = new Point(G.currentMap.grids[i].x * G.tileSize, G.currentMap.grids[i].y * G.tileSize);

                if (G.currentMap.grids[i].eState != null)
                {
                    EStateControl ec = new EStateControl();
                    MainPanel.Controls.Add(ec);
                    ec.data = G.currentMap.grids[i].eState;
                    ec.Location = new Point(G.currentMap.grids[i].eState.x * G.tileSize, G.currentMap.grids[i].eState.y * G.tileSize);
                }
            }

            G.bRepaintMainPanel = true;
        }