Update() public method

public Update ( ) : void
return void
Beispiel #1
0
        public void ShipHitByProjectileFFA()
        {
            // DO NOT MOVE THIS TEST AT ALL. MAKE TESTS BELOW THIS ONE OR ELSE FAILURE OCCURS. (Because of the global IDs.)
            World tester = new World(750, new List <Star>()
            {
                new Star(new Vector2D(4, 6), 0.01, 25)
            }, 4U, 300U, false);

            tester.AddShip(new Vector2D(100, 100), new Vector2D(1, 0), "meme", tester.GetShotFireDelay(), 0.6, 4.0, 5, 25);
            tester.AddShip(new Vector2D(130, 100), new Vector2D(1, 0), "meme", tester.GetShotFireDelay(), 0.6, 4.0, 5, 25);

            for (int updateIdx = 0; updateIdx < 5; updateIdx++)
            {
                tester.Update();
            }

            tester.ProcessCommand(26, 'F');

            for (int updateIdx = 0; updateIdx < 5; updateIdx++)
            {
                tester.Update();
                tester.Cleanup();
            }

            Assert.IsTrue(tester.GetShips()[27].GetHP() == 4);
        }
Beispiel #2
0
        public void CheckProjectileBoundsY()
        {
            // DO NOT MOVE THIS TEST AT ALL. MAKE TESTS BELOW THIS ONE OR ELSE FAILURE OCCURS. (Because of the global IDs.)
            World tester = new World(750, new List <Star>()
            {
                new Star(new Vector2D(4, 6), 0.01, 25)
            }, 4U, 300U, false);

            tester.AddShip(new Vector2D(0, -370), new Vector2D(0, -1), "meme", tester.GetShotFireDelay(), 0.6, 4.0, 5, 25);
            tester.AddShip(new Vector2D(0, 370), new Vector2D(0, 1), "meme", tester.GetShotFireDelay(), 0.6, 4.0, 5, 25);

            for (int updateIdx = 0; updateIdx < 6; updateIdx++)
            {
                tester.ProcessCommand(71, 'F');
                tester.Update();
                if (updateIdx == 4)
                {
                    Assert.IsTrue(tester.GetProjectiles().Count > 0);
                }
                tester.Cleanup();
            }

            for (int updateIdx = 0; updateIdx < 6; updateIdx++)
            {
                tester.ProcessCommand(72, 'F');
                tester.Update();
                if (updateIdx == 4)
                {
                    Assert.IsTrue(tester.GetProjectiles().Count > 0);
                }
                tester.Cleanup();
            }

            Assert.IsTrue(tester.GetProjectiles().Count == 0);
        }
Beispiel #3
0
        public void TestAddAndRemoveEdge()
        {
            var world = new World();
            var obj   = new Particle {
                Mass = 1, Position = new Vector2D(0, 5), Velocity = new Vector2D(0, 5)
            };

            obj.BindShape(new Circle(2));
            var edgeA = new Edge(-5, 0, 5, 0);
            var edgeB = new Edge(-5, 10, 5, 10);

            world.AddObject(obj);
            world.AddEdge(edgeA);
            world.AddEdge(edgeB);

            world.Update(1);
            Assert.AreEqual(new Vector2D(0, -5), obj.Velocity, "质体会被反弹");

            world.Update(1);
            world.Update(1);
            Assert.AreEqual(new Vector2D(0, 5), obj.Velocity, "质体会被再次反弹");

            world.RemoveEdge(edgeB);
            world.Update(1);
            world.Update(1);
            Assert.AreEqual(new Vector2D(0, 5), obj.Velocity, "移除边缘后质体不会被反弹");
        }
Beispiel #4
0
        protected IEnumerator UpdateModel(float time, bool dynamic = true)
        {
            IsUpdating = dynamic;

            float duration = 0;

            while (duration < time)
            {
                duration += Time.deltaTime;

                if (UpdateTask == null)
                {
                    UpdateTask = Task.Run(() => Model.Update());
                }
                else if (UpdateTask.Status == TaskStatus.RanToCompletion)
                {
                    UpdateTask = Task.Run(() => Model.Update());
                }

                yield return(null);
            }

            UpdateModelRoutine = null;
            IsUpdating         = false;
        }
Beispiel #5
0
        static void Main(string[] args)
        {
            var world = new World();

            CreatePlayer(world);
            BuildRooms(world);
            AddMonsters(world);

            world.AddSystem(0, new ConsoleUI());
            world.Update();


            world.AddSystem(0, new PlayerInput());
            world.AddSystem(1, new Systems.AI());

            world.AddSystem(2, new Movement());
            world.AddSystem(3, new Systems.Life());
            world.AddSystem(0, new Demo());



            while (true)
            {
                world.Update();
            }
        }
