Esempio n. 1
0
        public void Basic()
        {
            var tc = new TestCore();

            tc.Init();

            var texture = RenderTexture.Create(new Vector2I(640, 480), TextureFormat.R8G8B8A8_UNORM);

            Assert.NotNull(texture);

            var node = new SpriteNode();

            node.Texture = texture;
            Engine.AddNode(node);

            var mp = MediaPlayer.Load(@"TestData/Movie/Test1.mp4");

            mp.Play(false);

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

            tc.End();
        }
Esempio n. 2
0
        // エンジンに追加された時に実行
        protected override void OnAdded()
        {
            // キャラクターノードを追加
            AddChildNode(characterNode);

            // UIを表示するノード
            var uiNode = new Node();

            // UIノードを追加
            AddChildNode(uiNode);

            // 背景に使用するテクスチャ
            var backTexture = new SpriteNode();

            // 背景のテクスチャを読み込む
            backTexture.Texture = Texture2D.LoadStrict("Resources/Background.png");
            // 表示位置を奥に設定
            backTexture.ZOrder = -100;

            // 背景テクスチャを追加
            AddChildNode(backTexture);

            // プレイヤーを設定
            player = new Player(this, new Vector2F(100, 360));

            // キャラクターノードにプレイヤーを追加
            characterNode.AddChildNode(player);

            // 全てのウェーブを初期化する
            InitAllWave();

            + // BGMを初期化する
            +InitBGM();
        }
Esempio n. 3
0
        public void NoRenderTexture()
        {
            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       = texture.Size / 2;
            node.CameraGroup = 1 << 0;
            Engine.AddNode(node);

            var camera = new CameraNode();

            camera.Transform = Matrix44F.GetTranslation2D(new Vector2F(-200, -200));
            camera.Group     = 0;
            Engine.AddNode(camera);

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

            tc.End();
        }
Esempio n. 4
0
        protected override void OnAdded()
        {
            //背景
            var background = new SpriteNode();

            background.Texture  = Texture2D.Load("bg_main.jpg");
            background.Position = new Vector2F(0, 0);
            background.ZOrder   = Common.Parameter.ZOrder.BackGround;
            AddChildNode(background);

            var sign = new SpriteNode();

            sign.Texture  = Texture2D.Load("homesign.png");
            sign.Position = new Vector2F(0, 0);
            sign.ZOrder   = Common.Parameter.ZOrder.Panel;
            AddChildNode(sign);

            _powerPanel = new PowerPanel();
            _powerPanel.SetPosition(new Vector2F(sign.Texture.Size.X, 0));
            _powerPanel.SetNode(this);
            _powerPanel.UpdateValue();

            _moneyPanel = new MoneyPanel();
            _moneyPanel.SetPosition(new Vector2F(sign.Texture.Size.X, _powerPanel.GetHeight()));
            _moneyPanel.SetNode(this);
            _moneyPanel.SetValue(GameData.PlayerData.Money);

            _weatherPanel = new WeatherPanel();
            _weatherPanel.SetPosition(new Vector2F(sign.Texture.Size.X, _powerPanel.GetHeight() + _moneyPanel.GetHeight()));
            _weatherPanel.SetNode(this);
            _weatherPanel.UpdateValue();

            menu = new CommonMenu(this);
        }
Esempio n. 5
0
        static void Main(string[] args)
        {
            // Altseed を初期化します。
            if (!Engine.Initialize("SpriteNode", 640, 480, new Configuration())) return;

            // テクスチャを読み込みます。
            var texture = Texture2D.Load(@"TestData\IO\AltseedPink256.png");

            // スプライトを描画するノードを作成します。
            var node = new SpriteNode();

            // テクスチャを設定します。
            node.Texture = texture;

            // テクスチャのサイズで切り出す
            node.Src = new RectF(new Vector2F(), texture.Size);

            // ノードを登録します。
            Engine.AddNode(node);

            // メインループ。
            // Altseed のウインドウが閉じられると終了します。
            while (Engine.DoEvents())
            {
                // Altseed を更新します。
                Engine.Update();
            }

            // Altseed の終了処理をします。
            Engine.Terminate();
        }
