Beispiel #1
0
        public void ColorAtPositionNegativeTest( int x, int y )
        {
            Point position = new Point( x, y );
            Block block = new Block();

            Assert.AreEqual( null, block.ColorAt( position ) );
        }
Beispiel #2
0
        public void ColorAtPositionTest( int x, int y )
        {
            Point position = new Point( x, y );
            Block block = new Block();

            block.Grid [ position.Y ] [ position.X ] = Color.Tomato;
            Assert.AreEqual( Color.Tomato, block.ColorAt( position ) );
        }
Beispiel #3
0
        public void FixBlock()
        {
            for (int x = 0; x < Block.Width; x++)
            {
                for (int y = 0; y < Block.Height; y++)
                {
                    Color?color = Block.ColorAt(new Vector2(x, y));

                    if (color.HasValue)
                    {
                        _field[(int)Position.X + x, (int)Position.Y + y] = color;
                    }
                }
            }
        }
Beispiel #4
0
        private Color?GetColorInBlock(Vector2 position)
        {
            int x = (int)position.X;
            int y = (int)position.Y;

            Color?result = null;

            if (Block != null && (x >= Position.X && x < Position.X + Block.Width && y >= Position.Y && y < Position.Y + Block.Height))
            {
                Vector2 resultingPosition = position - Position;

                result = Block.ColorAt(resultingPosition);
            }

            if (result.HasValue)
            {
                return(result);
            }
            else
            {
                return(_field[x, y]);
            }
        }