Example #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="RectangleMode"/> class.
        /// </summary>
        public SvgSquaresMode()
        {
            // Create a list of gem images.
            SceneNodeLinkedList<float> nodes = new SceneNodeLinkedList<float>();
            RootSceneNode = nodes;

            // Load the image into memory.
            svgLoader = new SvgLoader(new FileInfo("Images/1cm.svg"));
            float screenScale = Platform.Instance.Window.Resolution.Height / 16f;
            svgLoader.Scale = screenScale * SvgImageLoader.Meter100px;
            TextureLoader textureLoader = new TextureLoader(svgLoader);

            // Create squares across the board.
            rows = (int) (440 / screenScale);
            columns = (int) (600 / (2 * screenScale));

            for (int i = 0; i < columns; i++)
            {
                for (int j = 0; j < rows; j++)
                {
                    ImageNode<float> image = new ImageNode<float>(textureLoader);
                    image.Point = new Point2<float>((j % 2) * screenScale + i * 2 * screenScale, j * screenScale);

                    if (i % 4 == 0)
                        image.Tint = new Color<float>(1, 1, 0, 0);

                    if (j % 4 == 0)
                        image.Tint = new Color<float>(1, 0, 1, 0);

                    nodes.Add(image);
                }
            }
        }
Example #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="RectangleMode"/> class.
        /// </summary>
        public GemsMode()
        {
            // Create a list of gem images.
            SceneNodeLinkedList <float> nodes = new SceneNodeLinkedList <float>();

            RootSceneNode = nodes;

            // Create the blue gem.
            BitmapLoader      systemLoader  = new BitmapLoader(new FileInfo("Images/Gem Blue.png"));
            TextureLoader     textureLoader = new TextureLoader(systemLoader);
            ImageNode <float> image         = new ImageNode <float>(textureLoader);

            image.Point = new Point2 <float>(10, 10);
            image.DrawableRenderAnimators.Add(
                new DisappearingFlickerDrawableAnimation <float>());
            image.DrawableRenderAnimators.Add(
                new UnsteadyFlickerDrawableAnimation <float>()
            {
                OpacityScale = 0.2,
                TimeScale    = 1,
            });
            Updating += image.OnUpdate;
            nodes.Add(image);

            // Create the green gem.
            systemLoader  = new BitmapLoader(new FileInfo("Images/Gem Green.png"));
            textureLoader = new TextureLoader(systemLoader);
            image         = new ImageNode <float>(textureLoader);
            image.Point   = new Point2 <float>(60, 90);
            nodes.Add(image);

            // Create the translucent orange.
            systemLoader  = new BitmapLoader(new FileInfo("Images/Gem Orange.png"));
            textureLoader = new TextureLoader(systemLoader);
            image         = new ImageNode <float>(textureLoader);
            image.Tint    = new Color <float>(0.5f, 1f, 1f, 1f);
            image.Point   = new Point2 <float>(110, 10);
            nodes.Add(image);

            // Create an animated image.
            AnimatedImageNodeController <float> animatedController = new AnimatedImageNodeController <float>();

            animatedController.NeedImageKey += OnLoadImageKey;
            animatedController.Load(new FileInfo("Images/Gem Animation.xml"));
            AnimatedImageNode <float> animatedImage = new AnimatedImageNode <float>(animatedController);

            animatedImage.Point = new Point2 <float>(10, 200);
            Updating           += animatedImage.OnUpdate;
            nodes.Add(animatedImage);
        }
Example #3
0
        /// <summary>
        /// Creates a text node with the given components.
        /// </summary>
        /// <param name="font">The font.</param>
        /// <param name="nodes">The nodes.</param>
        /// <param name="fontSize">Size of the font.</param>
        /// <param name="x">The x.</param>
        /// <param name="y">The y.</param>
        /// <returns></returns>
        private TextNode <float> CreateNode(
            IFontKey font,
            SceneNodeLinkedList <float> nodes,
            float fontSize,
            float x,
            float y)
        {
            TextNode <float> textNode = new TextNode <float>(font);

            textNode.Point    = new Point2 <float>(x, y);
            textNode.Text     = "Hello, World!";
            textNode.FontSize = fontSize;
            nodes.Add(textNode);
            return(textNode);
        }