Esempio n. 6
0
        public SpriteNode Attach(ProxySprite pNode)
        {
            SpriteNode pSpriteNode = (SpriteNode)this.baseAdd();

            pSpriteNode.Set(pNode, this);
            return(pSpriteNode);
        }
Esempio n. 7
0
        private static Domain.Nodes.Node BuildSpriteNode(DocumentData data, Node node)
        {
            var spriteRef  = new SpriteReference(node.SpriteKey);
            var domainNode = new SpriteNode(data.MessageBus, node.Id, node.Name, spriteRef)
            {
                Parent = node.ParentId == 0
                    ? null
                    : data.Nodes[node.ParentId] // node list is in hierarchical order, so parents always are available when their children are added.
            };

            if (domainNode.Parent == null)
            {
                data.RootNodes.InternalAdd(domainNode);
            }
            else
            {
                domainNode.Parent?.InternalAdd(domainNode);
            }

            domainNode.GetProperty(PropertyType.TranslationX).SetDesignValueInternal(node.Position.X);
            domainNode.GetProperty(PropertyType.TranslationY).SetDesignValueInternal(node.Position.Y);
            domainNode.GetProperty(PropertyType.RotationAngle).SetDesignValueInternal(node.Angle);
            domainNode.GetProperty(PropertyType.Visibility).SetDesignValueInternal(node.IsVisible ? 1f : 0f);

            return(domainNode);
        }
Esempio n. 8
0
        public SpriteNode Attach(GameSprite.Name name)
        {
            SpriteNode spriteNode = (SpriteNode)baseAdd();

            spriteNode.Initialize(name);
            return(spriteNode);
        }
Esempio n. 9
0
        protected bool HandleMouseRightHold(SpriteNode node)
        {
            if (handleVisibleOrNull(node))
            {
                return(false);
            }

            if (previousMouse.RightButton == ButtonState.Pressed && currentMouse.RightButton == ButtonState.Pressed)
            {
                if (!_holdRightWatch.IsRunning)
                {
                    _holdRightWatch.Start();
                }

                if (_holdRightWatch.ElapsedMilliseconds > 500)
                {
                    return(true);
                }
            }
            else
            {
                _holdRightWatch.Reset();
            }

            return(false);
        }
Esempio n. 10
0
        static void Main(string[] args)
        {
            // Altseed2 を初期化します。
            if (!Engine.Initialize("PostEffect - Sepia", 640, 480))
            {
                return;
            }

            // 画像を表示するノードを作成して登録します。
            // 詳しくはSpriteのサンプルを参照してください。
            var node = new SpriteNode
            {
                Texture = Texture2D.Load(@"TestData/Graphics/flower.png"),
                Scale   = new Vector2F(0.5f, 0.5f)
            };

            Engine.AddNode(node);

            // セピアを適用するポストエフェクトを作成して登録します。
            var postEffect = new PostEffectSepiaNode();

            Engine.AddNode(postEffect);

            // メインループ。
            // Altseed のウインドウが閉じられると終了します。
            while (Engine.DoEvents())
            {
                // Altseed を更新します。
                Engine.Update();
            }

            // Altseed の終了処理をします。
            Engine.Terminate();
        }
Esempio n. 11
0
        private void RunDestroyer(float timeLine, int x1, int y1, int x2, int y2)
        {
            var p         = GetPointFromCell(x1, y1);
            int cells     = Math.Max(Math.Abs(x2 - x1), Math.Abs(y2 - y1));
            var destroyer = new SpriteNode(1, p.X, p.Y)
            {
                IsAlive = false, Sprite = new Bitmap("destroyer.png"), Opacity = 0
            };

            _spriteNodes.Add(destroyer);
            _actions.Add(new Sequence(destroyer, 0, new Action[]
            {
                new Action(destroyer, timeLine - 100),
                new MoveBy(destroyer, 250 * cells, CellSize * (x2 - x1), CellSize * (y2 - y1))
            }));
            _actions.Add(new Sequence(destroyer, 0, new Action[]
            {
                new Action(destroyer, timeLine - 100),
                new FadeTo(destroyer, 10, 1)
            }));
            _actions.Add(new Sequence(destroyer, 0, new Action[]
            {
                new RotateBy(destroyer, 150, 45),
                new RotateBy(destroyer, 50, -45)
            })
            {
                Repeat = true, RepeatTimes = cells + ((int)timeLine - 100) / (150 + 50) - 1
            });
        }
