Пример #1
0
        /*************************************
         * Draw a single tile
         *************************************/
        private void DrawTile(float a_x, float a_y, float a_scale, Model.Tile a_tile)
        {
            int textureIndex = 0;
            Color tileColor;

            //Block tile
            if (a_tile.isBlocked() || a_tile.isTrap())
                textureIndex = 1;

            //Door tile
            if (a_tile.isExit())
                textureIndex = 2;

            if (a_tile.isTrap() && a_tile.isWalkedOn())
                a_tile.setWalkedOn(false);

            // Set colorChanger on trap tiles
            if (a_tile.isTrap())
            {
                tileColor = colorChanger.CurrentColor;
            }
            else
            {
                tileColor = Color.White;
            }

            //Get the source rectangle (pixels on the texture) for the tile type
            Rectangle sourceRectangle = new Rectangle(textureTileSize * textureIndex, 0, textureTileSize, textureTileSize);

            //Destination rectangle in windows coordinates only scaling
            Rectangle destRect = new Rectangle((int)a_x, (int)a_y, (int)a_scale, (int)a_scale);

            spriteBatch.Draw(tileTexture, destRect, sourceRectangle, tileColor);
        }