示例#1
0
        public void StaticFont()
        {
            var tc = new TestCore();

            tc.Init();

            Assert.True(Font.GenerateFontFile("../../Core/TestData/Font/mplus-1m-regular.ttf", "test.a2f", 100, "Hello, world! こんにちは"));
            var font1 = Font.LoadStaticFontStrict("test.a2f");

            Assert.NotNull(font1);

            const string path = "Serialization/StaticFont.bin";

            Serialize(path, font1);

            Assert.True(System.IO.File.Exists(path));

            var font2 = Deserialize <Font>(path);

            Assert.NotNull(font2);

            Assert.AreEqual(font1.Path, font2.Path);
            Assert.AreEqual(font1.Ascent, font2.Ascent);
            Assert.AreEqual(font1.Descent, font2.Descent);
            Assert.AreEqual(font1.LineGap, font2.LineGap);
            Assert.AreEqual(font1.Size, font2.Size);

            var obj1 = new TextNode()
            {
                Position = new Vector2F(100, 100),
                Font     = font1,
                Text     = "Hellow"
            };
            var obj2 = new TextNode()
            {
                Position = new Vector2F(100, 500),
                Font     = font2,
                Text     = "Hellow"
            };

            Engine.AddNode(obj1);
            Engine.AddNode(obj2);

            tc.LoopBody(null, null);

            tc.End();
        }
示例#2
0
        public void TextNode2()
        {
            var tc = new TestCore();

            tc.Init();

            var font  = Font.LoadDynamicFont("../../Core/TestData/Font/mplus-1m-regular.ttf", 40);
            var font2 = Font.LoadDynamicFont("../../Core/TestData/Font/GenYoMinJP-Bold.ttf", 40);

            Assert.NotNull(font);
            Assert.NotNull(font2);
            var imageFont = Font.CreateImageFont(font);

            imageFont.AddImageGlyph('〇', Texture2D.Load(@"../../Core/TestData/IO/AltseedPink.png"));

            TextNode node = new TextNode()
            {
                Font = font2, Text = "Hello, world! こんにちは カーニングあるよ!!", IsEnableKerning = false, Color = new Color(255, 0, 0, 200)
            };

            Engine.AddNode(node);
            Engine.AddNode(new TextNode()
            {
                Font = font2, Text = "Hello, world! こんにちは カーニングないです", Color = new Color(0, 255, 0, 200)
            });
            Engine.AddNode(new TextNode()
            {
                Font = font, Text = node.Size.ToString(), Position = new Vector2F(0.0f, 50.0f)
            });
            Engine.AddNode(new TextNode()
            {
                Font = font, Text = "字間5です。\n行間標準です。", CharacterSpace = 10, Position = new Vector2F(0.0f, 150.0f)
            });
            Engine.AddNode(new TextNode()
            {
                Font = font, Text = "字間10です。\n行間70です。", CharacterSpace = 50, LineGap = 200, Position = new Vector2F(0.0f, 250.0f)
            });
            tc.Duration = 1000;
            tc.LoopBody(c =>
            {
            }
                        , null);

            tc.End();
        }
示例#3
0
        public void _RenderTexture()
        {
            var tc = new TestCore();

            tc.Init();

            var texture = Texture2D.Load(@"../../Core/TestData/IO/AltseedPink.png");

            Assert.NotNull(texture);

            var node = new SpriteNode();

            //node.Src = new RectF(new Vector2F(100, 100), new Vector2F(200, 200));
            node.Texture = texture;
            //node.CenterPosition = texture.Size / 2;
            node.Scale       = new Vector2F(0.5f, 0.5f);
            node.CameraGroup = 1 << 0;
            Engine.AddNode(node);

            var renderTexture = RenderTexture.Create(new Vector2I(200, 200));
            var camera        = new CameraNode();

            camera.Group         = 0;
            camera.TargetTexture = renderTexture;
            Engine.AddNode(camera);

            var node2 = new SpriteNode();

            node2.CameraGroup = 1 << 1;
            node2.Texture     = renderTexture;
            node2.Position    = new Vector2F(300, 300);
            Engine.AddNode(node2);

            var camera2 = new CameraNode();

            camera2.Group = 1;
            Engine.AddNode(camera2);

            tc.LoopBody(c =>
            {
            }
                        , null);

            tc.End();
        }