Esempio n. 12
0
        private SpriteNode AddNewNode(int x, int y)
        {
            var p    = GetPointFromCell(x, y);
            int code = _rnd.Next(1, 6);

            // game rules: check for two sames stones in row and column before our
            int forbidden1 = -1, forbidden2 = -1;

            if (x > 1)
            {
                forbidden1 = _field[x - 1, y].Code == _field[x - 2, y].Code ? _field[x - 1, y].Code : -1;
            }
            if (y > 1)
            {
                forbidden2 = _field[x, y - 1].Code == _field[x, y - 2].Code ? _field[x, y - 1].Code : -1;
            }
            while (code == forbidden1 || code == forbidden2)
            {
                code = _rnd.Next(1, 6);
            }

            var node = new SpriteNode(code, p.X, p.Y)
            {
                IsAlive = true, MovementPriority = ++_movementCount
            };

            _spriteNodes.Add(node);
            _field[x, y] = node;

            return(node);
        }
Esempio n. 13
0
        // エンジンに追加された時に実行
        protected override void OnAdded()
        {
            // キャラクターノードを追加
            AddChildNode(characterNode);

            // UIを表示するノード
            var uiNode = new Node();

            // UIノードを追加
            AddChildNode(uiNode);

            + // 背景に使用するテクスチャ
            +var backTexture = new SpriteNode();
            + // 背景のテクスチャを読み込む
            +backTexture.Texture = Texture2D.LoadStrict("Resources/Background.png");
            + // 表示位置を奥に設定
            +backTexture.ZOrder = -100;
            +
            + // 背景テクスチャを追加
            +AddChildNode(backTexture);

            // プレイヤーを設定
            player = new Player(new Vector2F(100, 360));

            // キャラクターノードにプレイヤーを追加
            characterNode.AddChildNode(player);
        }
Esempio n. 14
0
 protected override void ReturnSelf()
 {
     Root.Return(Node);
     Node          = null;
     OnUpdateEvent = null;
     BoxUISystem.Return(this);
 }
Esempio n. 15
0
        static void Main(string[] args)
        {
            // エンジンを初期化
            Engine.Initialize("Tutorial", 960, 720);

            + // 自機
            +var player = new SpriteNode();
            + // 自機のテクスチャを読み込む
            +player.Texture = Texture2D.LoadStrict("Resources/Player.png");
            + // 自機の座標を設定
            +player.Position = new Vector2F(100, 360);
            + // 自機の中心座標を設定
            +player.CenterPosition = player.ContentSize / 2;
            +
            + // 自機をエンジンに追加
            +Engine.AddNode(player);

            // メインループ
            while (Engine.DoEvents())
            {
                // エンジンを更新
                Engine.Update();

                // Escapeキーでゲーム終了
                if (Engine.Keyboard.GetKeyState(Key.Escape) == ButtonState.Push)
                {
                    break;
                }
            }

            // エンジンの終了処理を行う
            Engine.Terminate();
        }
Esempio n. 16
0
        public void NoRenderTexture()
        {
            var tc = new TestCore();

            tc.Init();

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

            Assert.NotNull(texture);

            var node = new SpriteNode();

            node.Texture        = texture;
            node.CenterPosition = texture.Size / 2;
            node.CameraGroup    = 0b1;
            Engine.AddNode(node);

            var camera = new CameraNode();

            camera.Position = new Vector2F(100, 0);
            camera.Scale    = new Vector2F(2, 2);
            camera.Group    = 0b1;
            Engine.AddNode(camera);

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

            tc.End();
        }
