Ejemplo n.º 1
0
        public override IEnumerable <IRenderable> GetCustomVisualizers(IVoxelHandle handle)
        {
            var inv = new InventoryVisualizer(handle);

            inv.ItemRelativeTransformationProvider = i =>
            {
                var currentInventory = handle.Data.Inventory.Items.ToList();
                var itemTypeList     = marketInventory.Select(e => e.ItemType).ToList();
                var itemI            = currentInventory[i];
                var itemTypeIndex    = getItemTypeIndex(itemI, itemTypeList);

                if (itemTypeIndex == -1)
                {
                    return(Matrix.Identity);
                }

                var itemTypeI            = itemTypeList[itemTypeIndex];
                var nbItemsOfTypeUntillI = getNbItemOfTypeUntilIndex(i, itemTypeI, currentInventory);

                const int   stackWidth   = 3;
                const float stackSpacing = 2.5f;
                var         stackOffsetX = itemStackPositions[itemTypeIndex].X * stackSpacing;
                var         stackOffsetZ = itemStackPositions[itemTypeIndex].Y * stackSpacing;
                const float scaling      = 0.5f;
                var         x            = (float)Math.Floor((float)nbItemsOfTypeUntillI % (stackWidth * stackWidth) / stackWidth) * 1.1f * scaling * 2f - stackWidth * 0.5f * scaling * 2f + scaling;
                var         y            = (float)Math.Floor((float)nbItemsOfTypeUntillI / (stackWidth * stackWidth)) * 1.1f * scaling * 2f + 1f;
                var         z            = nbItemsOfTypeUntillI % stackWidth * 1.1f * scaling * 2f - 0.5f * stackWidth * scaling * 2f + scaling;

                return(Matrix.Scaling(MathHelper.One * scaling) * Matrix.Translation(x + stackOffsetX, y, z + stackOffsetZ));
            };
            yield return(inv);
        }
Ejemplo n.º 2
0
        public override System.Collections.Generic.IEnumerable <IRenderable> GetCustomVisualizers(IVoxelHandle handle)
        {
            var inv = new InventoryVisualizer(handle);

            inv.ItemRelativeTransformationProvider = i =>
            {
                return(InventoryVisualizer.getItemCircleTransformation(i, handle.GetInternalVoxel(), 0.25f));
            };
            yield return(inv);
        }
Ejemplo n.º 3
0
        public override System.Collections.Generic.IEnumerable <IRenderable> GetCustomVisualizers(IVoxelHandle handle)
        {
            var inv = new InventoryVisualizer(handle);

            inv.ItemRelativeTransformationProvider = i =>
            {
                var size     = 5;
                var x        = (float)(i % size);
                var y        = (float)(i / size);
                var tileSize = 10;

                var cellSize = tileSize / (float)size;

                x -= size / 2f;
                y -= size / 2f;


                return(Matrix.Scaling(MathHelper.One * 0.5f) *
                       Matrix.Translation(cellSize * (x + 0.5f), 1f, cellSize * (y + 0.5f)));
            };
            yield return(inv);
        }