예제 #1
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            SpriteBatch = new SpriteBatch(GraphicsDevice);

            _myWorld = new World();
            _myObjectManager = new MyGameObjectManager(); // Create the custom game object manager
            _myWorld.AddManager(_myObjectManager); // Add it to the world

            for (int i = 0; i < 5; i++)
            {
                GameObject obj = new GameObject {Id = i};
                _myWorld.Add(obj);
            }

            Output.WriteLine(OddEventCountBefore, _myObjectManager.EventCount, _myObjectManager.OddCount);
            _myWorld.Process();
            Output.WriteLine(OddEventCountAfter, _myObjectManager.EventCount, _myObjectManager.OddCount);
        }
예제 #2
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            SpriteBatch = new SpriteBatch(GraphicsDevice);

            _myWorld = new World();

            GameObject simpleSoldier = new GameObject {Id = 1};
            GameObject armoredSoldier = new GameObject {Id = 2};
            simpleSoldier.Add(new HealthComponent()); // Create and add a component to a game object
            armoredSoldier.Add(new HealthComponent());
            armoredSoldier.Add(new ShieldComponent());

            Output.WriteLine("Component added...");
            Output.WriteLine(GameObjectComponentCount, "SimpleSoldier", simpleSoldier.Count);
            Output.WriteLine(GameObjectComponentCount, "ArmoredSoldier", armoredSoldier.Count);

            _myWorld.Add(simpleSoldier);
            _myWorld.Add(armoredSoldier);
            _myWorld.Process();
        }