Ejemplo n.º 1
0
        public void AddTile(Tile tile)
        {
            // Console.WriteLine("Checking if " + tile.x + ">" + width + " && " + tile.y + ">" + height);
            // Check if the tile is empty
            if (tile.texX == 0 && tile.texY == 0)
            {
                var matches = tiles.Where(p => p.x == tile.x && p.y == tile.y);
                List<Tile> match = matches.ToList();

                foreach (Tile t in match)
                {
                    tiles.Remove(t);
                }
                return;
            }

            // Check if the tile fits in the map
            if (tile.x < width && tile.y < height)
            {

                // Remove all tiles with the same coordinates
                var matches = tiles.Where(p => p.x == tile.x && p.y == tile.y);
                List<Tile> match = matches.ToList();

                foreach (Tile t in match)
                {
                    tiles.Remove(t);
                }

                // All is good, add the new tile
                tiles.Add(tile);
                //Console.WriteLine(tiles.Count());
            }
        }
Ejemplo n.º 2
0
        private void pictureBox1_Click_1(object sender, EventArgs e)
        {
            MouseEventArgs me = (MouseEventArgs)e;
            Point coord = me.Location;
            //Coord p = new Coord(coord.X / 32, coord.Y / 32);
            //Console.WriteLine("Was clicked at " + p.getX() + " " + p.getY());

            try {
                //currentTile =
                //currentTile = new Tile()
                currentTile = new Tile(coord.X / 32, coord.Y / 32);
            }
            catch (Exception ee)
            {

            }
            pictureBox2.Image = currentTile.GetImage();
        }
Ejemplo n.º 3
0
 private void AddSomething(MouseEventArgs e)
 {
     var me = (MouseEventArgs)e;
     var coord = me.Location;
     if (tileMode)
     {
         var tempTile = new Tile(currentTile.texX, currentTile.texY);
         tempTile.x = coord.X/32;
         tempTile.y = coord.Y/32;
         tileMap.AddTile(tempTile);
     }
     else
     {
         var tempProp = new Prop(currentTile.texX, currentTile.texY);
         tempProp.x = coord.X / 32;
         tempProp.y = coord.Y / 32;
         tileMap.AddProp(tempProp);
     }
     pictureBox3.Image = tileMap.GetMap();
 }