Esempio n. 17
0
        public void MassSpriteNode()
        {
            var tc = new TestCore(new Configuration()
            {
                WaitVSync = false
            });

            tc.Init();

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

            Assert.NotNull(texture);

            var ws   = Engine.WindowSize;
            var size = 10;

            for (var x = 0; x < ws.X / size; x++)
            {
                for (var y = 0; y < ws.Y / size; y++)
                {
                    var node = new SpriteNode();
                    node.Texture  = texture;
                    node.Src      = new RectF(new Vector2F(128 * (x % 2), 128 * (y % 2)), new Vector2F(128, 128));
                    node.Scale    = new Vector2F(1, 1) * size / 128f;
                    node.Position = new Vector2F(x, y) * size;
                    Engine.AddNode(node);
                }
            }

            tc.LoopBody(null, null);

            tc.End();
        }
        static void Main(string[] args)
        {
            // Altseed を初期化します。
            if (!Engine.Initialize("SpriteNode", 640, 480))
            {
                return;
            }

            // TestData ディレクトリからファイルパッケージを生成します。
            // パスワードを ALTSEED とします。
            Engine.File.PackWithPassword("TestData", "Package.pack", "ALTSEED");

            // Package.pack をルートパッケージにします。
            Engine.File.AddRootPackageWithPassword("Package.pack", "ALTSEED");

            // パッケージに含まれる画像データをロードします。
            var texture = Texture2D.Load(@"TestData/IO/AltseedPink256.png");

            // 画像を描画するノードを生成・登録します。
            var node = new SpriteNode();

            node.Texture = texture;
            Engine.AddNode(node);

            // メインループ。
            // Altseed のウインドウが閉じられると終了します。
            while (Engine.DoEvents())
            {
                // Altseed を更新します。
                Engine.Update();
            }

            // Altseed の終了処理をします。
            Engine.Terminate();
        }
Esempio n. 19
0
        public bool HandleMouse(SpriteNode node, Event e)
        {
            previousMouse = currentMouse;
            currentMouse  = Mouse.GetState();

            switch (e)
            {
            case Event.HOLDLEFT:
                return(HandleMouseLeftHold(node));

            case Event.HOLDRIGHT:
                return(HandleMouseRightHold(node));

            case Event.CLICKLEFT:
                return(HandleMouseClickLeft(node));

            case Event.CLICKRIGT:
                return(HandleMouseClickRight(node));

            case Event.MOUSEOVER:
                return(HandleMouseOver(node));

            case Event.MOUSEOUT:
                return(HandleMouseOut(node));

            case Event.CLICKOUTLEFT:
                return(HandleClickOutLeft(node));

            default:
                return(false);
            }
        }
Esempio n. 20
0
 public Sequence(SpriteNode target, float duration, Action[] actions)
     : base(target, duration)
 {
     _actions = actions;
     Duration = _actions.Sum(x => x.Duration);
     _tPrev   = 0;
 }
Esempio n. 21
0
        static void Main(string[] args)
        {
            // エンジンを初期化
            Engine.Initialize("Tutorial", 960, 720);

            // 自機
            +var player = new SpriteNode();
            + // 自機のテクスチャを読み込む
            +player.Texture = Texture2D.LoadStrict("Resources/Player.png");
            + // 自機の座標を設定
            +player.Position = new Vector2F(100, 360);
            + // 自機の中心座標を設定
            +player.CenterPosition = player.Texture.Size / 2;
            +
            + // 自機をエンジンに追加
            +Engine.AddNode(player);

            // メインループ
            while (Engine.DoEvents())
            {
                // エンジンを更新
                Engine.Update();
            }

            // エンジンの終了処理を行う
            Engine.Terminate();
        }
Esempio n. 22
0
        public void TreeAdd()
        {
            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);

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

            tc.End();
        }