Beispiel #6
0
        /// <summary>
        /// A controller method that receives and extracts world information
        /// from the server.
        /// </summary>
        /// <param name="state"></param>
        private void ReceiveWorld(SocketState state)
        {
            for (int i = 0; i < state.DataLength; i++)
            {
                JObject obj        = JObject.Parse(state.Messages[i]);
                JToken  jAttribute = obj["vertices"];

                if (jAttribute != null)
                {
                    lock (this)
                    {
                        // If the received message deserializes to a snake, update the world with a new snake.
                        Snake.Snake snake = JsonConvert.DeserializeObject <Snake.Snake>(state.Messages[i]);
                        if (snake._ID == playerID && snake.Vertices.Last.Value._x == -1 && snake.Vertices.Last.Value._y == -1)
                        {
                            isConnected = false;
                            Invoke(new MethodInvoker(AllowReconnect));
                        }
                        world.Update(snake);
                    }
                }
                else // else update the world with a food object.
                {
                    lock (this)
                    {
                        Food food = JsonConvert.DeserializeObject <Food>(state.Messages[i]);
                        world.Update(food);
                    }
                }
            }
            UpdateFrame();
            BeginInvoke(new MethodInvoker(UpdateScoreboard));
            Network.GetData(state);
        }
        /// <summary>
        /// Updates the state of the game. This method checks the GameScreen.IsActive
        /// property, so the game will stop updating when the pause menu is active,
        /// or if you tab away to a different application.
        /// </summary>
        public override void Update(GameTime gameTime, bool otherScreenHasFocus,
                                    bool coveredByOtherScreen)
        {
            base.Update(gameTime, otherScreenHasFocus, coveredByOtherScreen);

            // if something else has canceled our game, then exit
            if ((networkSession == null) || (world == null))
            {
                if (!IsExiting)
                {
                    ExitScreen();
                }
                base.Update(gameTime, otherScreenHasFocus, coveredByOtherScreen);
                return;
            }

            // update the world
            if (world != null)
            {
                if (otherScreenHasFocus || coveredByOtherScreen)
                {
                    world.Update((float)gameTime.ElapsedGameTime.TotalSeconds, true);
                }
                else if (world.GameExited)
                {
                    if (!IsExiting)
                    {
                        ExitScreen();
                    }
                    networkSession = null;
                    base.Update(gameTime, otherScreenHasFocus, coveredByOtherScreen);
                    return;
                }
                else
                {
                    world.Update((float)gameTime.ElapsedGameTime.TotalSeconds, false);
                    // if the game was just won, then build the winner string
                    if (world.GameWon && String.IsNullOrEmpty(winnerString) &&
                        (world.WinnerIndex >= 0) &&
                        (world.WinnerIndex < networkSession.AllGamers.Count))
                    {
                        winnerString =
                            networkSession.AllGamers[world.WinnerIndex].Gamertag;
                        winnerString +=
                            " has won the game!\nPress A to return to the lobby.";
                        Vector2 winnerStringSize =
                            world.PlayerFont.MeasureString(winnerString);
                        winnerStringPosition = new Vector2(
                            ScreenManager.GraphicsDevice.Viewport.X +
                            ScreenManager.GraphicsDevice.Viewport.Width / 2 -
                            (float)Math.Floor(winnerStringSize.X / 2),
                            ScreenManager.GraphicsDevice.Viewport.Y +
                            ScreenManager.GraphicsDevice.Viewport.Height / 2 -
                            (float)Math.Floor(winnerStringSize.Y / 2));
                    }
                }
            }
        }
Beispiel #8
0
        public void WorldSimulationFixedStep()
        {
            var world = new World("World A");
            var sim   = world.GetOrCreateSystem <SimulationSystemGroup>();
            var uc    = world.GetOrCreateSystem <UpdateCountSystem>();

            sim.AddSystemToUpdateList(uc);

            // Unity.Core.Hybrid.UpdateWorldTimeSystem
            var timeData = new TimeData();

            void AdvanceWorldTime(float amount)
            {
                uc.updateCount = 0;
                timeData       = new TimeData(timeData.ElapsedTime + amount, amount);
                world.SetTime(timeData);
            }

            sim.SetFixedTimeStep(1.0f);
            Assert.IsTrue(sim.FixedTimeStepEnabled);

            // first frame will tick immediately
            AdvanceWorldTime(0.5f);
            world.Update();
            Assert.AreEqual(0.5, uc.lastUpdateTime, 0.001f);
            Assert.AreEqual(1.0, uc.lastUpdateDeltaTime, 0.001f);
            Assert.AreEqual(1, uc.updateCount);

            AdvanceWorldTime(1.1f);
            world.Update();
            Assert.AreEqual(1.5, uc.lastUpdateTime, 0.001f);
            Assert.AreEqual(1.0, uc.lastUpdateDeltaTime, 0.001f);
            Assert.AreEqual(1, uc.updateCount);

            // No update should happen because the time elapsed is less than the interval
            AdvanceWorldTime(0.1f);
            world.Update();
            Assert.AreEqual(1.5, uc.lastUpdateTime, 0.001f);
            Assert.AreEqual(1.0, uc.lastUpdateDeltaTime, 0.001f);
            Assert.AreEqual(0, uc.updateCount);

            AdvanceWorldTime(1.0f);
            world.Update();
            Assert.AreEqual(2.5, uc.lastUpdateTime, 0.001f);
            Assert.AreEqual(1.0, uc.lastUpdateDeltaTime, 0.001f);
            Assert.AreEqual(1, uc.updateCount);

            // If time jumps by a lot, we should tick the fixed rate systems
            // multiple times
            AdvanceWorldTime(2.0f);
            world.Update();
            Assert.AreEqual(4.5, uc.lastUpdateTime, 0.001f);
            Assert.AreEqual(1.0, uc.lastUpdateDeltaTime, 0.001f);
            Assert.AreEqual(2, uc.updateCount);

            world.Dispose();
        }
        public void WorldSimulation_FixedRateUtils_Simple()
        {
            using (var world = new World("World A"))
            {
                var sim = world.GetOrCreateSystem <SimulationSystemGroup>();
                var uc  = world.GetOrCreateSystem <UpdateCountSystem>();
                sim.AddSystemToUpdateList(uc);

                // Unity.Core.Hybrid.UpdateWorldTimeSystem
                var timeData = new TimeData();

                void AdvanceWorldTime(float amount)
                {
                    uc.updateCount = 0;
                    timeData       = new TimeData(timeData.ElapsedTime + amount, amount);
                    world.SetTime(timeData);
                }

                sim.FixedRateManager = new FixedRateUtils.FixedRateSimpleManager(1.0f);

                // first frame will tick at elapsedTime=0
                AdvanceWorldTime(0.5f);
                world.Update();
                Assert.AreEqual(0.0, uc.lastUpdateTime, 0.001f);
                Assert.AreEqual(1.0, uc.lastUpdateDeltaTime, 0.001f);
                Assert.AreEqual(1, uc.updateCount);

                // Advance elapsed time to 1.6 seconds. the second tick should occur at 1.0
                AdvanceWorldTime(1.1f);
                world.Update();
                Assert.AreEqual(1.0, uc.lastUpdateTime, 0.001f);
                Assert.AreEqual(1.0, uc.lastUpdateDeltaTime, 0.001f);
                Assert.AreEqual(1, uc.updateCount);

                // Advance elapsed time to 1.7 seconds. the third tick should occur at 2.0
                AdvanceWorldTime(0.1f);
                world.Update();
                Assert.AreEqual(2.0, uc.lastUpdateTime, 0.001f);
                Assert.AreEqual(1.0, uc.lastUpdateDeltaTime, 0.001f);
                Assert.AreEqual(1, uc.updateCount);

                // Advance elapsed time to 2.7 seconds. The third tick should occur at 3.0
                AdvanceWorldTime(1.0f);
                world.Update();
                Assert.AreEqual(3.0, uc.lastUpdateTime, 0.001f);
                Assert.AreEqual(1.0, uc.lastUpdateDeltaTime, 0.001f);
                Assert.AreEqual(1, uc.updateCount);

                // Advance elapsed time to 4.9 seconds. The fourth tick should occur at 4.0
                AdvanceWorldTime(2.2f);
                world.Update();
                Assert.AreEqual(4.0, uc.lastUpdateTime, 0.001f);
                Assert.AreEqual(1.0, uc.lastUpdateDeltaTime, 0.001f);
                Assert.AreEqual(1, uc.updateCount);
            }
        }
        public void WorldSimulation_FixedRateUtils_CatchUp()
        {
            using (var world = new World("World A"))
            {
                var sim = world.GetOrCreateSystem <SimulationSystemGroup>();
                var uc  = world.GetOrCreateSystem <UpdateCountSystem>();
                sim.AddSystemToUpdateList(uc);

                // Unity.Core.Hybrid.UpdateWorldTimeSystem
                var timeData = new TimeData();

                void AdvanceWorldTime(float amount)
                {
                    uc.updateCount = 0;
                    timeData       = new TimeData(timeData.ElapsedTime + amount, amount);
                    world.SetTime(timeData);
                }

                sim.FixedRateManager = new FixedRateUtils.FixedRateCatchUpManager(0.1f);

                // first frame will tick at elapsedTime=0
                AdvanceWorldTime(0.05f);
                world.Update();
                Assert.AreEqual(0.0, uc.lastUpdateTime, 0.001f);
                Assert.AreEqual(0.1, uc.lastUpdateDeltaTime, 0.001f);
                Assert.AreEqual(1, uc.updateCount);

                // Advance elapsed time to 0.16 seconds. the second tick should occur at 0.1
                AdvanceWorldTime(0.11f);
                world.Update();
                Assert.AreEqual(0.1, uc.lastUpdateTime, 0.001f);
                Assert.AreEqual(0.1, uc.lastUpdateDeltaTime, 0.001f);
                Assert.AreEqual(1, uc.updateCount);

                // Advance elapsed time to 0.17 seconds. No tick should occur.
                AdvanceWorldTime(0.01f);
                world.Update();
                Assert.AreEqual(0.1, uc.lastUpdateTime, 0.001f);
                Assert.AreEqual(0.1, uc.lastUpdateDeltaTime, 0.001f);
                Assert.AreEqual(0, uc.updateCount);

                // Advance elapsed time to 0.27 seconds. The third tick should occur at 0.20
                AdvanceWorldTime(0.1f);
                world.Update();
                Assert.AreEqual(0.2, uc.lastUpdateTime, 0.001f);
                Assert.AreEqual(0.1, uc.lastUpdateDeltaTime, 0.001f);
                Assert.AreEqual(1, uc.updateCount);

                // Advance elapsed time to 0.49 seconds. The fourth and fifth ticks should occur at 0.30 and 0.40.
                AdvanceWorldTime(0.22f);
                world.Update();
                Assert.AreEqual(0.40, uc.lastUpdateTime, 0.001f);
                Assert.AreEqual(0.1, uc.lastUpdateDeltaTime, 0.001f);
                Assert.AreEqual(2, uc.updateCount);
            }
        }
