Пример #1
0
        private void DrawWorldMap()
        {
            Vector2 cameraPostition = worldCharacter.CameraPosition;
            Point   positionOffset  = worldCharacter.PositionOffset + new Point(EngineSettings.TileSize, EngineSettings.TileSize);

            int worldmapLength = _worldMapSpriteSet[0].Length;

            for (int yOffset = ((int)cameraPostition.Y * WorldInformation.mapWidth) - 1, TileY = -positionOffset.Y; yOffset < (int)(cameraPostition.Y + _halfWidthPlus) * WorldInformation.mapWidth; yOffset += WorldInformation.mapWidth, TileY += EngineSettings.TileSize)
            {
                for (int x = (int)cameraPostition.X + yOffset, TileX = -positionOffset.X; x < (int)cameraPostition.X + _halfHeightPlus + yOffset + 1; x++, TileX += EngineSettings.TileSize)
                {
                    int ColorIndex = x;

                    while (ColorIndex < yOffset)
                    {
                        ColorIndex += WorldInformation.mapWidth;
                    }
                    while (ColorIndex > yOffset + WorldInformation.mapWidth)
                    {
                        ColorIndex -= WorldInformation.mapWidth;
                    }

                    while (ColorIndex < 0)
                    {
                        ColorIndex += worldmapLength;
                    }
                    while (ColorIndex >= worldmapLength)
                    {
                        ColorIndex -= worldmapLength;
                    }

                    Color TileColor = _worldmapAnimator.Get()[ColorIndex];
                    Point location  = new Point(TileX, TileY);
                    if (MapTileCollection.ContainsTile(TileColor))
                    {
                        if (MapTileCollection.HasSubTexture(TileColor))
                        {
                            GSS.SpriteBatch.Draw(MapTileCollection.GetSubTexture(TileColor),
                                                 new Rectangle(location, TileSize), _sunColor);
                        }

                        if (GSS.DebugMapX0Y0)
                        {
                            Point t = GetCoordinate(ColorIndex);
                            GSS.SpriteBatch.Draw(MapTileCollection.GetTexture(TileColor),
                                                 new Rectangle(location, TileSize),
                                                 t.X == 0 || t.Y == 0 ? new Color(0, 0, 0) : _sunColor);
                        }
                        else
                        {
                            GSS.SpriteBatch.Draw(MapTileCollection.GetTexture(TileColor),
                                                 new Rectangle(location, TileSize), _sunColor);
                        }
                    }
                    else
                    {
                        GSS.SpriteBatch.Draw(MapTileCollection.GetTexture(), new Rectangle(location, TileSize), Color.Black);
                    }
                }
            }
        }