示例#4
0
        public void Culling()
        {
            var tc = new TestCore();

            tc.Init();

            var font = Font.LoadDynamicFont("../../Core/TestData/Font/mplus-1m-regular.ttf", 30);

            Assert.NotNull(font);

            var texture = Texture2D.Load(@"../../Core/TestData/IO/AltseedPink.png");

            Assert.NotNull(texture);

            var text = new TextNode()
            {
                Font = font, Text = "", ZOrder = 10
            };

            Engine.AddNode(text);

            var parent = new Altseed.Node();

            Engine.AddNode(parent);

            tc.LoopBody(c =>
            {
                text.Text = "Drawing Object : " + Engine.CullingSystem.DrawingRenderedCount + " FPS: " + Engine.CurrentFPS.ToString();

                var node      = new SpriteNode();
                node.Src      = new RectF(new Vector2F(100, 100), new Vector2F(200, 200));
                node.Texture  = texture;
                node.Position = new Vector2F(200, -500);
                parent.AddChildNode(node);

                foreach (var item in parent.Children.OfType <SpriteNode>())
                {
                    item.Position += new Vector2F(0, 10);
                }
            }, null);

            tc.End();
        }
示例#5
0
        public void BeginEnd()
        {
            var tc = new TestCore(new Configuration {
                ToolEnabled = true
            });

            tc.Init();

            tc.LoopBody(c =>
            {
                if (Engine.Tool.Begin("Test", ToolWindow.None))
                {
                    Engine.Tool.End();
                }
            }
                        , null);

            tc.End();
        }
示例#6
0
        public void PauseAndResume()
        {
            var tc = new TestCore();

            tc.Init();

            var texture = Texture2D.Load(@"../../Core/TestData/IO/AltseedPink.png");

            Assert.NotNull(texture);

            var node = new RotateSpriteNode();

            node.Texture = texture;
            node.AdjustSize();
            node.CenterPosition = texture.Size / 2;
            node.Position       = new Vector2F(200, 200);
            Engine.AddNode(node);

            var node2 = new RotateSpriteNode();

            node2.Texture = texture;
            node2.AdjustSize();
            node2.CenterPosition = texture.Size / 2;
            node2.Position       = new Vector2F(600, 200);
            Engine.AddNode(node2);

            tc.LoopBody(c =>
            {
                if (c == 50)
                {
                    Engine.Pause(node);
                }
                if (c == 150)
                {
                    Engine.Resume();
                }
            }
                        , null);

            tc.End();
        }
示例#7
0
        public void Play()
        {
            var tc = new TestCore();

            tc.Init();

            var bgm = Altseed.Sound.Load(@"../../Core/TestData/Sound/bgm1.ogg", false);
            var se  = Altseed.Sound.Load(@"../../Core/TestData/Sound/se1.wav", true);

            Assert.NotNull(bgm);
            Assert.NotNull(se);

            var bgm_id = Engine.Sound.Play(bgm);
            var se_id  = Engine.Sound.Play(se);

            tc.LoopBody(null, null);

            Engine.Sound.StopAll();

            tc.End();
        }
示例#8
0
        public void GrayScale()
        {
            var tc = new TestCore();

            tc.Init();

            var texture = Texture2D.Load(@"../../Core/TestData/IO/AltseedPink.png");

            Assert.NotNull(texture);

            Engine.AddNode(new SpriteNode()
            {
                Texture = texture
            });

            Engine.AddNode(new PostEffectGrayScaleNode());

            tc.LoopBody(c => {
            }, null);

            tc.End();
        }
示例#9
0
        public void EnuemrateAncestors()
        {
            var tc = new TestCore();

            tc.Init();

            var t1 = Texture2D.Load(@"../../Core/TestData/IO/AltseedPink.png");

            Assert.NotNull(t1);

            var s = new SpriteNode();

            s.Src      = new RectF(new Vector2F(100, 100), new Vector2F(100, 100));
            s.Texture  = t1;
            s.Position = new Vector2F(100, 100);

            var s2 = new SpriteNode();

            s2.Src      = new RectF(new Vector2F(200, 200), new Vector2F(100, 100));
            s2.Texture  = t1;
            s2.Position = new Vector2F(200, 0);

            s.AddChildNode(s2);

            Engine.AddNode(s);

            tc.LoopBody(c =>
            {
                if (c == 2)
                {
                    var e = s2.EnumerateAncestors().ToArray();
                    Assert.AreEqual(1, e.Length);
                    Assert.AreSame(e[0], s);
                }
                s.Angle++;
            }, null);

            tc.End();
        }