Beispiel #11
0
        public void TestThatTwoCircleShapesAreColliding()
        {
            _world.Setup();

            var position1 = new FixVec2(-1, 0);
            var velocity1 = new FixVec2(1, 0);
            var entity1   = _context.CreateEntity()
                            .Add(new Position(position1))
                            .Add(new Velocity(velocity1))
                            .Add(CreateSimpleCircleBoundingShapes())
                            .Add(new Collisions(ListPool <Collision> .Instance.Get()));

            var position2 = new FixVec2(1, 0);
            var velocity2 = new FixVec2(-1, 0);
            var entity2   = _context.CreateEntity()
                            .Add(new Position(position2))
                            .Add(new Velocity(velocity2))
                            .Add(CreateSimpleCircleBoundingShapes())
                            .Add(new Collisions(ListPool <Collision> .Instance.Get()));


            var distToGo = Fix.Ratio(50, 100);
            var time     = distToGo / PhysicsLimits.Velocity;

            while (time > 0)
            {
                _world.Cleanup();
                _world.Update();
                time -= TimeStep;
            }

            var shapes1     = entity1.Get <BoundingShapes>().Shapes;
            var shapes2     = entity2.Get <BoundingShapes>().Shapes;
            var collisions1 = entity1.Get <Collisions>().List;
            var collisions2 = entity2.Get <Collisions>().List;

            Assert.AreEqual(1, collisions1.Count);
            Assert.AreEqual(1, collisions2.Count);

            var collision1 = collisions1[0];
            var collision2 = collisions2[0];

            Assert.AreEqual(shapes1.First, collision1.SelfShape);
            Assert.AreEqual(shapes2.First, collision1.OtherShape);
            Assert.AreEqual(entity2.Id, collision1.Other.Id);

            Assert.AreEqual(shapes2.First, collision2.SelfShape);
            Assert.AreEqual(shapes1.First, collision2.OtherShape);
            Assert.AreEqual(entity1.Id, collision2.Other.Id);
        }
Beispiel #12
0
        /// <summary>
        /// Starts the simulation
        /// </summary>
        public async void Start()
        {
            //Check world
            if (World == null)
            {
                throw new ArgumentException("World is not loaded!");
            }

            if (World.Fields == null)
            {
                throw new ArgumentException("World is not generated!");
            }

            //If everything is ok, we enter the loop
            Running             = true;
            simulationStopwatch = Stopwatch.StartNew();
            while (Running)
            {
                var timeElapsed = simulationStopwatch.ElapsedMilliseconds;
                simulationStopwatch.Restart();
                lock (World)
                {
                    Weather.DoWeatherStep();
                    World.Update((double)timeElapsed / Delay);
                }
                await Task.Delay((int)Math.Max(Delay - timeElapsed, 0)); //The delay is lowered if the simulation rate lags behind
            }
        }