Esempio n. 23
0
        static void Main(string[] args)
        {
            // Altseed2 を初期化します。
            if (!Engine.Initialize("SpriteNode", 640, 480))
            {
                return;
            }

            // テクスチャを読み込みます。
            var texture = Texture2D.Load(@"TestData/IO/AltseedPink256.png");

            // スプライトを描画するノードを作成します。
            var node = new SpriteNode();

            // テクスチャを設定します。
            node.Texture = texture;

            // ノードを登録します。
            Engine.AddNode(node);

            // メインループ。
            // Altseed のウインドウが閉じられると終了します。
            while (Engine.DoEvents())
            {
                // Altseed を更新します。
                Engine.Update();
            }

            // Altseed の終了処理をします。
            Engine.Terminate();
        }
Esempio n. 24
0
        static void Main(string[] args)
        {
            // エンジンを初期化
            Engine.Initialize("Tutorial", 960, 720);

            // 自機
            var player = new SpriteNode();

            // 自機のテクスチャを読み込む
            player.Texture = Texture2D.LoadStrict("Resources/Player.png");
            // 自機の座標を設定
            player.Position = new Vector2F(100, 360);
            // 自機の中心座標を設定
            player.CenterPosition = player.ContentSize / 2;

            // 自機をエンジンに追加
            Engine.AddNode(player);

            // メインループ
            while (Engine.DoEvents())
            {
                // エンジンを更新
                Engine.Update();

                // ↑キーでY座標を減少
                if (Engine.Keyboard.GetKeyState(Key.Up) == ButtonState.Hold)
                {
                    player.Position -= new Vector2F(0.0f, 2.5f);
                }

                // ↓キーでY座標を増加
                if (Engine.Keyboard.GetKeyState(Key.Down) == ButtonState.Hold)
                {
                    player.Position += new Vector2F(0.0f, 2.5f);
                }

                // →キーでX座標を増加
                if (Engine.Keyboard.GetKeyState(Key.Right) == ButtonState.Hold)
                {
                    player.Position += new Vector2F(2.5f, 0.0f);
                }

                // ←キーでX座標を減少
                if (Engine.Keyboard.GetKeyState(Key.Left) == ButtonState.Hold)
                {
                    player.Position -= new Vector2F(2.5f, 0.0f);
                }

                // Escapeキーでゲーム終了
                if (Engine.Keyboard.GetKeyState(Key.Escape) == ButtonState.Push)
                {
                    break;
                }
            }

            // エンジンの終了処理を行う
            Engine.Terminate();
        }
Esempio n. 25
0
        public void RemovingNodeCauseCrashWithMaterial()
        {
            var tc = new TestCore(new Configuration()
            {
                WaitVSync = false
            });

            tc.Init();
            Engine.TargetFPS = 10000;
            SpriteNode node = null;

#if !CI
            tc.Duration = 50000;
#endif

            tc.LoopBody(c =>
            {
                if (node != null)
                {
                    Engine.RemoveNode(node);
                }

                node                = new SpriteNode();
                node.Texture        = Texture2D.Load(@"TestData/IO/AltseedPink.png");
                node.CenterPosition = node.Texture.Size / 2;
                node.Position       = new Vector2F(200, 200);
                node.Material       = Material.Create();
                var psCode          = @"
Texture2D mainTex : register(t0);
SamplerState mainSamp : register(s0);
struct PS_INPUT
{
    float4  Position : SV_POSITION;
    float4  Color    : COLOR0;
    float2  UV1 : UV0;
    float2  UV2 : UV1;
};
float4 main(PS_INPUT input) : SV_TARGET 
{ 
    float4 c;
    c = mainTex.Sample(mainSamp, 1.0f - input.UV1) * input.Color;
    return c;
}";
                node.Material.SetShader(Shader.Create("ps", psCode, ShaderStage.Pixel));
                Engine.AddNode(node);


                if (c % 100 == 0)
                {
                    GC.Collect();
                    GC.WaitForFullGCComplete();
                }
            }
                        , null);

            tc.End();
        }
