Exemple #1
0
        public void RemoveTile(int x, int y, int w, int h, bool converts)
        {
            x -= this.x;
            y -= this.y;

            try
            {
                if (x < 0 || y < 0)
                {
                    return;
                }

                if (w == tilesize && h == tilesize)
                {
                    if (map[x, y] != null && !map[x, y].build)
                    {
                        return;
                    }

                    map[x, y] = new Tile();
                }
                else
                {
                    for (int yy = 0; yy < h / tilesize; yy++)
                    {
                        for (int xx = 0; xx < w / tilesize; xx++)
                        {
                            RemoveTile(x + xx, y + yy, tilesize, tilesize, false);
                        }
                    }
                }

                if (converts)
                {
                    Tilemapper.ConvertAndSetMap(this);
                }
            }
            catch (Exception exc)
            {
                Engine.ExecuteScript("lx.StopMouse(2);");

                Feed.GiveException("Tile Remove", exc);
            }
        }
Exemple #2
0
        public void SetTile(int x, int y, Tile t, bool converts)
        {
            x -= this.x;
            y -= this.y;

            try
            {
                if (x < 0 || y < 0)
                {
                    return;
                }

                if (x >= map.GetLength(0))
                {
                    Resize(x + 1, map.GetLength(1));
                }
                if (y >= map.GetLength(1))
                {
                    Resize(map.GetLength(0), y + 1);
                }

                if (map[x, y] != null &&
                    map[x, y].build &&
                    map[x, y].cX == Tilemapper.selected.cX &&
                    map[x, y].cY == Tilemapper.selected.cY &&
                    map[x, y].r == Tilemapper.selected.r)
                {
                    return;
                }

                if (t.cW == tilesize && t.cH == tilesize)
                {
                    t.build   = true;
                    map[x, y] = t;
                }
                else
                {
                    for (int yy = 0; yy < t.cH / tilesize; yy++)
                    {
                        for (int xx = 0; xx < t.cW / tilesize; xx++)
                        {
                            Tile tt = new Tile()
                            {
                                sprite = t.sprite,
                                cX     = t.cX + xx * tilesize,
                                cY     = t.cY + yy * tilesize,
                                cW     = tilesize,
                                cH     = tilesize,
                                build  = true
                            };

                            SetTile(x + this.x + xx, y + this.y + yy, tt, false);
                        }
                    }
                }

                if (converts)
                {
                    Tilemapper.ConvertAndSetMap(this);
                }
            }
            catch (Exception exc)
            {
                Engine.ExecuteScript("lx.StopMouse(0);");

                Feed.GiveException("Tile Set", exc);
            }
        }