Beispiel #13
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                Exit();
            }

            var         keyboardState = Keyboard.GetState();
            const float movementSpeed = 300;

            if (keyboardState.IsKeyDown(Keys.Up))
            {
                _camera.Move(new Vector2(0, -movementSpeed) * (float)gameTime.ElapsedGameTime.TotalSeconds);
            }

            if (keyboardState.IsKeyDown(Keys.Down))
            {
                _camera.Move(new Vector2(0, +movementSpeed) * (float)gameTime.ElapsedGameTime.TotalSeconds);
            }

            if (keyboardState.IsKeyDown(Keys.Left))
            {
                _camera.Move(new Vector2(-movementSpeed, 0) * (float)gameTime.ElapsedGameTime.TotalSeconds);
            }

            if (keyboardState.IsKeyDown(Keys.Right))
            {
                _camera.Move(new Vector2(+movementSpeed, 0) * (float)gameTime.ElapsedGameTime.TotalSeconds);
            }

            _world.Update(gameTime);

            base.Update(gameTime);
        }
Beispiel #14
0
        public void ShotgunTest()
        {
            using (var resource = CommonResource.CreateDummy(WadPath.Doom2, @"data\shotgun_test.wad"))
            {
                var demo    = new Demo(@"data\shotgun_test.lmp");
                var players = DoomTest.GetDefaultPlayers();
                var cmds    = players.Select(player => player.Cmd).ToArray();
                var world   = new World(resource, demo.Options, players);

                var lastHash = 0;
                var aggHash  = 0;

                while (true)
                {
                    if (!demo.ReadCmd(cmds))
                    {
                        break;
                    }

                    world.Update();
                    lastHash = DoomDebug.GetMobjHash(world);
                    aggHash  = DoomDebug.CombineHash(aggHash, lastHash);
                }

                Assert.AreEqual(0x3dd50799u, (uint)lastHash);
                Assert.AreEqual(0x4ddd814fu, (uint)aggHash);
            }
        }
Beispiel #15
0
        protected override void Update(GameTime gameTime)
        {
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                Exit();
            }

            // TODO: Add your update logic here

            KeyboardState keyState = Keyboard.GetState();

            if (keyState.IsKeyDown(Keys.W) || keyState.IsKeyDown(Keys.Up))
            {
                world.hero.UpdatePosRelative(0, -5);
            }
            else if (keyState.IsKeyDown(Keys.A) || keyState.IsKeyDown(Keys.Left))
            {
                world.hero.UpdatePosRelative(-5, 0);
            }
            else if (keyState.IsKeyDown(Keys.S) || keyState.IsKeyDown(Keys.Down))
            {
                world.hero.UpdatePosRelative(0, 5);
            }
            else if (keyState.IsKeyDown(Keys.D) || keyState.IsKeyDown(Keys.Right))
            {
                world.hero.UpdatePosRelative(5, 0);
            }

            world.Update();

            base.Update(gameTime);
        }
        public override void Update(GameTime gameTime)
        {
            world.Update(gameTime);
            player.Update(gameTime);
            player.Camera.LockToSprite(player.Sprite);

            if (InputHandler.KeyReleased(Keys.Space) ||
                InputHandler.ButtonReleased(Buttons.A, PlayerIndex.One))
            {
                foreach (Character c in World.Levels[World.CurrentLevel].Characters)
                {
                    float distance = Vector2.Distance(player.Sprite.Center, c.Sprite.Center);

                    if (distance < Character.SpeakingRadius && c is NonPlayerCharacter)
                    {
                        NonPlayerCharacter npc = (NonPlayerCharacter)c;

                        if (npc.HasConversation)
                        {
                            StateManager.PushState(GameRef.ConversationScreen);
                            GameRef.ConversationScreen.SetConversation(player, npc, npc.CurrentConversation);
                            GameRef.ConversationScreen.StartConversation();
                        }
                    }
                }
            }

            base.Update(gameTime);
        }
Beispiel #17
0
        public bool Update()
        {
#if UNITY_DOTSPLAYER
            UnsafeUtility.FreeTempMemory();
#endif

            var shouldContinue = true;


            if (m_BootPhase == BootPhase.Running)
            {
                m_World.Update();
                shouldContinue = !m_World.QuitUpdate;
            }
            else
            {
                if (m_BootPhase == BootPhase.Booting)
                {
                    UpdateBooting();
                }
                else if (m_BootPhase == BootPhase.LoadingConfig)
                {
                    UpdateLoadingConfig();
                }
                else
                {
                    throw new Exception("Invalid BootPhase specified");
                }
            }

            return(shouldContinue);
        }
Beispiel #18
0
    public void SimpleHybridComponent()
    {
        TestUtilities.RegisterSystems(World, TestUtilities.SystemCategories.Streaming | TestUtilities.SystemCategories.HybridComponents);

        var loadParams = new SceneSystem.LoadParameters
        {
            Flags = SceneLoadFlags.BlockOnImport | SceneLoadFlags.BlockOnStreamIn
        };

        var sceneGUID = new GUID(AssetDatabase.AssetPathToGUID("Assets/StressTests/HybridLights/HybridLights/SubScene.unity"));

        World.GetExistingSystem <SceneSystem>().LoadSceneAsync(sceneGUID, loadParams);
        World.Update();


        var entity    = EmptySystem.GetSingletonEntity <Light>();
        var companion = m_Manager.GetComponentObject <Light>(entity).gameObject;

        void MoveAndCheck(float3 testpos)
        {
            m_Manager.SetComponentData(entity, new LocalToWorld {
                Value = float4x4.Translate(testpos)
            });
            World.Update();
            Assert.AreEqual(testpos, (float3)companion.transform.position);
        }

        MoveAndCheck(new float3(1, 2, 3));
        MoveAndCheck(new float3(2, 3, 4));
    }
        public void WorldTime_UnityEngineDeltaTimeDrivesTime()
        {
            using (var world = new World("World A"))
            {
                var init = world.GetOrCreateSystem <InitializationSystemGroup>();

                var unityTimeSys = world.GetOrCreateSystem(typeof(UpdateWorldTimeSystem));
                init.AddSystemToUpdateList(unityTimeSys);

                float  lastDeltaTime       = math.min(UnityEngine.Time.deltaTime, world.MaximumDeltaTime);
                double expectedElapsedTime = 0;

                // Ideally this should be a playmode test that we run for several frames, so that UnityEngine.Time.deltaTime
                // would vary for each update. For now we'll just pretend the deltaTime is the same for each frame.
                for (int i = 0; i < 10; ++i)
                {
                    world.Update();
                    Assert.AreEqual(expectedElapsedTime, world.Time.ElapsedTime);
                    float newDeltaTime = math.min(UnityEngine.Time.deltaTime, world.MaximumDeltaTime);
                    Assert.AreEqual(newDeltaTime, world.Time.DeltaTime);
                    lastDeltaTime        = newDeltaTime;
                    expectedElapsedTime += lastDeltaTime;
                }
            }
        }
