Inheritance: IResource, IPropertyProvider
Esempio n. 1
0
        public void QueueAdd(TileCoord coord, Tile tile)
        {
            if (tile != null) {
                TileStack srcStack = null;
                if (_tileSource.InRange(coord))
                    srcStack = new TileStack(_tileSource[coord]);

                TileStack stack = new TileStack(srcStack);
                stack.Add(tile);

                if (_tiles.ContainsKey(coord))
                    _tiles[coord] = new TileRecord(_tiles[coord].Original, stack);
                else
                    _tiles[coord] = new TileRecord(srcStack, stack);
            }
        }
Esempio n. 2
0
        protected override void AddTileImpl(int x, int y, Tile tile)
        {
            int xi = XIndex(x);
            int yi = YIndex(y);

            if (_tiles[yi, xi] == null) {
                _tiles[yi, xi] = new TileStack();
                _tiles[yi, xi].Modified += TileStackModifiedHandler;
            }

            _tiles[yi, xi].Remove(tile);
            _tiles[yi, xi].Add(tile);
        }
        private void TileSelected(object sender, TileEventArgs e)
        {
            _selectedTile = e.Tile;

            _annotations.Clear();

            if (_selectedTile != null) {
                TileCoord location = _tileLayer.TileToCoord(e.Tile);
                int x = location.X * _tileSet.TileWidth;
                int y = location.Y * _tileSet.TileHeight;

                SelectionAnnot annot = new SelectionAnnot() {
                    Start = new Treefrog.Framework.Imaging.Point(x, y),
                    End = new Treefrog.Framework.Imaging.Point(x + _tileSet.TileWidth, y + _tileSet.TileHeight),
                    Fill = new SolidColorBrush(new Treefrog.Framework.Imaging.Color(192, 0, 0, 128)),
                };

                _annotations.Add(annot);
            }

            OnSelectedTileChanged(EventArgs.Empty);
        }
Esempio n. 4
0
 public DependentTile (Guid uid, Tile baseTile, TileTransform xform)
     : base(uid)
 {
     _base = baseTile;
     _transform = xform;
 }
Esempio n. 5
0
 public void RemoveTile(TileCoord coord, Tile tile)
 {
     if (_tiles.ContainsKey(coord))
         _tiles[coord].Remove(tile);
 }
Esempio n. 6
0
 public void SetTile(int x, int y, Tile tile)
 {
     int position = y * _brushClass.TemplateWidth + x;
     SetTile(position, tile);
 }
Esempio n. 7
0
        private void ShowPreviewMarker(TileCoord location)
        {
            if (ActiveTile == null && _activeBrush == null)
                return;

            if (_selectionAnnot != null)
                return;

            if (_activeBrush == null && ActiveTile != _activeTile) {
                ClearPreviewMarker();
                _activeTile = ActiveTile;
            }

            if (!_previewMarkerVisible) {
                if (_previewMarker == null) {
                    _previewMarker = new ImageAnnot();
                    _previewMarker.BlendColor = new Color(255, 255, 255, 128);
                    if (_activeBrush != null)
                        _previewMarker.Image = BuildBrushMarker();
                    else
                        _previewMarker.Image = BuildTileMarker();
                }

                _annots.Add(_previewMarker);
                _previewMarkerVisible = true;
            }

            if (_previewMarker != null) {
                int x = (int)(location.X * Layer.TileWidth);
                int y = (int)(location.Y * Layer.TileHeight);

                _previewMarker.Position = new Point(x, y);
                //if (_activeBrush != null)
                //    _previewMarker.End = new Point(x + Layer.TileWidth * _activeBrush.TilesWide, y + Layer.TileHeight * _activeBrush.TilesHigh);
                //else
                //    _previewMarker.End = new Point(x + Layer.TileWidth, y + Layer.TileHeight);
            }
            else {
                HidePreviewMarker();
            }
        }
Esempio n. 8
0
        public void RemoveTile(int x, int y, Tile tile)
        {
            CheckBoundsFail(x, y);

            LocatedTileEventArgs ea = new LocatedTileEventArgs(tile, x, y);
            OnTileRemoving(ea);
            RemoveTileImpl(x, y, tile);
            OnTileRemoved(ea);
        }
Esempio n. 9
0
 protected abstract void AddTileImpl(int x, int y, Tile tile);
Esempio n. 10
0
 public LocatedTileEventArgs(Tile tile, int x, int y)
     : base(tile)
 {
     X = x;
     Y = y;
 }
