Exemplo n.º 1
0
        public void RefreshIcons()
        {
            icons = new Dictionary <Rectangle, ProductionIcon>();
            if (CurrentQueue == null)
            {
                return;
            }

            var allBuildables = CurrentQueue.AllItems().OrderBy(a => a.Traits.Get <BuildableInfo>().BuildPaletteOrder);
            var i             = 0;
            var rb            = RenderBounds;

            foreach (var item in allBuildables)
            {
                var x    = i % Columns;
                var y    = i / Columns;
                var rect = new Rectangle(rb.X + x * 64 + 1, rb.Y + y * 48 + 1, 64, 48);
                var icon = new Animation(RenderSimple.GetImage(item));
                icon.Play(item.Traits.Get <TooltipInfo>().Icon);
                var pi = new ProductionIcon()
                {
                    Name   = item.Name,
                    Sprite = icon.Image,
                    Pos    = new float2(rect.Location),
                    Queued = CurrentQueue.AllQueued().Where(a => a.Item == item.Name).ToList(),
                };
                icons.Add(rect, pi);
                i++;
            }

            eventBounds = icons.Keys.Aggregate(Rectangle.Union);
        }
        public void RefreshIcons()
        {
            Icons = new Dictionary<Rectangle, ProductionIcon>();
            if (CurrentQueue == null)
                return;

            var allBuildables = CurrentQueue.AllItems().OrderBy(a => a.Traits.Get<BuildableInfo>().BuildPaletteOrder);
            var i = 0;
            var rb = RenderBounds;
            foreach (var item in allBuildables)
            {
                var x = i % Columns;
                var y = i / Columns;
                var rect =  new Rectangle(rb.X + x * 64 + 1, rb.Y + y * 48 + 1, 64, 48);
                var pi = new ProductionIcon()
                {
                    Name = item.Name,
                    Sprite = iconSprites[item.Name],
                    Pos = new float2(rect.Location),
                    Queued = CurrentQueue.AllQueued().Where(a => a.Item == item.Name).ToList(),
                };
                Icons.Add(rect, pi);
                i++;
            }

            eventBounds = Icons.Keys.Aggregate(Rectangle.Union);
        }