Beispiel #20
0
        protected override void Update(GameTime gameTime)
        {
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                Exit();
            }

            Global.gameTime = gameTime;
            Global.keyboard.Update();
            Global.mouseControl.Update();

            if (Global.keyboard.GetPress("Insert"))
            {
                Global.debugging = true;
            }
            if (Global.keyboard.GetPress("Home"))
            {
                Global.debugging = false;
            }

            Resolution.Update(this, Global.graphics);

            world.Update();

            Global.console.Update();
            Global.keyboard.UpdateOld();
            Global.mouseControl.UpdateOld();


            base.Update(gameTime);
        }
Beispiel #21
0
        /* The Update() function handles everything that needs doing every frame in the WorldScreen. */
        public override void Update(GameTime gameTime)
        {
            /* The Player and World are both updated. These handle camera and sprite movement as well as updating the current Level object. */
            player.Update(gameTime);
            world.Update(gameTime);

            /* If the player releases the "I" key, or the start button on a gamepad, the InventoryScreen is pushed on to the state stack.
             * UpdateNames() is also called so that the list of Pokemon in the InventoryScreen matches the player's Pokemon. */
            if (InputHandler.KeyReleased(Keys.I) || InputHandler.ButtonReleased(Buttons.Start, PlayerIndex.One))
            {
                GameRef.InventoryScreen.UpdateNames();
                Change(ChangeType.Push, GameRef.InventoryScreen);
            }

            base.Update(gameTime);

            /* If the Player's StepCheck bit is true, this means the player has just completed a step.
             * Any actions that take place after taking a step, such as checking for wild Pokemon or a warp tile, need to happen.
             * StepCheck is then set to false again so it doesn't do everything again next frame. */
            if (Player.StepCheck)
            {
                Player.StepCheck = false;
                CheckSpawn();
                CheckWarp();
            }
        }
Beispiel #22
0
        protected override void OnUpdate(GameTime gameTime)
        {
            MiniMap.PlayerLocation = World.Player.KnownPosition;

            var args = new UpdateArgs()
            {
                Camera = World.Camera, GraphicsDevice = Graphics, GameTime = gameTime
            };

            _playingHud.CheckInput = Alex.GuiManager.ActiveDialog == null;

            //	if (Alex.IsActive)

            if (Math.Abs(AspectRatio - Graphics.Viewport.AspectRatio) > 0f)
            {
                World.Camera.UpdateAspectRatio(Graphics.Viewport.AspectRatio);
                AspectRatio = Graphics.Viewport.AspectRatio;
            }

            if (!_playingHud.Chat.Focused && Alex.GameStateManager.GetActiveState() is PlayingState)
            {
                World.Player.Controller.CheckMovementInput = Alex.IsActive && Alex.GuiManager.ActiveDialog == null;
                World.Player.Controller.CheckInput         = Alex.IsActive;

                if (Alex.GuiManager.ActiveDialog == null)
                {
                    CheckInput(gameTime);
                }
            }
            else
            {
                World.Player.Controller.CheckInput = false;
            }

            World.Update(args);

            var now = DateTime.UtcNow;

            if (now - _previousMemUpdate > TimeSpan.FromSeconds(5))
            {
                _previousMemUpdate = now;


                _ramUsage = Environment.WorkingSet;

                ThreadPool.GetMaxThreads(out int maxThreads, out _);
                ThreadPool.GetAvailableThreads(out int availableThreads, out _);
                _threadsUsed = maxThreads - availableThreads;

                _maxThreads = maxThreads;

                var pos     = World.Player.KnownPosition.GetCoordinates3D();
                var biomeId = World.GetBiome(pos.X, pos.Y, pos.Z);
                var biome   = BiomeUtils.GetBiomeById(biomeId);
                _currentBiomeId = biomeId;
                _currentBiome   = biome;
            }

            base.OnUpdate(gameTime);
        }
Beispiel #23
0
        private void TestAddObject(World world, PhysicsObject obj)
        {
            world.AddObject(obj);
            world.Update(1);

            Assert.AreEqual(new Vector2D(5, 9.8), obj.Acceleration, "作用力应被正确地施加到了物体上");
        }
Beispiel #24
0
        public override void MakeDecision(World world)
        {
            double[] input = new double[]
            {
                world.IsClearAhead() ? 0 : 1,
                     world.IsClearAheadAhead() ? 0 : 1,
                     world.IsClearLeft() ? 0 : 1,
                     world.IsClearLeftThenAhead() ? 0 : 1,
                     world.IsClearRight() ? 0 : 1,
                     world.IsClearRightThenAhead() ? 0 : 1,
                     world.IsFoodStraightAhead() ? 0 : 1,
                     world.IsFoodToTheLeft() ? 0 : 1,
                     world.IsFoodToTheRight() ? 0 : 1,
                     world.IsBonusStraightAhead() ? 0 : 1,
                     world.IsBonusToTheLeft() ? 0 : 1,
                     world.IsBonusToTheRight() ? 0 : 1,
                //world.Snake.Tail.Count > 10 ? 0 : 1,
                ((double)world.Snake.Direction) / 4
            };

            if (isLearning)
            {
                //Network.Mutate();
            }

            double[] output = Network.FeedForward(input);

            Decision finalDecision = ConvertOutputToDecision(output);

            ApplyDecision(world, finalDecision);
            world.Update();
        }
Beispiel #25
0
        public override void Update(GameTime gameTime)
        {
            world.Update(gameTime);
            player.Update(gameTime);

            base.Update(gameTime);
        }
Beispiel #26
0
        void Update()
        {
            CameraManager.Update();

            player?.ApplyPlayerCameraInput();
            world?.Update();
        }