示例#10
0
        public void Loop()
        {
            var tc = new TestCore();

            tc.Init();

            var bgm = Altseed.Sound.Load(@"../../Core/TestData/Sound/bgm1.ogg", false);

            Assert.NotNull(bgm);

            bgm.IsLoopingMode     = true;
            bgm.LoopStartingPoint = 1f;
            bgm.LoopEndPoint      = 2.5f;

            var bgm_id = Engine.Sound.Play(bgm);

            tc.LoopBody(null, null);

            Engine.Sound.StopAll();

            tc.End();
        }
示例#11
0
        public void LightBloom()
        {
            var tc = new TestCore();

            tc.Init();

            var texture = Texture2D.Load(@"../../Core/TestData/IO/AltseedPink.png");

            Assert.NotNull(texture);

            Engine.AddNode(new SpriteNode()
            {
                Texture = texture
            });

            Engine.AddNode(new PostEffectLightBloomNode {
                Threashold = 0.1f
            });

            tc.LoopBody(c => {
            }, null);

            tc.End();
        }
示例#12
0
        public void TreeDelete()
        {
            var tc = new TestCore();

            tc.Init();

            var t1 = Texture2D.Load(@"../../Core/TestData/IO/AltseedPink.png");

            Assert.NotNull(t1);

            var s = new SpriteNode();

            s.Src      = new RectF(new Vector2F(100, 100), new Vector2F(100, 100));
            s.Texture  = t1;
            s.Position = new Vector2F(100, 100);

            var s2 = new SpriteNode();

            s2.Src      = new RectF(new Vector2F(200, 200), new Vector2F(100, 100));
            s2.Texture  = t1;
            s2.Position = new Vector2F(200, 200);

            s.AddChildNode(s2);

            Engine.AddNode(s);

            tc.LoopBody(c =>
            {
                if (c == 100)
                {
                    Engine.RemoveNode(s);
                }
            }, null);

            tc.End();
        }
示例#13
0
        public void Anchor()
        {
            var tc = new TestCore();

            tc.Init();

            var font = Font.LoadDynamicFont("../../Core/TestData/Font/mplus-1m-regular.ttf", 30);

            Assert.NotNull(font);

            var texture = Texture2D.Load(@"../../Core/TestData/IO/AltseedPink.png");

            Assert.NotNull(texture);

            Vector2F rectSize = texture.Size;
            var      parent   = new PolygonNode();

            parent.Position = new Vector2F(320, 240);
            //parent.Pivot = new Vector2F(0.5f, 0.5f);
            parent.SetVertexes(new[] {
                new Vector2F(0, 0),
                new Vector2F(rectSize.X, 0),
                new Vector2F(rectSize.X, rectSize.Y),
                new Vector2F(0, rectSize.Y),
            }, new Color(255, 255, 255, 255));
            parent.AdjustSize();
            Engine.AddNode(parent);

            var child = new SpriteNode();

            child.Texture   = texture;
            child.Position  = new Vector2F(120, 200);
            child.Src       = new RectF(new Vector2F(), texture.Size);
            child.Pivot     = new Vector2F(0.5f, 0.5f);
            child.AnchorMin = new Vector2F(0.2f, 0.0f);
            child.AnchorMax = new Vector2F(0.8f, 1f);
            child.ZOrder    = 10;
            child.Mode      = DrawMode.Fill;
            child.AdjustSize();
            parent.AddChildNode(child);

            var childText = new TextNode();

            childText.Font                = font;
            childText.Color               = new Color(0, 0, 0);
            childText.Text                = "あいうえお";
            childText.Pivot               = new Vector2F(0.5f, 0.5f);
            childText.AnchorMin           = new Vector2F(0.5f, 0.5f);
            childText.AnchorMax           = new Vector2F(0.5f, 0.5f);
            childText.ZOrder              = 15;
            childText.HorizontalAlignment = HorizontalAlignment.Center;
            childText.VerticalAlignment   = VerticalAlignment.Center;
            childText.Size                = child.Size;
            child.AddChildNode(childText);

            var text = new TextNode()
            {
                Font = font, Text = "", ZOrder = 10
            };

            Engine.AddNode(text);

            tc.Duration = 10000;
            tc.LoopBody(c =>
            {
                if (Engine.Keyboard.GetKeyState(Keys.Right) == ButtonState.Hold)
                {
                    rectSize.X += 1.5f;
                }
                if (Engine.Keyboard.GetKeyState(Keys.Left) == ButtonState.Hold)
                {
                    rectSize.X -= 1.5f;
                }
                if (Engine.Keyboard.GetKeyState(Keys.Down) == ButtonState.Hold)
                {
                    rectSize.Y += 1.5f;
                }
                if (Engine.Keyboard.GetKeyState(Keys.Up) == ButtonState.Hold)
                {
                    rectSize.Y -= 1.5f;
                }

                if (Engine.Keyboard.GetKeyState(Keys.D) == ButtonState.Hold)
                {
                    parent.Position += new Vector2F(1.5f, 0);
                }
                if (Engine.Keyboard.GetKeyState(Keys.A) == ButtonState.Hold)
                {
                    parent.Position += new Vector2F(-1.5f, 0);
                }
                if (Engine.Keyboard.GetKeyState(Keys.S) == ButtonState.Hold)
                {
                    parent.Position += new Vector2F(0, 1.5f);
                }
                if (Engine.Keyboard.GetKeyState(Keys.W) == ButtonState.Hold)
                {
                    parent.Position += new Vector2F(0, -1.5f);
                }

                parent.SetVertexes(new[] {
                    new Vector2F(0, 0),
                    new Vector2F(rectSize.X, 0),
                    new Vector2F(rectSize.X, rectSize.Y),
                    new Vector2F(0, rectSize.Y),
                }, new Color(255, 255, 255, 255));
                parent.AdjustSize();

                text.Text = child.Size.ToString();
            }, null);

            tc.End();
        }
