コード例 #1
0
 public void Initialize(AIBrain brain)
 {
     this.brain  = brain;
     brain.Train = Train;
     brain.UI    = ui;
     deathListener.Reset();
 }
コード例 #2
0
ファイル: EventSystemTests.cs プロジェクト: Ethereal77/stride
        public void EveryFrameClear()
        {
            var game = new EventSystemTest();

            var frameCount = 0;

            var evt = new EventKey();

            game.AddTask(async() =>
            {
                while (frameCount < 25)
                {
                    evt.Broadcast();
                    evt.Broadcast();

                    await game.NextFrame();
                }
            }, 10);

            game.AddTask(async() =>
            {
                var rcv = new EventReceiver(evt, EventReceiverOptions.Buffered);
                while (frameCount < 25)
                {
                    if (frameCount == 20)
                    {
                        var manyEvents = rcv.TryReceiveAll();
                        Assert.Equal(2, manyEvents);
                        game.Exit();
                    }

                    rcv.Reset();

                    await game.NextFrame();

                    frameCount++;
                }
            }, -10);

            game.Run();
        }
コード例 #3
0
        public override async Task Execute()
        {
            // Find our JumpyJetRenderer to start/stop parallax background
            var renderer = (JumpyJetRenderer)((SceneCameraRenderer)SceneSystem.GraphicsCompositor.Game).Child;

            var pauseListener = new EventReceiver(GlobalEvents.CharacterDied);
            var startListener = new EventReceiver(GlobalEvents.Clear);

            while (Game.IsRunning)
            {
                // we don't care for the reason - either way we stop the background
                await pauseListener.ReceiveAsync();

                renderer.StopScrolling();
                startListener.Reset(); // remove any start events that happened before pause

                await startListener.ReceiveAsync();

                renderer.StartScrolling();
                pauseListener.Reset(); // remove any pause events that happened before the start
            }
        }
コード例 #4
0
        public void EveryFrameClear()
        {
            var game = new EventSystemTest();

            var frameCount = 0;

            var evt = new EventKey();

            game.AddTask(async () =>
            {
                while (frameCount < 25)
                {
                    evt.Broadcast();
                    evt.Broadcast();

                    await game.NextFrame();
                }
            }, 10);

            game.AddTask(async () =>
            {
                var rcv = new EventReceiver(evt, EventReceiverOptions.Buffered);
                while (frameCount < 25)
                {
                    if (frameCount == 20)
                    {
                        var manyEvents = rcv.TryReceiveAll();
                        Assert.AreEqual(2, manyEvents);
                        game.Exit();
                    }

                    rcv.Reset();

                    await game.NextFrame();

                    frameCount++;
                }
            }, -10);

            game.Run();
        }