Beispiel #27
0
        private void btnTask100_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                Task task = Task.Run(() =>
                {
                    World world = new World(false);
                    world.UnPause();

                    for (int cntr = 0; cntr < 100; cntr++)
                    {
                        Thread.Sleep(50);
                        world.Update();
                    }

                    world.Pause();          // pause really isn't necessary, since there isn't a timer to stop
                    world.Dispose();
                });

                task.ContinueWith(t =>
                {
                    MessageBox.Show("Finished", this.Title, MessageBoxButton.OK, MessageBoxImage.Information);
                }, TaskScheduler.FromCurrentSynchronizationContext());
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), this.Title, MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
        public void WorldTime_MaximumDeltaTime_ClampsDeltaTime()
        {
            // Sometimes, the engine reports a deltaTime of 0 while running this test, and we can't possibly
            // clamp that. Ideally we'd be able to substitute in an arbitrary deltaTime from the engine;
            // Instead, we just skip the test if the engine's reported deltaTime would be too small to clamp.
            const float kMaxDeltaTime = 1.0f / 256.0f;

            if (UnityEngine.Time.deltaTime <= kMaxDeltaTime)
            {
                return;
            }
            using (var world = new World("World A"))
            {
                var init = world.GetOrCreateSystem <InitializationSystemGroup>();

                var unityTimeSys = world.GetOrCreateSystem(typeof(UpdateWorldTimeSystem));
                init.AddSystemToUpdateList(unityTimeSys);

                // Ideally this should be a playmode test that we run for several frames, so that UnityEngine.Time.deltaTime
                // would vary for each update. For now we'll just pretend the deltaTime is the same for each frame.
                world.MaximumDeltaTime = kMaxDeltaTime;
                Assert.Greater(UnityEngine.Time.deltaTime, world.MaximumDeltaTime); // max delta time *must* affect this test
                double expectedElapsedTime = 0;

                for (int i = 0; i < 10; ++i)
                {
                    world.Update();
                    Assert.AreEqual(expectedElapsedTime, world.Time.ElapsedTime);
                    Assert.AreEqual(world.MaximumDeltaTime, world.Time.DeltaTime);
                    expectedElapsedTime += world.Time.DeltaTime;
                }
            }
        }
Beispiel #29
0
        public void Update(GameTime deltaTime)
        {
            World.Update();
            for (int i = 0; i < World.Systems.Count; i++)
            {
                var preUpdateTicks = DateTime.UtcNow.Ticks;
                var system         = World.Systems[i];

                if (!system.WantsUpdate)
                {
                    continue;
                }
                if (system.IsActive)
                {
                    if (Global.Verbose)
                    {
                        FConsole.WriteLine("Update Starting for " + system.Name);
                    }

                    system.Update((float)deltaTime.ElapsedGameTime.TotalSeconds);

                    if (Global.Verbose)
                    {
                        FConsole.WriteLine("Done " + system.Name);
                    }
                }
                var postUpdateTicks = DateTime.UtcNow.Ticks;
                Profiler.AddUpdate(system.Name, (postUpdateTicks - preUpdateTicks) / 10000f);
            }
        }
Beispiel #30
0
        private void Test <TTweenCommand, TTweenInfo, TTarget, TTweenInfoValue>(Entity entity, TTweenInfoValue start, TTweenInfoValue end, float duration)
            where TTweenCommand : struct, IComponentData, ITweenParams, ITweenInfo <TTweenInfoValue>
            where TTweenInfo : struct, IComponentData, ITweenId, ITweenInfo <TTweenInfoValue>
            where TTarget : struct, IComponentData
            where TTweenInfoValue : struct
        {
            Assert.IsTrue(EntityManager.HasComponent <TTweenCommand>(entity));

            World.Update();
            World.Update();

            Assert.IsFalse(EntityManager.HasComponent <TTweenCommand>(entity));
            Assert.IsTrue(EntityManager.HasComponent <TTweenInfo>(entity));
            Assert.IsTrue(EntityManager.HasComponent <TTarget>(entity));
            Assert.IsTrue(EntityManager.HasComponent <TweenState>(entity));

            TweenState tween = GetSingletonTweenState(entity);

            Assert.AreEqual(duration, tween.Duration);

            TTweenInfo info = EntityManager.GetComponentData <TTweenInfo>(entity);

            Assert.AreEqual(start, info.GetTweenStart());
            Assert.AreEqual(end, info.GetTweenEnd());
        }
Beispiel #31
0
        public static void Main(string[] args)
        {
            var g2d = DD.Graphics2D.GetInstance ();
            g2d.CreateWindow (800, 600, "こんにちは、世界");

            // ----------------------------------------

            var wld = new World ();

            var node1 = MySender.Create ("Recver1", new Vector3 (100, 250, 0));
            var node2 = MyRecver.Create ("Recver1", new Vector3 (600, 150, 0));
            var node3 = MyRecver.Create ("Recver2", new Vector3 (600, 250, 0));
            var node4 = MyRecver.Create ("Recver3", new Vector3 (600, 350, 0));
            var node5 = MyRecver.Create ("All", new Vector3 (600, 500, 0));
            var node6 = MyButton.Create ("1", "Recver1", new Vector3 (50, 350, 0));
            var node7 = MyButton.Create ("2", "Recver2", new Vector3 (100, 350, 0));
            var node8 = MyButton.Create ("3", "Recver3", new Vector3 (150, 350, 0));
            var node9 = MyButton.Create ("All", "All", new Vector3 (200, 350, 0));

            wld.AddChild (node1);
            wld.AddChild (node2);
            wld.AddChild (node3);
            wld.AddChild (node4);
            wld.AddChild (node5);
            wld.AddChild (node6);
            wld.AddChild (node7);
            wld.AddChild (node8);
            wld.AddChild (node9);

            // ----------------------------------------
            var active = true;

            g2d.OnClosed += delegate (object sender, EventArgs eventArgs) {
                active = false;
            };

            Console.WriteLine ("Start of Main Loop");

            g2d.SetFrameRateLimit (60);

            var watch = new Stopwatch ();
            watch.Start ();

            while (active) {
                var msec = watch.ElapsedMilliseconds;

                g2d.Dispatch (wld);
                wld.Animate (msec, 33);
                wld.CollisionUpdate ();
                wld.Update (msec);
                wld.Deliver ();
                g2d.Draw (wld);
            }

            Console.WriteLine ("End of Game");
        }
