示例#1
0
        // Pre process (occurs before Draw())
        public void preProcess()
        {
            Vector2 viewOffset          = -_currentScreenCenter + _halfScreenSize;
            float   antiFogTextureScale = _scale * 0.5f;

            // Draw anti fog points (points where the anti fog brush texture will be drawn
            _spriteBatch.GraphicsDevice.SetRenderTarget(_antiFogRT);
            _spriteBatch.GraphicsDevice.Clear(Color.Transparent);
            _spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend);

            foreach (WorldMapDefinition worldMap in DataManager.worldMapManager.worldMapDefinitions)
            {
                foreach (LevelPathDefinition levelPath in worldMap.levelPathDefinitions)
                {
                    if (DataManager.worldMapManager.isLevelPathDiscovered(worldMap.uid, levelPath.id))
                    {
                        foreach (LevelPathKey key in levelPath.pathKeys)
                        {
                            float increment = 0.1f;
                            for (float i = increment; i < 1f; i += increment)
                            {
                                Vector2 point = Vector2.Zero;
                                StasisMathHelper.bezier(ref key.p0, ref key.p1, ref key.p2, ref key.p3, i, out point);
                                _spriteBatch.Draw(_antiFogBrush, viewOffset + point, _antiFogBrush.Bounds, Color.White, 0f, _antiFogBrushOrigin, antiFogTextureScale, SpriteEffects.None, 0f);
                            }
                        }
                    }
                }
                foreach (LevelIconDefinition levelIcon in worldMap.levelIconDefinitions)
                {
                    LevelIconState state = DataManager.worldMapManager.getLevelIconState(worldMap.uid, levelIcon.uid);

                    if (state != null && state.discovered)
                    {
                        _spriteBatch.Draw(_antiFogBrush, viewOffset + levelIcon.position, _antiFogBrush.Bounds, Color.White, 0f, _antiFogBrushOrigin, antiFogTextureScale, SpriteEffects.None, 0f);
                    }
                }
            }
            _spriteBatch.End();
            _spriteBatch.GraphicsDevice.SetRenderTarget(_fogRT);
            _spriteBatch.GraphicsDevice.Clear(Color.Transparent);
            _spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend, null, null, null, _fogEffect);
            _spriteBatch.Draw(_antiFogRT, _antiFogRT.Bounds, Color.White);
            _spriteBatch.End();
            _spriteBatch.GraphicsDevice.SetRenderTarget(null);
            _spriteBatch.GraphicsDevice.Clear(Color.Black);
        }
示例#2
0
        public override void draw()
        {
            Vector2 viewOffset = -_currentScreenCenter + _halfScreenSize;

            foreach (WorldMapDefinition worldMap in DataManager.worldMapManager.worldMapDefinitions)
            {
                WorldMapState worldMapState = DataManager.worldMapManager.getWorldMapState(worldMap.uid);

                if (worldMapState.discovered)
                {
                    // World map texture
                    _spriteBatch.Draw(worldMap.texture, viewOffset, worldMap.texture.Bounds, Color.White, 0f, new Vector2(worldMap.texture.Width, worldMap.texture.Height) / 2f, _scale, SpriteEffects.None, 1f);

                    // Paths
                    foreach (LevelPathDefinition levelPath in worldMap.levelPathDefinitions)
                    {
                        if (DataManager.worldMapManager.isLevelPathDiscovered(worldMap.uid, levelPath.id))
                        {
                            foreach (LevelPathKey key in levelPath.pathKeys)
                            {
                                float increment = 0.001f;
                                for (float i = 0f; i < 1f; i += increment)
                                {
                                    Vector2 point = Vector2.Zero;
                                    StasisMathHelper.bezier(ref key.p0, ref key.p1, ref key.p2, ref key.p3, i, out point);
                                    _spriteBatch.Draw(_pathTexture, viewOffset + point, _pathTexture.Bounds, Color.Yellow, 0f, _pathTextureOrigin, _scale, SpriteEffects.None, 0.3f);
                                }
                            }
                        }
                    }

                    // Level icons
                    foreach (LevelIconDefinition levelIcon in worldMap.levelIconDefinitions)
                    {
                        LevelIconState state = DataManager.worldMapManager.getLevelIconState(worldMap.uid, levelIcon.uid);

                        if (state != null && state.discovered)
                        {
                            Texture2D texture = state.finished ? levelIcon.finishedTexture : levelIcon.unfinishedTexture;

                            _spriteBatch.Draw(texture, viewOffset + levelIcon.position, texture.Bounds, Color.White, 0f, new Vector2(texture.Width, texture.Height) / 2f, _scale, SpriteEffects.None, 0.2f);
                        }
                    }
                }
            }

            // Draw fog render target
            _spriteBatch.Draw(_fogRT, Vector2.Zero, _fogRT.Bounds, Color.White, 0f, Vector2.Zero, _scale, SpriteEffects.None, 0.1f);

            // Draw level select icon
            _spriteBatch.Draw(_levelSelectIcon, _levelSelectPosition, _levelSelectIcon.Bounds, _levelSelectIconColor, _levelSelectAngle, _levelSelectIconHalfSize, _scale, SpriteEffects.None, 0f);

            // Draw title text
            if (_selectedLevelIcon != null)
            {
                _spriteBatch.DrawString(_levelSelectTitleFont, _selectedLevelIcon.title, new Vector2(32, 32), Color.White);
            }

            // Draw description text
            if (_selectedLevelIcon != null)
            {
                string text = wrapText(_levelSelectDescriptionFont, _selectedLevelIcon.description, 420);
                _spriteBatch.DrawString(_levelSelectDescriptionFont, text, new Vector2(32, 96), Color.LightGray);
            }

            base.draw();
        }