Ejemplo n.º 1
0
        protected override void CalculateResult(MapToolContext ctx, Rectangle marqueeBounds, out ItemFieldFragment fragment, out string hint)
        {
            Rectangle tileRect = ctx.ToTiles(marqueeBounds);

            fragment = new ItemFieldFragment();
            segmentLayout.CalculateResult(ctx, tileRect, fragment);
            hint = "";  //droppedItemCount > 0 ? $"{droppedItemCount} Items" : "-";
        }
Ejemplo n.º 2
0
        public void CalculateResult(MapToolContext ctx, Rectangle tileRect, ItemFieldFragment fragment)
        {
            if (tileRect.Size.Encompasses(placedItemSize))
            {
                Rectangle placedItemRect = new Rectangle(tileRect.Location, placedItemSize);
                fragment.Add(placedItemRect, placedItem, ctx.MapEditingService.IsOccupied(placedItemRect));

                if (recipeItem != null)
                {
                    for (int y = tileRect.Top; y + recipeItemSize.Height <= tileRect.Bottom; y += recipeItemSize.Height)
                    {
                        Rectangle recipeItemRect =
                            new Rectangle(tileRect.Left, y, recipeItemSize.Width, recipeItemSize.Height);
                        if (recipeItemRect.IntersectsWith(placedItemRect))
                        {
                            continue;
                        }
                        fragment.Add(recipeItemRect, recipeItem, ctx.MapEditingService.IsOccupied(recipeItemRect));
                    }
                }

                int droppedItemTop =
                    placedItemRect.Top + droppedItemSize.Height - (placedItemRect.Height % droppedItemSize.Height);
                int doppedItemsPerColumn =
                    (tileRect.Bottom - droppedItemTop) / droppedItemSize.Height;

                if (droppedItems.Count > 0)
                {
                    for (int x = tileRect.Left + recipeItemSize.Width;
                         x + droppedItemSize.Width <= tileRect.Right;
                         x += droppedItemSize.Width)
                    {
                        for (int y = 0; y < doppedItemsPerColumn; y++)
                        {
                            Rectangle droppedItemRect = new Rectangle(x, droppedItemTop + y * droppedItemSize.Height,
                                                                      droppedItemSize.Width, droppedItemSize.Height);
                            if (droppedItemRect.IntersectsWith(placedItemRect))
                            {
                                continue;
                            }
                            var droppedItemIndex = (int)(y / ((float)doppedItemsPerColumn / droppedItems.Count));
                            var droppedItem      = droppedItems[droppedItemIndex];
                            fragment.Add(droppedItemRect, droppedItem,
                                         ctx.MapEditingService.IsOccupied(droppedItemRect));
                        }
                    }
                }
            }
        }
Ejemplo n.º 3
0
        protected override void CalculateResult(MapToolContext ctx, Rectangle marqueeBounds, out ItemFieldFragment fragment, out string hint)
        {
            fragment = new ItemFieldFragment();
            var tileRect = ctx.ToTiles(marqueeBounds);

            for (int x = tileRect.Left; x <= tileRect.Right - itemSize.Width; x += itemSize.Width)
            {
                for (int y = tileRect.Top; y <= tileRect.Bottom - itemSize.Height; y += itemSize.Height)
                {
                    Rectangle itemTileRect = new Rectangle(x, y, itemSize.Width, itemSize.Height);
                    fragment.Add(itemTileRect, item, ctx.MapEditingService.IsOccupied(itemTileRect));
                }
            }

            int itemsX = tileRect.Width / itemSize.Width;
            int itemsY = tileRect.Height / itemSize.Height;

            hint = $"{itemsX} × {itemsY}";
        }
Ejemplo n.º 4
0
        protected override void CalculateResult(MapToolContext ctx, Rectangle marqueeBounds,
                                                out ItemFieldFragment fragment, out string hint)
        {
            var tileRect = ctx.ToTiles(marqueeBounds).Quantize(2);

            fragment = new ItemFieldFragment();
            hint     = $"{segmentLayouts.Length} Item(s)";
            if (layout.GetSegmentRects(tileRect, segmentLayouts, minSegementSizes, rowCount, out var segmentRects,
                                       out var templateHint))
            {
                for (int segmentIndex = 0;
                     segmentIndex < segmentLayouts.Length;
                     segmentIndex++)
                {
                    segmentLayouts[segmentIndex].CalculateResult(ctx, segmentRects[segmentIndex], fragment);
                }
            }

            if (!string.IsNullOrWhiteSpace(templateHint))
            {
                hint = $"{hint} - {templateHint}";
            }
        }
Ejemplo n.º 5
0
 protected abstract void CalculateResult(MapToolContext ctx, Rectangle marqueeBounds,
                                         out ItemFieldFragment fragment,
                                         out string hint);
Ejemplo n.º 6
0
        public void CalculateResult(MapToolContext ctx, Rectangle tileRect, ItemFieldFragment fragment)
        {
            Rectangle itemRect = new Rectangle(tileRect.Location, new Size(2, 2));

            fragment.Add(itemRect, item, ctx.MapEditingService.IsOccupied(itemRect));
        }