Beispiel #32
0
        public void Test_ClearRecords()
        {
            var node = new Node ("Node");
            var mbox = new MailBox ("Address");
            node.Attach (mbox);

            var wld = new World ();
            wld.AddChild (node);

            wld.Update (16);
            wld.PostOffice.Post (node, "Address", "Hello World");
            wld.Update (33);
            wld.PostOffice.Deliver ();

            var po = wld.PostOffice;
            Assert.AreEqual (1, po.DeliveryRecordCount);

            po.ClearRecords ();
            Assert.AreEqual (0, po.DeliveryRecordCount);
        }
Beispiel #33
0
        public static void Main(string[] args)
        {
            var g2d = DD.Graphics2D.GetInstance ();
            g2d.CreateWindow (800, 600, "こんにちは、世界");

            // ----------------------------------------

            var wld = new World ();

            var node1 = MyCharacter.Create (new Vector3 (200, 200, 0), 16);    // GroupID = 1<<4
            var node2 = MyBlock.Create (new Vector3 (100, 300, 0), -1);        // CollideWith = All
            var node3 = MyBlock.Create (new Vector3 (300, 300, 0), 16);        // CollideWith = 1<<4
            var node4 = MyBlock.Create (new Vector3 (500, 300, 0), 0);         // CollideWith = None
            var node5 = MyHUD.Create (new Vector3 (10, 10, 0));
            wld.AddChild (node1);
            wld.AddChild (node2);
            wld.AddChild (node3);
            wld.AddChild (node4);
            wld.AddChild (node5);

            // ----------------------------------------
            var active = true;

            g2d.OnClosed += delegate (object sender, EventArgs eventArgs) {
                active = false;
            };

            Console.WriteLine ("Start of Main Loop");

            g2d.SetFrameRateLimit (60);

            var watch = new Stopwatch ();
            watch.Start ();

            while (active) {
                var msec = watch.ElapsedMilliseconds;

                g2d.Dispatch (wld);
                wld.Animate (msec, 33);
                wld.Deliver ();
                wld.CollisionUpdate ();
                wld.Update (msec);
                g2d.Draw (wld);
            }

            wld.Destroy ();
            Console.WriteLine ("End of Game");
        }
Beispiel #34
0
        public static void Main(string[] args)
        {
            var g2d = DD.Graphics2D.GetInstance ();
            g2d.CreateWindow (800, 600, "こんにちは、世界");

            Resource.SetTextureDirectory ("DatabaseSample/Textures/");

            // ----------------------------------------
            var node1 = MyCharacterHolder.Create ();
            var node2 = MyCharacterViewer.Create (new Vector3 (0, 0, 0));
            var node3 = MyCharacterSelector.Create (new Vector3 (0,0,0));

            var wld = new World ();
            wld.AddChild (node1);
            wld.AddChild (node2);
            wld.AddChild (node3);

            // ----------------------------------------
            var active = true;

            g2d.OnClosed += delegate (object sender, EventArgs eventArgs) {
                active = false;
            };

            Console.WriteLine ("Start of Main Loop");

            g2d.SetFrameRateLimit (60);

            var watch = new Stopwatch ();
            watch.Start ();

            while (active) {
                var msec = watch.ElapsedMilliseconds;

                g2d.Dispatch (wld);
                wld.Animate (msec, 33);
                wld.Deliver ();
                wld.CollisionUpdate ();
                wld.Update (msec);
                wld.Purge ();
                g2d.Draw (wld);
            }

            Console.WriteLine ("End of Game");
            wld.Destroy ();
        }
Beispiel #35
0
        public static void Main(string[] args)
        {
            var g2d = DD.Graphics2D.GetInstance ();
            g2d.CreateWindow (800, 600, "こんにちは、世界");

            // ----------------------------------------

            var wld = new World ();

            var node1 = MyComponent.Create (new Vector3(100,100,0));
            wld.AddChild (node1);

            // ----------------------------------------
            var active = true;

            g2d.OnClosed += delegate (object sender, EventArgs eventArgs) {
                active = false;
            };

            Console.WriteLine ("Start of Main Loop");

            g2d.SetFrameRateLimit (60);

            var watch = new Stopwatch ();
            watch.Start ();

            while (active) {
                var msec = watch.ElapsedMilliseconds;

                g2d.Dispatch (wld);
                wld.Animate (msec, 16);
                wld.CollisionUpdate ();
                wld.Update (msec);
                g2d.Draw (wld);
            }

            Console.WriteLine ("End of Game");
            wld.Destroy ();
        }
Beispiel #36
0
        public void Test_Destroy_and_Purge()
        {
            var node1 = new Node ("DeadSoul(PurgeTime=1)");  // パージされる
            var node2 = new Node ("DeadSoul(PurgeTime=2)");  // パージされない

            var wld = new World ();
            wld.AddChild (node1);
            wld.AddChild (node2);

            // 遅延ファイナライズ
            node1.Destroy (1);
            node2.Destroy (2);

            // そしてパージ (time=1まで)
            wld.Update (1);
            wld.Purge ();

            Assert.AreEqual (true, node1.IsDestroyed);
            Assert.AreEqual (true, node2.IsDestroyed);
            Assert.AreEqual (true, node1.IsFinalized);
            Assert.AreEqual (false, node2.IsFinalized);
            Assert.AreEqual (1, wld.NodeDestroyer.ReservationCount);
            Assert.AreEqual (1, wld.ChildCount);
        }
Beispiel #37
0
        public void Test_Find_by_Predicate()
        {
            var node1 = new Node ("Node1");
            var node2 = new Node ("Node2");
            var node3 = new Node ("Node3");
            var node4 = new Node ("Node4");
            node1.AddChild (node2);
            node1.AddChild (node3);

            var wld = new World ();
            wld.AddChild (node1);

            Assert.AreEqual (node1, wld.Find (x => x.Name == "Node1"));
            Assert.AreEqual (node2, wld.Find (x => x.Name == "Node2"));
            Assert.AreEqual (node3, wld.Find (x => x.Name == "Node3"));
            Assert.AreEqual (null, wld.Find (x => x.Name == "Node4"));

            // Update()を呼ぶまで更新されない
            wld.AddChild (node4);
            Assert.AreEqual (null, wld.Find (x => x.Name == "Node4"));

            wld.Update (0);
            Assert.AreEqual (node4, wld.Find (x => x.Name == "Node4"));
        }