示例#14
0
        public void SpriteNode()
        {
            var tc = new TestCore();

            tc.Init();

            var texture = Texture2D.Load(@"../../Core/TestData/IO/AltseedPink.png");

            Assert.NotNull(texture);

            var node = new SpriteNode();

            node.Src     = new RectF(new Vector2F(100, 100), new Vector2F(200, 200));
            node.Texture = texture;
            node.Pivot   = new Vector2F(0.5f, 0.5f);
            node.AdjustSize();
            Engine.AddNode(node);

            tc.LoopBody(c =>
            {
                if (Engine.Keyboard.GetKeyState(Keys.Right) == ButtonState.Hold)
                {
                    node.Position += new Vector2F(1.5f, 0);
                }
                if (Engine.Keyboard.GetKeyState(Keys.Left) == ButtonState.Hold)
                {
                    node.Position -= new Vector2F(1.5f, 0);
                }
                if (Engine.Keyboard.GetKeyState(Keys.Down) == ButtonState.Hold)
                {
                    node.Position += new Vector2F(0, 1.5f);
                }
                if (Engine.Keyboard.GetKeyState(Keys.Up) == ButtonState.Hold)
                {
                    node.Position -= new Vector2F(0, 1.5f);
                }
                if (Engine.Keyboard.GetKeyState(Keys.B) == ButtonState.Hold)
                {
                    node.Scale += new Vector2F(0.01f, 0.01f);
                }
                if (Engine.Keyboard.GetKeyState(Keys.S) == ButtonState.Hold)
                {
                    node.Scale -= new Vector2F(0.01f, 0.01f);
                }
                if (Engine.Keyboard.GetKeyState(Keys.R) == ButtonState.Hold)
                {
                    node.Angle += 3;
                }
                if (Engine.Keyboard.GetKeyState(Keys.L) == ButtonState.Hold)
                {
                    node.Angle -= 3;
                }
                if (Engine.Keyboard.GetKeyState(Keys.X) == ButtonState.Hold)
                {
                    node.Src = new RectF(node.Src.X, node.Src.Y, node.Src.Width - 2.0f, node.Src.Height - 2.0f);
                }
                if (Engine.Keyboard.GetKeyState(Keys.Z) == ButtonState.Hold)
                {
                    node.Src = new RectF(node.Src.X, node.Src.Y, node.Src.Width + 2.0f, node.Src.Height + 2.0f);
                }
                if (Engine.Keyboard.GetKeyState(Keys.C) == ButtonState.Hold)
                {
                    node.Src = new RectF(node.Src.X - 2.0f, node.Src.Y - 2.0f, node.Src.Width, node.Src.Height);
                }
                if (Engine.Keyboard.GetKeyState(Keys.V) == ButtonState.Hold)
                {
                    node.Src = new RectF(node.Src.X + 2.0f, node.Src.Y + 2.0f, node.Src.Width, node.Src.Height);
                }
            }
                        , null);

            tc.End();
        }