Beispiel #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
                        );
                }
            }
        }