Beispiel #38
0
        public void Test_Finds_by_Predicate()
        {
            var node1 = new Node ("Node1");
            var node2 = new Node ("Node2");
            var node3 = new Node ("Node3");
            var node4 = new Node ("Node1");
            var node5 = new Node ("Node1");
            var node6 = new Node ("Node6");
            node1.AddChild (node2);
            node1.AddChild (node3);
            node2.AddChild (node4);
            node3.AddChild (node5);

            var wld = new World ();
            wld.AddChild (node1);

            Assert.AreEqual (3, wld.Finds (x => x.Name == "Node1").Count());
            Assert.AreEqual (1, wld.Finds (x => x.Name == "Node2").Count ());
            Assert.AreEqual (1, wld.Finds (x => x.Name == "Node3").Count ());
            Assert.AreEqual (0, wld.Finds (x => x.Name == "Node4").Count ());

            // Update()を呼ぶまで更新されない
            wld.AddChild (node6);
            Assert.AreEqual (0, wld.Finds (x => x.Name == "Node6").Count ());

            wld.Update (0);
            Assert.AreEqual (1, wld.Finds (x => x.Name == "Node6").Count ());
        }
Beispiel #39
0
        public void Test_Downloads()
        {
            var node1 = new Node ("Node1");
            var node2 = new Node ("Node2");
            var node3 = new Node ("Node3");
            var node4 = new Node ("Node4");

            var wld = new World ();

            wld.AddChild (node1);
            wld.AddChild (node2);
            wld.AddChild (node3);
            Assert.AreEqual (4, wld.Downwards.Count ());

            // Update()するまでは反映されない
            wld.AddChild (node4);
            Assert.AreEqual (4, wld.Downwards.Count ());

            wld.Update (0);
            Assert.AreEqual (5, wld.Downwards.Count ());
        }
Beispiel #40
0
        public void Test_DeliveryRecord()
        {
            var node = new Node ("Node");
            var mbox = new MailBox ("Address");
            node.Attach (mbox);

            var wld = new World ();
            wld.AddChild (node);

            wld.Update (16);
            wld.PostOffice.Post (node, "Address", "Hello World");
            wld.Update (33);
            wld.PostOffice.Deliver ();

            var po = wld.PostOffice;

            Assert.AreEqual (1, po.DeliveryRecordCount);
            Assert.AreEqual (1, po.DeliveryRecords.Count());

            var rec = po.DeliveryRecords.ElementAt (0);

            Assert.AreEqual (33, rec.Time);
            Assert.AreEqual ("Node", rec.From);
            Assert.AreEqual ("Address", rec.Address);
            Assert.AreEqual ("Hello World", rec.LetterType);
        }
Beispiel #41
0
        public static void Main(string[] args)
        {
            var g2d = DD.Graphics2D.GetInstance ();
            g2d.CreateWindow (800, 728, "こんにちは、世界");

            Thread.Sleep (1000);

            // ----------------------------------------

            var wld = new World ();

            var node1 = MyCamera.Create (new Vector3(-100, 1300, 0));
            var node2 = MyBackground.Create ();
            var node3 = MyTank.CreateFriend ("T-34", new Vector3 (200, 1600, 0), Quaternion.Identity);
            var node4 = MyTank.CreateFriend ("PanzerIV", new Vector3 (400, 1600, 0), Quaternion.Identity);
            var node5 = MyTank.CreateFriend ("Panther", new Vector3 (600, 1600, 0), Quaternion.Identity);
            var node6 = MyTank.CreateEnemy ("Hotchkiss", new Vector3 (100, 1200, 0), new Quaternion(180, 0,0,1));
            var node7 = MyCharacter.Create ("Ako");
            var node8 = MyCharacter.Create ("Bko");
            var node9 = MyCharacter.Create ("Cko");
            var node10 = MyCard.Create (0, node7, node3);
            var node11 = MyCard.Create (1, node8, node4);
            var node12 = MyCard.Create (2, node9, node5);
            var node13 = MyRader.Create (new Vector3(800 - 128 - 16, 16, 0));
            var node14 = MyMouseSelector.Create ();
            var node15 = MyBGM.Create ();
            var node16 = MyGameClear.Create ();

            // Tank --> MyCharacter
            node3.GetComponent<MyTank> ().MyCharacter = node7;
            node4.GetComponent<MyTank> ().MyCharacter = node8;
            node5.GetComponent<MyTank> ().MyCharacter = node9;

            var rnd = new Random ();
            for (var i = 0; i < 10; i++) {
                var pos = new Vector3 (100 + rnd.Next (600), 1000 - rnd.Next (2000), 0);
                var rot = new Quaternion (180, 0, 0, 1);
                wld.AddChild(MyTank.CreateEnemy ("Hotchkiss", pos, rot));
            }

            wld.AddChild (node1);
            wld.AddChild (node2);
            wld.AddChild (node3);
            wld.AddChild (node4);
            wld.AddChild (node5);
            wld.AddChild (node6);
            wld.AddChild (node7);
            wld.AddChild (node8);
            wld.AddChild (node9);
            node1.AddChild (node10);
            node1.AddChild (node11);
            node1.AddChild (node12);
            node1.AddChild (node13);
            node1.AddChild (node16);
            wld.AddChild (node14);
            wld.AddChild (node15);
            wld.ActiveCamera = node1;

            // ----------------------------------------
            var active = true;

            g2d.OnClosed += delegate (object sender, EventArgs eventArgs) {
                active = false;
            };

            Console.WriteLine ("Start of Main Loop");

            g2d.SetFrameRateLimit (60);

            var watch = new Stopwatch ();
            watch.Start ();

            while (active) {
                var msec = watch.ElapsedMilliseconds;

                wld.Animate (msec, 33);
                g2d.Dispatch (wld);
                wld.Update (msec);
                g2d.Draw (wld);
            }

            Console.WriteLine ("End of Game");
        }
Beispiel #42
0
        public void Test_UpdateInit()
        {
            var wld = new World ();
            var nod = new Node ();
            wld.AddChild (nod);

            var cmp1 = new MyComponent ();
            var cmp2 = new MyComponent ();
            wld.Attach (cmp1);
            nod.Attach (cmp2);

            wld.Update (0);
            Assert.AreEqual (1, cmp1.OnUpdateInited);
            Assert.AreEqual (1, cmp2.OnUpdateInited);

            wld.Update (0);
            Assert.AreEqual (1, cmp1.OnUpdateInited);
            Assert.AreEqual (1, cmp2.OnUpdateInited);
        }