Example #1
0
 public GUIExampleScene()
 {
     g      = new Gui.Gui();
     c      = new TestContainer(Position.Origin);
     images = new[]
     {
         TileImageLoader.LoadImage("village"),
         TileImageLoader.LoadImage("hoard"),
         TileImageLoader.LoadImage("sleep"),
         TileImageLoader.LoadImage("trade")
     };
 }
Example #2
0
        private void UpdateTiles()
        {
            var newTiles = new List <Tile>();

            if (ParentMap != null && TileMatrix != null && TileSource != null)
            {
                var maxZoomLevel = Math.Min(TileMatrix.ZoomLevel, MaxZoomLevel);

                if (maxZoomLevel >= MinZoomLevel)
                {
                    var tileSize = 1 << (TileMatrix.ZoomLevel - maxZoomLevel);
                    var x1       = (int)Math.Floor((double)TileMatrix.XMin / tileSize); // may be negative
                    var x2       = TileMatrix.XMax / tileSize;
                    var y1       = Math.Max(TileMatrix.YMin / tileSize, 0);
                    var y2       = Math.Min(TileMatrix.YMax / tileSize, (1 << maxZoomLevel) - 1);

                    for (var y = y1; y <= y2; y++)
                    {
                        for (var x = x1; x <= x2; x++)
                        {
                            var tile = Tiles.FirstOrDefault(t => t.ZoomLevel == maxZoomLevel && t.X == x && t.Y == y);

                            if (tile == null)
                            {
                                tile = new Tile(maxZoomLevel, x, y);

                                var equivalentTile = Tiles.FirstOrDefault(
                                    t => t.ZoomLevel == maxZoomLevel && t.XIndex == tile.XIndex && t.Y == y && t.Image.Source != null);

                                if (equivalentTile != null)
                                {
                                    tile.SetImage(equivalentTile.Image.Source, false); // no fade-in animation
                                }
                            }

                            newTiles.Add(tile);
                        }
                    }
                }
            }

            Tiles = newTiles;

            Children.Clear();

            foreach (var tile in Tiles)
            {
                Children.Add(tile.Image);
            }

            TileImageLoader.LoadTilesAsync(Tiles, TileSource, SourceName);
        }
Example #3
0
        public TestScene()
        {
            /*p0 = new Position(6, 25);
             * p1 = new Position(15, 13);
             * p2 = new Position(25, 26);
             * p3 = new Position(35, 13);*/

            p0 = new Position(6, 25);
            p1 = new Position(6, 6);
            p2 = new Position(16, 6);
            p3 = new Position(26, 6);

            img = TileImageLoader.LoadImage("test");

            testMapping.SetBinding("ActionDown", new KeyBinding(Key.J));
        }
Example #4
0
 public TestContainer(Position position)
     : base(position, new Dimensions(21, 9), Color.Black)
 {
     image = TileImageLoader.LoadImage("testgui");
 }