예제 #1
0
        protected void Draw(SpriteBatch spriteBatch, int x, int y, float layerDepth)
        {
            spriteBatch.Draw(Texture ?? AssetManager.GetDefault <Texture2D>(),
                             new Rectangle(x * World.BlockSize, y * World.BlockSize, World.BlockSize * Dimensions.X, World.BlockSize * Dimensions.Y),
                             CalculateSourceRectangle(),
                             Color.White,
                             0.0f,
                             new Vector2(0),
                             SpriteEffects.None,
                             layerDepth
                             );

            if (IsSelected)
            {
                ShapeManager.DrawRectangle(spriteBatch, new Rectangle(x * World.BlockSize, y * World.BlockSize, World.BlockSize, World.BlockSize), Color.Transparent, Color.Red);
            }
        }
예제 #2
0
        public void DrawAtCell(SpriteBatch spriteBatch, Cell cell, float opacity, bool withBorder = true)
        {
            List <Cell> neighbors = cell.GetNeighbors(false);
            bool        north     = neighbors[0] == null || neighbors[0].Zone != this;
            bool        east      = neighbors[1] == null || neighbors[1].Zone != this;
            bool        south     = neighbors[2] == null || neighbors[2].Zone != this;
            bool        west      = neighbors[3] == null || neighbors[3].Zone != this;
            BitArray    mask      = new BitArray(new bool[] { north, east, south, west });
            Rectangle   area      = new Rectangle(cell.X * World.BlockSize, cell.Y * World.BlockSize, World.BlockSize, World.BlockSize);

            if (!withBorder)
            {
                mask = new BitArray(4, false);
            }
            if (IsSelected)
            {
                opacity = 0.25f;
            }
            ShapeManager.DrawRectangle(spriteBatch, area, new Color(1f, 0, 0, opacity), new Color(0, 0, 1f, opacity), mask, DrawLayer.Zone);
        }
예제 #3
0
        public void Draw(SpriteBatch spriteBatch, int x, int y, float drawLayer)
        {
            if (Texture == null)
            {
                return;
            }

            if (IsSelected)
            {
                ShapeManager.DrawRectangle(spriteBatch, new Rectangle(x, y, World.BlockSize, World.BlockSize), Color.Transparent, Color.Red);
            }

            spriteBatch.Draw(Texture,
                             new Rectangle(x, y, World.BlockSize, World.BlockSize),
                             new Rectangle(0, 0, Texture.Width, Texture.Height),
                             Color.White,
                             0.0f,
                             new Vector2(0),
                             SpriteEffects.None,
                             drawLayer
                             );

            spriteBatch.DrawString(AssetManager.GetDefault <SpriteFont>(), "" + Count, new Vector2(x, y), Color.Red, 0f, Vector2.Zero, 1f, SpriteEffects.None, drawLayer + 0.01f);
        }