示例#1
0
        protected void AddSpritesToLayers(Layer darknessLayer, Layer hudLayer)
        {
            _hudLayer   = hudLayer;
            _lightLayer = darknessLayer;

#if DEBUG
            if (DebugVariables.ShowDebugShapes)
            {
                LayerProvidedByContainer.Remove(AxisAlignedRectangleInstance);
                ShapeManager.AddToLayer(AxisAlignedRectangleInstance, hudLayer);
            }
#endif


            LayerProvidedByContainer.Remove(RangePreviewSprite);
            SpriteManager.AddToLayer(RangePreviewSprite, hudLayer);

            LayerProvidedByContainer.Remove(LightSpriteInstance);
            SpriteManager.AddToLayer(LightSpriteInstance, darknessLayer);

            LayerProvidedByContainer.Remove(WarpSpriteInstance);
            SpriteManager.AddToLayer(WarpSpriteInstance, darknessLayer);

            LayerProvidedByContainer.Remove(LightAimSpriteInstance);
            SpriteManager.AddToLayer(LightAimSpriteInstance, darknessLayer);

            var gumLayer = RenderingLibrary.SystemManagers.Default.Renderer.Layers.FirstOrDefault(l => l.Name == "InfoLayerGum");
            StructureUpgradeStatusInstance.MoveToFrbLayer(hudLayer, gumLayer);

            LayerProvidedByContainer.Remove(RangeCircleInstance);
            ShapeManager.AddToLayer(RangeCircleInstance, hudLayer);
        }
示例#2
0
        private static Texture2D GenerateRadiusTexture(int maxRange, int minRange)
        {
            // Determine the new layer size
            var newTextureHeight = maxRange * 2;
            var newTextureWidth  = maxRange * 2;

            // This layer holds whatever we want drawn
            var temporaryLayer = new Layer();

            // Define the layer.
            var renderTarget = new RenderTarget2D(
                FlatRedBallServices.GraphicsDevice,
                newTextureWidth,
                newTextureHeight);

            temporaryLayer.RenderTarget = renderTarget;

            var maxRangeSprite = new Sprite
            {
                Texture        = RangeCircleTexture,
                TextureScale   = newTextureHeight / (float)RangeCircleTexture.Height,
                ColorOperation = ColorOperation.ColorTextureAlpha,
                Z     = 0,
                Red   = 0,
                Green = 255,
                Blue  = 0,
            };

            SpriteManager.AddToLayer(maxRangeSprite, temporaryLayer);

            var minRangeSprite = new Sprite
            {
                Texture      = MinRangeCircleTexture,
                TextureScale = minRange * 2 / (float)MinRangeCircleTexture.Height,
                //ColorOperation = ColorOperation.Subtract,
                ColorOperation = ColorOperation.ColorTextureAlpha,
                Z     = 1,
                Red   = 255,
                Green = 0,
                Blue  = 0,
            };

            SpriteManager.AddToLayer(minRangeSprite, temporaryLayer);

            // Rendering requires a camera. We'll create a temporary one (don't add it to the SpriteManager)
            var temporaryCamera = new Camera(null, newTextureWidth, newTextureHeight)
            {
                DrawsWorld = false, Z = 40
            };

            // We only want the camera to draw the layer
            temporaryCamera.UsePixelCoordinates();
            temporaryCamera.AddLayer(temporaryLayer);

            FlatRedBall.Graphics.Renderer.DrawCamera(temporaryCamera, null);

            //using (var fileStream = File.Create("range.png"))
            //{
            //    renderTarget.SaveAsPng(fileStream, newTextureWidth, newTextureHeight);
            //}

            SpriteManager.RemoveSprite(maxRangeSprite);
            SpriteManager.RemoveSprite(minRangeSprite);

            FlatRedBallServices.AddDisposable(
                "Max" + maxRange.ToString() + "Min" + minRange.ToString() + ".png",
                renderTarget,
                "ContentManagerName");

            return(renderTarget);
        }