Exemple #1
0
        public void AddProp(Prop prop)
        {
            //Console.WriteLine("Checking if " + prop.x + ">" + width + " && " + prop.y + ">" + height);

            // Remove empty prop
            if (prop.texX == 0 && prop.texY == 0)
            {
                var matches = props.Where(p => p.x == prop.x && p.y == prop.y);
                List<Prop> match = matches.ToList();

                foreach (Prop t in match)
                {
                    props.Remove(t);
                }
                return;
            }

            // Check if the Prop fits in the map
            if (prop.x < width && prop.y < height)
            {
                // Remove all propss with the same coordinates
                var matches = props.Where(p => p.x == prop.x && p.y == prop.y);
                List<Prop> match = matches.ToList();

                foreach (Prop t in match)
                {
                    props.Remove(t);
                }

                // All is good, add the new Prop
                props.Add(prop);
                //Console.WriteLine(tiles.Count());
            }
        }
Exemple #2
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();
 }