Example #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="RectangleMode"/> class.
        /// </summary>
        public GemsMode()
        {
            // Create a list of gem images.
            SceneNodeLinkedList<float> nodes = new SceneNodeLinkedList<float>();
            RootSceneNode = nodes;

            // Create the blue gem.
            BitmapLoader systemLoader = new BitmapLoader(new FileInfo("Images/Gem Blue.png"));
            TextureLoader textureLoader = new TextureLoader(systemLoader);
            ImageNode<float> image = new ImageNode<float>(textureLoader);
            image.Point = new Point2<float>(10, 10);
            image.DrawableRenderAnimators.Add(
                new DisappearingFlickerDrawableAnimation<float>());
            image.DrawableRenderAnimators.Add(
                new UnsteadyFlickerDrawableAnimation<float>()
                {
                    OpacityScale = 0.2,
                    TimeScale = 1,
                });
            Updating += image.OnUpdate;
            nodes.Add(image);

            // Create the green gem.
            systemLoader = new BitmapLoader(new FileInfo("Images/Gem Green.png"));
            textureLoader = new TextureLoader(systemLoader);
            image = new ImageNode<float>(textureLoader);
            image.Point = new Point2<float>(60, 90);
            nodes.Add(image);

            // Create the translucent orange.
            systemLoader = new BitmapLoader(new FileInfo("Images/Gem Orange.png"));
            textureLoader = new TextureLoader(systemLoader);
            image = new ImageNode<float>(textureLoader);
            image.Tint = new Color<float>(0.5f, 1f, 1f, 1f);
            image.Point = new Point2<float>(110, 10);
            nodes.Add(image);

            // Create an animated image.
            AnimatedImageNodeController<float> animatedController = new AnimatedImageNodeController<float>();
            animatedController.NeedImageKey += OnLoadImageKey;
            animatedController.Load(new FileInfo("Images/Gem Animation.xml"));
            AnimatedImageNode<float> animatedImage = new AnimatedImageNode<float>(animatedController);
            animatedImage.Point = new Point2<float>(10, 200);
            Updating += animatedImage.OnUpdate;
            nodes.Add(animatedImage);
        }
Example #5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="RectangleMode"/> class.
        /// </summary>
        public SvgSquaresMode()
        {
            // Create a list of gem images.
            SceneNodeLinkedList <float> nodes = new SceneNodeLinkedList <float>();

            RootSceneNode = nodes;

            // Load the image into memory.
            svgLoader = new SvgLoader(new FileInfo("Images/1cm.svg"));
            float screenScale = Platform.Instance.Window.Resolution.Height / 16f;

            svgLoader.Scale = screenScale * SvgImageLoader.Meter100px;
            TextureLoader textureLoader = new TextureLoader(svgLoader);

            // Create squares across the board.
            rows    = (int)(440 / screenScale);
            columns = (int)(600 / (2 * screenScale));

            for (int i = 0; i < columns; i++)
            {
                for (int j = 0; j < rows; j++)
                {
                    ImageNode <float> image = new ImageNode <float>(textureLoader);
                    image.Point = new Point2 <float>((j % 2) * screenScale + i * 2 * screenScale, j * screenScale);

                    if (i % 4 == 0)
                    {
                        image.Tint = new Color <float>(1, 1, 0, 0);
                    }

                    if (j % 4 == 0)
                    {
                        image.Tint = new Color <float>(1, 0, 1, 0);
                    }

                    nodes.Add(image);
                }
            }
        }
Example #6
0
        /// <summary>
        /// Called when the resolution is changed.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="args">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        protected override void OnResolutionChanged(object sender, EventArgs args)
        {
            // Call the parent's resolution change.
            base.OnResolutionChanged(sender, args);

            // Adjust the SVG loader.
            float screenScale = Platform.Instance.Window.Resolution.Height / 16f;

            svgLoader.Scale = screenScale * SvgImageLoader.Meter100px;

            // Create squares across the board.
            SceneNodeLinkedList <float> nodes = (SceneNodeLinkedList <float>)RootSceneNode;
            int k = 0;

            for (int i = 0; i < columns; i++)
            {
                for (int j = 0; j < rows; j++)
                {
                    ImageNode <float> node = (ImageNode <float>)nodes[k];
                    node.Point = new Point2 <float>((j % 2) * screenScale + i * 2 * screenScale, j * screenScale);
                    k++;
                }
            }
        }
