示例#1
0
        /// <summary>
        /// Renders all crops of the worldgrid.
        /// </summary>
        /// <param name="spriteBatch">The spritebatch to use for drawing.</param>
        /// <param name="worldGrid">The worldgrid to get all info from.</param>
        public void RenderCrops(SpriteBatch spriteBatch, WorldGrid worldGrid)
        {
            float maxYTextureIndex = cropTextureAtlas.YSize - 1;

            for (byte xIndex = 0; xIndex < worldGrid.Size; xIndex++)
            {
                for (byte yIndex = 0; yIndex < worldGrid.Size; yIndex++)
                {
                    if (!worldGrid.HasCrop(yIndex, xIndex))
                    {
                        continue;
                    }

                    Crop?currentCrop = worldGrid.GetCrop(yIndex, xIndex);

                    int growthIndex   = (int)(currentCrop.Value.Growth * maxYTextureIndex);
                    int cropTypeIndex = ((int)currentCrop.Value.Type) - 1;

                    cropTextureAtlas.Draw(
                        cropTypeIndex, growthIndex, 1, 1,
                        spriteBatch,
                        new Rectangle(xIndex * CELL_SIZE * DISPLAY_SCALE, yIndex * CELL_SIZE * DISPLAY_SCALE, CELL_SIZE * DISPLAY_SCALE, CELL_SIZE * DISPLAY_SCALE),
                        Color.White
                        );
                }
            }
        }
示例#2
0
        /// <summary>
        /// Renders all structures of the worldgrid.
        /// </summary>
        /// <param name="spriteBatch">The spritebatch to use for drawing.</param>
        /// <param name="worldGrid">The worldgrid to get all info from.</param>
        public void RenderStructures(SpriteBatch spriteBatch, WorldGrid worldGrid)
        {
            for (byte xIndex = 0; xIndex < worldGrid.Size; xIndex++)
            {
                for (byte yIndex = 0; yIndex < worldGrid.Size; yIndex++)
                {
                    if (!worldGrid.HasStructure(yIndex, xIndex))
                    {
                        continue;
                    }

                    Structure currentStructure = worldGrid.GetStructure(yIndex, xIndex);

                    if (xIndex != currentStructure.X || yIndex != currentStructure.Y)
                    {
                        continue;
                    }

                    int  structureTypeIndex = (int)currentStructure.Type - 1;
                    byte structureHeight    = currentStructure.Height;

                    structureTextureAtlas.Draw(
                        structureTypeIndex * STRUCTURE_HEIGHT, 0, STRUCTURE_HEIGHT, STRUCTURE_WIDTH,
                        spriteBatch,
                        new Rectangle(xIndex * CELL_SIZE * DISPLAY_SCALE, (yIndex - STRUCTURE_HEIGHT + structureHeight) * CELL_SIZE * DISPLAY_SCALE, CELL_SIZE * STRUCTURE_WIDTH * DISPLAY_SCALE, CELL_SIZE * STRUCTURE_HEIGHT * DISPLAY_SCALE),
                        Color.White
                        );
                }
            }
        }
示例#3
0
        public void Draw(SpriteBatch spriteBatch)
        {
            Vector2 draw = new Vector2(Location.X, Location.Y + TextureAtlas.Height);

            if (appearenceTimer > appearenceDelay)
            {
                TextureAtlas.Draw(spriteBatch, draw);
            }
        }
示例#4
0
        /// <summary>
        /// Renders all soil of the worldgrid.
        /// </summary>
        /// <param name="spriteBatch">The spritebatch to use for drawing.</param>
        /// <param name="worldGrid">The worldgrid to get all info from.</param>
        public void RenderSoil(SpriteBatch spriteBatch, WorldGrid worldGrid)
        {
            for (byte xIndex = 0; xIndex < worldGrid.Size; xIndex++)
            {
                for (byte yIndex = 0; yIndex < worldGrid.Size; yIndex++)
                {
                    int tilledIndex    = Convert.ToInt32(worldGrid.GetTilled(yIndex, xIndex)) * 3;
                    int soilTypeIndex  = (int)worldGrid.GetSoil(yIndex, xIndex);
                    int variationIndex = (xIndex * yIndex) % 3;

                    soilTextureAtlas.Draw(
                        soilTypeIndex, tilledIndex + variationIndex, 1, 1,
                        spriteBatch,
                        new Rectangle(xIndex * CELL_SIZE * DISPLAY_SCALE, yIndex * CELL_SIZE * DISPLAY_SCALE, CELL_SIZE * DISPLAY_SCALE, CELL_SIZE * DISPLAY_SCALE),
                        Color.White
                        );
                }
            }
        }
示例#5
0
 public override void Draw(SpriteBatch spriteBatch)
 {
     atlas.Draw(spriteBatch, Position);
 }
 /// <summary>   Submit a sprite for drawing in the current batch. </summary>
 ///
 /// <param name="spriteBatch">      The spriteBatch to act on. </param>
 /// <param name="atlas">            The atlas. </param>
 /// <param name="texture">          The texture. </param>
 /// <param name="position">         The position. </param>
 /// <param name="sourceRectangle">  Source rectangle. </param>
 /// <param name="color">            The color. </param>
 /// <param name="rotation">         The rotation. </param>
 /// <param name="origin">           The origin. </param>
 /// <param name="scale">            The scale. </param>
 /// <param name="effects">          The effects. </param>
 /// <param name="layerDepth">       Depth of the layer. </param>
 public static void Draw(this SpriteBatch spriteBatch, TextureAtlas atlas, string texture, Vector2 position, Rectangle?sourceRectangle, Color color, float rotation, Vector2 origin, Vector2 scale, SpriteEffects effects, float layerDepth)
 {
     atlas.Draw(spriteBatch, texture, position, sourceRectangle, color, rotation, origin, scale, effects, layerDepth);
 }
 /// <summary>   Submit a sprite for drawing in the current batch. </summary>
 ///
 /// <param name="spriteBatch">      The spriteBatch to act on. </param>
 /// <param name="atlas">            The atlas. </param>
 /// <param name="texture">          The texture. </param>
 /// <param name="position">         The position. </param>
 /// <param name="sourceRectangle">  Source rectangle. </param>
 /// <param name="color">            The color. </param>
 public static void Draw(this SpriteBatch spriteBatch, TextureAtlas atlas, string texture, Vector2 position, Rectangle?sourceRectangle, Color color)
 {
     atlas.Draw(spriteBatch, texture, position, sourceRectangle, color);
 }
 /// <summary>   Submit a sprite for drawing in the current batch. </summary>
 ///
 /// <param name="spriteBatch">          The spriteBatch to act on. </param>
 /// <param name="atlas">                The atlas. </param>
 /// <param name="texture">              The texture. </param>
 /// <param name="destinationRectangle"> Destination rectangle. </param>
 /// <param name="sourceRectangle">      Source rectangle. </param>
 /// <param name="color">                The color. </param>
 public static void Draw(this SpriteBatch spriteBatch, TextureAtlas atlas, string texture, Rectangle destinationRectangle, Rectangle?sourceRectangle, Color color)
 {
     atlas.Draw(spriteBatch, texture, destinationRectangle, sourceRectangle, color);
 }
示例#9
0
 public void Draw(SpriteBatch spriteBatch)
 {
     locale.Y = Location.Y + TextureAtlas.Height;
     locale.X = Location.X;
     TextureAtlas.Draw(spriteBatch, locale);
 }