Esempio n. 26
0
        public LabelBase()
        {
            _node         = new SpriteNode();
            _node.Texture = Texture.FarmWindow;

            _text       = new TextNode();
            _text.Font  = Font.LoadDynamicFontStrict("HachiMaruPop-Regular.ttf", 40);
            _text.Color = new Color(0, 0, 0);
        }
Esempio n. 27
0
        public void IsDrawnActuallyWithNoDrawnNode()
        {
            var tc = new TestCore();

            tc.Init();

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

            Assert.NotNull(texture);

            var node = new SpriteNode();

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

            var node2 = new TransformNode();

            node2.CenterPosition = texture.Size / 2;
            node2.Position       = new Vector2F(200, 200);

            var node3 = new RectangleNode();

            node3.RectangleSize  = texture.Size;
            node3.Texture        = texture;
            node3.CenterPosition = texture.Size / 2;
            node3.Position       = new Vector2F(300, 300);

            tc.LoopBody(c =>
            {
                if (c == 2)
                {
                    node.AddChildNode(node2);
                }
                else if (c == 4)
                {
                    node.IsDrawn = false;
                    Assert.IsFalse(node.IsDrawnActually);
                }

                else if (c == 6)
                {
                    node2.AddChildNode(node3);
                }

                else if (c == 8)
                {
                    node.IsDrawn = true;

                    Assert.IsTrue(node.IsDrawnActually);
                    Assert.IsTrue(node3.IsDrawnActually);
                }
            }, null);

            tc.End();
        }
Esempio n. 28
0
        public void Draw()
        {
            SpriteNode pNode = (SpriteNode)baseGetActive();

            while (pNode != null)
            {
                pNode.pSpriteBase.Render();
                pNode = (SpriteNode)pNode.pNext;
            }
        }
Esempio n. 29
0
        public SpriteNode Attach(SpriteBase pNode)
        {
            // Go to Man, get a node from reserve, add to active, return it
            SpriteNode pSBNode = (SpriteNode)this.baseAdd();

            // Initialize SpriteBatchNode
            pSBNode.Set(pNode);

            return(pSBNode);
        }
Esempio n. 30
0
        // エンジンに追加された時に実行
        protected override void OnAdded()
        {
            // キャラクターノードを追加
            AddChildNode(characterNode);

            // UIを表示するノード
            var uiNode = new Node();

            // UIノードを追加
            AddChildNode(uiNode);

            // 背景に使用するテクスチャ
            var backTexture = new SpriteNode();

            // 背景のテクスチャを読み込む
            backTexture.Texture = Texture2D.LoadStrict("Resources/Background.png");
            // 表示位置を奥に設定
            backTexture.ZOrder = -100;

            // 背景テクスチャを追加
            AddChildNode(backTexture);

            // プレイヤーを設定
            player = new Player(this, new Vector2F(100, 360));

            // キャラクターノードにプレイヤーを追加
            characterNode.AddChildNode(player);

            // スコアを表示するノードを設定
            scoreNode = new TextNode();
            // スコア表示に使うフォントを読み込む
            scoreNode.Font = Font.LoadDynamicFontStrict("Resources/GenYoMinJP-Bold.ttf", 30);
            // スコア表示の位置を設定
            scoreNode.Position = new Vector2F();

            // UIノードにスコア表示ノードを追加
            uiNode.AddChildNode(scoreNode);

            // 現在ウェーブを表示するノードを設定
            waveNode = new TextNode();
            // ウェーブ表示に使うフォントを読み込む
            waveNode.Font = Font.LoadDynamicFontStrict("Resources/GenYoMinJP-Bold.ttf", 30);
            // ウェーブ表示の座標を設定
            waveNode.Position = new Vector2F(200, 0);

            // ウェーブ表示ノードを追加
            uiNode.AddChildNode(waveNode);

            // 全てのウェーブを初期化する
            InitAllWave();

            // BGMを初期化する
            InitBGM();
        }