Ejemplo n.º 1
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();
        }
Ejemplo n.º 2
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();
        }
Ejemplo n.º 3
0
        public void PolygonCollider()
        {
            var tc = new TestCore();

            tc.Init();

            var collider1 = new PolygonCollider
            {
                Position = new Vector2F(30f, 30f),
                Rotation = 10.0f,
            };

            var array_g = new Vertex[]
            {
                new Vertex(new Vector3F(10f, 10f, 10f), new Color(100, 100, 100, 100), new Vector2F(10f, 10f), new Vector2F(100f, 100f)),
                new Vertex(new Vector3F(20f, 20f, 20f), new Color(200, 200, 200, 200), new Vector2F(20f, 20f), new Vector2F(200f, 200f)),
                new Vertex(new Vector3F(30f, 30f, 30f), new Color(300, 300, 300, 300), new Vector2F(30f, 30f), new Vector2F(300f, 300f)),
            };

            var array_a = Altseed.Vector2FArray.Create(array_g.Length);

            Assert.NotNull(array_a);
            array_a.FromArray(array_g.Select(v => new Vector2F(v.Position.X, v.Position.Y)).ToArray());

            collider1.Vertexes = array_a;

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

            Serialize(path, collider1);

            var collider2 = Deserialize <PolygonCollider>(path);

            Assert.NotNull(collider2);

            Assert.AreEqual(collider1.Position, collider2.Position);
            Assert.AreEqual(collider1.Rotation, collider2.Rotation);
            Assert.True(Enumerable.SequenceEqual(collider1.Vertexes.ToArray(), collider2.Vertexes.ToArray()));

            tc.End();
        }
Ejemplo n.º 4
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();
        }
Ejemplo n.º 5
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();
        }
Ejemplo n.º 6
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();
        }
Ejemplo n.º 7
0
        public void Configuration()
        {
            var tc = new TestCore();

            tc.Init();

            var config1 = new Configuration()
            {
                ConsoleLoggingEnabled = true,
                FileLoggingEnabled    = false,
                IsFullscreen          = false,
                IsResizable           = true,
                LogFileName           = "Log.txt",
                ToolEnabled           = true
            };

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

            Serialize(path, config1);

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

            var config2 = Deserialize <Configuration>(path);

            Assert.AreEqual(config1.ConsoleLoggingEnabled, true);
            Assert.AreEqual(config1.ConsoleLoggingEnabled, config2.ConsoleLoggingEnabled);
            Assert.AreEqual(config1.FileLoggingEnabled, false);
            Assert.AreEqual(config1.FileLoggingEnabled, config2.FileLoggingEnabled);
            Assert.AreEqual(config1.IsFullscreen, false);
            Assert.AreEqual(config1.IsFullscreen, config2.IsFullscreen);
            Assert.AreEqual(config1.IsResizable, true);
            Assert.AreEqual(config1.IsResizable, config2.IsResizable);
            Assert.AreEqual(config1.LogFileName, "Log.txt");
            Assert.AreEqual(config1.LogFileName, config2.LogFileName);
            Assert.AreEqual(config1.ToolEnabled, true);
            Assert.AreEqual(config1.ToolEnabled, config2.ToolEnabled);

            tc.End();
        }
Ejemplo n.º 8
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();
        }
Ejemplo n.º 9
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();
        }
Ejemplo n.º 10
0
        public void RenderedText()
        {
            var tc = new TestCore();

            tc.Init();

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

            Assert.NotNull(font);

            var text1 = Altseed.RenderedText.Create();

            Assert.NotNull(text1);

            text1.Color = new Color(100, 255, 200, 255);
            text1.Font  = font;
            text1.Text  = "test";

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

            Serialize(path, text1);

            var text2 = Deserialize <RenderedText>(path);

            Assert.NotNull(text2);

            Assert.AreEqual(text1.Color, text2.Color);
            Assert.AreEqual(text1.Material, text2.Material);
            Assert.AreEqual(text1.Font.Path, text2.Font.Path);
            Assert.AreEqual(text1.Font.Size, text2.Font.Size);
            Assert.AreEqual(text1.Text, text2.Text);
            Assert.AreEqual(text1.Transform, text2.Transform);
            Assert.AreEqual(text1.Weight, text2.Weight);

            tc.End();
        }
Ejemplo n.º 11
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();
        }
Ejemplo n.º 12
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();
        }