Exemple #1
0
        private bool AddToFloor(TextureBlock texture)
        {
            bool succes = false;

            if (height == -1)
            {
                height         = texture.height;
                AvailableWidth = new int[height];
                for (int i = 0; i < AvailableWidth.Length; i++)
                {
                    AvailableWidth[i] = width;
                }
                ShelfTexture = new Texture2D(width, height);
            }

            if (AvailableWidth[texture.height - 1] >= texture.width)
            {
                texture.NewStartX = FloorPixelX;
                texture.newStartY = 0;
                textureblocks.Add(texture);
                ShelfTexture.SetPixels(FloorPixelX, 0, texture.width, texture.height, texture.pixels, 0);
                ShelfTexture.Apply(true);
                FloorPixelX += texture.width;
                for (int i = 0; i < texture.height; i++)
                {
                    AvailableWidth[i] -= texture.width;
                }
                succes = true;
            }

            return(succes);
        }
Exemple #2
0
        public bool AddTexture(TextureBlock texture)
        {
            bool Added = false;

            if (CeilingPixelX < width)
            {
                Added = AddToCeiling(texture);
            }
            if (Added == false)
            {
                Added = AddToFloor(texture);
            }
            if (Added == false)
            {
                Added = AddToCeiling(texture);
            }
            return(Added);
        }
Exemple #3
0
        private bool AddToCeiling(TextureBlock texture)
        {
            bool succes = false;

            if (AvailableWidth[height - texture.height] >= texture.width)
            {
                texture.NewStartX = CeilingPixelX;
                texture.newStartY = height - texture.height;
                ShelfTexture.SetPixels(CeilingPixelX - texture.width, height - texture.height, texture.width, texture.height, texture.pixels, 0);
                ShelfTexture.Apply(true);
                CeilingPixelX -= texture.width;
                for (int i = height - 1; i > height - 1 - texture.height; i--)
                {
                    AvailableWidth[i] -= texture.width;
                }
                succes = true;
                textureblocks.Add(texture);
            }

            return(succes);
        }