Example #7
0
        /// <summary>
        /// Initializes a new instance of the <see cref="FontsMode"/> class.
        /// </summary>
        public FontsMode()
        {
            // Create a list of gem images.
            SceneNodeLinkedList<float> nodes = new SceneNodeLinkedList<float>();
            RootSceneNode = nodes;

            // Create the basic font.
            IFontKey font = FtglFontLoader.Load(new FileInfo("Fonts/lilac.ttf"));
            TextNode<float> textNode = new TextNode<float>(font);
            textNode.Point = new Point2<float>(10, 10);
            textNode.Text = "Hello, World.";
            textNode.FontSize = 30;
            nodes.Add(textNode);

            // Create a larger version.
            font = FtglFontLoader.Load(new FileInfo("Fonts/carbon.ttf"));
            textNode = new TextNode<float>(font);
            textNode.Point = new Point2<float>(10, 50);
            textNode.Text = "13";
            textNode.FontSize = 110;
            textNode.Tint = new Color<float>(1.0f, 1.0f, 0.25f, 0.25f);
            nodes.Add(textNode);

            font = FtglFontLoader.Load(new FileInfo("Fonts/carbon.ttf"));
            textNode = new TextNode<float>(font);
            textNode.Point = new Point2<float>(90, 60);
            textNode.Text = "/";
            textNode.FontSize = 180;
            nodes.Add(textNode);

            font = FtglFontLoader.Load(new FileInfo("Fonts/carbon.ttf"));
            textNode = new TextNode<float>(font);
            textNode.Point = new Point2<float>(130, 160);
            textNode.Text = "23";
            textNode.FontSize = 110;
            nodes.Add(textNode);

            // Set up the various text nodes
            int y = 10;
            CreateNode(font, nodes, 30, 350, y);

            y += 40;
            textNode = CreateNode(font, nodes, 30, 350, y);
            textNode.DrawableRenderAnimators.Add(
                new UnsteadyFlickerDrawableAnimation<float>()
                {
                    OpacityScale = 0.2,
                    TimeScale = 1,
                });
            Updating += textNode.OnUpdate;

            y += 40;
            textNode = CreateNode(font, nodes, 30, 350, y);
            textNode.DrawableRenderAnimators.Add(
                new DisappearingFlickerDrawableAnimation<float>());
            Updating += textNode.OnUpdate;

            y += 40;
            textNode = CreateNode(font, nodes, 30, 350, y);
            textNode.DrawableRenderAnimators.Add(
                new DisappearingFlickerDrawableAnimation<float>());
            textNode.DrawableRenderAnimators.Add(
                new UnsteadyFlickerDrawableAnimation<float>()
                {
                    OpacityScale = 0.2,
                    TimeScale = 1,
                });
            Updating += textNode.OnUpdate;
        }
Example #8
0
 /// <summary>
 /// Creates a text node with the given components.
 /// </summary>
 /// <param name="font">The font.</param>
 /// <param name="nodes">The nodes.</param>
 /// <param name="fontSize">Size of the font.</param>
 /// <param name="x">The x.</param>
 /// <param name="y">The y.</param>
 /// <returns></returns>
 private TextNode<float> CreateNode(
     IFontKey font,
     SceneNodeLinkedList<float> nodes,
     float fontSize,
     float x,
     float y)
 {
     TextNode<float> textNode = new TextNode<float>(font);
     textNode.Point = new Point2<float>(x, y);
     textNode.Text = "Hello, World!";
     textNode.FontSize = fontSize;
     nodes.Add(textNode);
     return textNode;
 }
Example #9
0
        /// <summary>
        /// Initializes a new instance of the <see cref="FontsMode"/> class.
        /// </summary>
        public FontsMode()
        {
            // Create a list of gem images.
            SceneNodeLinkedList <float> nodes = new SceneNodeLinkedList <float>();

            RootSceneNode = nodes;

            // Create the basic font.
            IFontKey         font     = FtglFontLoader.Load(new FileInfo("Fonts/lilac.ttf"));
            TextNode <float> textNode = new TextNode <float>(font);

            textNode.Point    = new Point2 <float>(10, 10);
            textNode.Text     = "Hello, World.";
            textNode.FontSize = 30;
            nodes.Add(textNode);

            // Create a larger version.
            font              = FtglFontLoader.Load(new FileInfo("Fonts/carbon.ttf"));
            textNode          = new TextNode <float>(font);
            textNode.Point    = new Point2 <float>(10, 50);
            textNode.Text     = "13";
            textNode.FontSize = 110;
            textNode.Tint     = new Color <float>(1.0f, 1.0f, 0.25f, 0.25f);
            nodes.Add(textNode);

            font              = FtglFontLoader.Load(new FileInfo("Fonts/carbon.ttf"));
            textNode          = new TextNode <float>(font);
            textNode.Point    = new Point2 <float>(90, 60);
            textNode.Text     = "/";
            textNode.FontSize = 180;
            nodes.Add(textNode);

            font              = FtglFontLoader.Load(new FileInfo("Fonts/carbon.ttf"));
            textNode          = new TextNode <float>(font);
            textNode.Point    = new Point2 <float>(130, 160);
            textNode.Text     = "23";
            textNode.FontSize = 110;
            nodes.Add(textNode);

            // Set up the various text nodes
            int y = 10;

            CreateNode(font, nodes, 30, 350, y);

            y       += 40;
            textNode = CreateNode(font, nodes, 30, 350, y);
            textNode.DrawableRenderAnimators.Add(
                new UnsteadyFlickerDrawableAnimation <float>()
            {
                OpacityScale = 0.2,
                TimeScale    = 1,
            });
            Updating += textNode.OnUpdate;

            y       += 40;
            textNode = CreateNode(font, nodes, 30, 350, y);
            textNode.DrawableRenderAnimators.Add(
                new DisappearingFlickerDrawableAnimation <float>());
            Updating += textNode.OnUpdate;

            y       += 40;
            textNode = CreateNode(font, nodes, 30, 350, y);
            textNode.DrawableRenderAnimators.Add(
                new DisappearingFlickerDrawableAnimation <float>());
            textNode.DrawableRenderAnimators.Add(
                new UnsteadyFlickerDrawableAnimation <float>()
            {
                OpacityScale = 0.2,
                TimeScale    = 1,
            });
            Updating += textNode.OnUpdate;
        }