Esempio n. 11
0
        public void AddTile(int x, int y, Tile tile)
        {
            CheckBoundsFail(x, y);
            CheckTileFail(tile);

            LocatedTileEventArgs ea = new LocatedTileEventArgs(tile, x, y);
            OnTileAdding(ea);
            AddTileImpl(x, y, tile);
            OnTileAdded(ea);
        }
        public TileCoord TileToCoord(Tile tile)
        {
            int tilesWide = TilesWide;

            int pointX = 0;
            int pointY = 0;

            foreach (Tile t in _layer.Tiles) {
                if (tile == t) {
                    return new TileCoord(pointX, pointY);
                }

                if (++pointX >= tilesWide) {
                    pointX = 0;
                    pointY++;
                }
            }

            throw new ArgumentException("The tile does not exist in the layer.", "tile");
        }
Esempio n. 13
0
 public void RemoveAllMatchingTiles(Tile tile)
 {
     for (int y = TileOriginY; y < TileOriginY + TilesHigh; y++) {
         for (int x = TileOriginX; x < TileOriginX + TilesWide; x++) {
             RemoveTile(x, y, tile);
         }
     }
 }
Esempio n. 14
0
 public bool CanAddTile(int x, int y, Tile tile)
 {
     return CheckTile(tile) && CheckBounds(x, y);
 }
Esempio n. 15
0
        protected override void RemoveTileImpl(int x, int y, Tile tile)
        {
            int xi = XIndex(x);
            int yi = YIndex(y);

            if (_tiles[yi, xi] != null) {
                _tiles[yi, xi].Remove(tile);
            }
        }
Esempio n. 16
0
 protected bool CheckTile(Tile tile)
 {
     return tile.Width == TileWidth && tile.Height == TileHeight;
 }
Esempio n. 17
0
 public void SetTile(int position, Tile tile)
 {
     if (position >= 0 && position < _tiles.Count)
         _tiles[position].Tile = tile;
 }
Esempio n. 18
0
 protected void CheckTileFail(Tile tile)
 {
     if (!CheckTile(tile)) {
         throw new ArgumentException(String.Format("Tried to add tile with dimenions ({0}, {1}), layer expects tile dimensions ({2}, {3})",
             new string[] { tile.Width.ToString(), tile.Height.ToString(), TileWidth.ToString(), TileHeight.ToString() }));
     }
 }
Esempio n. 19
0
 private void RemoveTileFromBrush(DynamicTileBrush brush, Tile tile)
 {
     if (brush != null) {
         for (int i = 0; i < _brush.BrushClass.SlotCount; i++) {
             if (_brush.GetTile(i) == tile)
                 _brush.SetTile(i, null);
         }
     }
 }
Esempio n. 20
0
 protected abstract void RemoveTileImpl(int x, int y, Tile tile);
Esempio n. 21
0
        public void QueueReplacement(TileCoord coord, Tile replacement)
        {
            TileStack srcStack = null;
            if (_tileSource.InRange(coord))
                srcStack = new TileStack(_tileSource[coord]);

            TileStack stack = null;
            if (replacement != null) {
                stack = new TileStack();
                stack.Add(replacement);
            }

            if (_tiles.ContainsKey(coord))
                _tiles[coord] = new TileRecord(_tiles[coord].Original, stack);
            else
                _tiles[coord] = new TileRecord(srcStack, stack);
        }
Esempio n. 22
0
        public void TestSetup()
        {
            _eventsFired = EventFlags.None;
            _registry = new TileRegistry(_service.GraphicsDevice);
            _pool = new TilePool("pool", _registry, 16, 16);

            Texture2D tex1 = new Texture2D(_service.GraphicsDevice, 16, 16);
            Texture2D tex2 = new Texture2D(_service.GraphicsDevice, 16, 16);

            _tile1 = _pool.GetTile(_pool.AddTile(tex1));
            _tile2 = _pool.GetTile(_pool.AddTile(tex2));
        }
Esempio n. 23
0
        public void AddTile(TileCoord coord, Tile tile)
        {
            if (!_tiles.ContainsKey(coord))
                _tiles.Add(coord, new TileStack());

            _tiles[coord].Remove(tile);
            _tiles[coord].Add(tile);

            UpdateExtants(coord);
        }
Esempio n. 24
0
 private void AttachEvents(Tile tile)
 {
     tile.Modified += (s, e) => { _eventsFired |= EventFlags.Modified; };
     tile.TextureModified += (s, e) => { _eventsFired |= EventFlags.TextureModified; };
 }
Esempio n. 25
0
        private void RemoveTileFromBrush(StaticTileBrush brush, Tile tile)
        {
            if (brush != null) {
                List<LocatedTile> removeQueue = new List<LocatedTile>();
                foreach (LocatedTile brushTile in brush.Tiles) {
                    if (brushTile.Tile == tile)
                        removeQueue.Add(brushTile);
                }

                foreach (LocatedTile brushTile in removeQueue)
                    brush.RemoveTile(brushTile.Location, brushTile.Tile);
            }
        }
Esempio n. 26
0
 public TileProperties (Tile parent)
     : base(new string[0])
 {
     _parent = parent;
 }