Exemplo n.º 1
0
        private void AddToColumns(RectInt rect)
        {
            RectInt common;

            rect.Intersects(new RectInt(0, 0, TextureSource.Texture.width, TextureSource.Texture.height), out common);

            for (int i = 0; i < common.width; i++)
            {
                colliderChanged = columns[common.x + i].SumRange(new Range(common.y, common.y + common.height - 1)) || colliderChanged;
            }
        }
Exemplo n.º 2
0
        public virtual bool Paint(RectInt r, PaintingParameters pp)
        {
            if (pp.PaintingMode == PaintingMode.NONE)
            {
                return(false);
            }

            //Find common rect that will be applied on this texture rect
            RectInt common;

            r.Intersects(new RectInt(0, 0, TextureSource.Texture.width, TextureSource.Texture.height), out common);

            //Generate color array...
            int len = common.width * common.height;

            if (len == 0)
            {
                return(false);
            }

            Color[] cs = new Color[len];

            //...using paiting method
            if (pp.PaintingMode == PaintingMode.REPLACE_COLOR)
            {
                for (int i = 0; i < len; i++)
                {
                    cs[i] = pp.Color;
                }
            }
            else if (pp.PaintingMode == PaintingMode.ADD_COLOR)
            {
                for (int i = 0; i < common.width; i++)
                {
                    for (int j = 0; j < common.height; j++)
                    {
                        cs[i * common.height + j] = TextureSource.Texture.GetPixel(common.x + i, common.y + j) + pp.Color;
                    }
                }
            }

            //Apply color
            TextureSource.Texture.SetPixels(common.x, common.y, common.width, common.height, cs);

            //Set up this chunk as ready to be updated on next Update()
            painted = true;
            return(true);
        }
Exemplo n.º 3
0
 public bool Intersects(RectInt visibleRect)
 {
     return(visibleRect.Intersects(area));
 }