/// <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(); _firstObject = new GameObject {Id = 1}; // Create a game object and assign an id _secondObject = new GameObject{Id = 2}; Output.WriteLine("Adding game object..."); _myWorld.Add(_firstObject); // Add the game object to the world _myWorld.Add(_secondObject); Output.WriteLine(ObjectInWorldBefore, _myWorld.GameObjectManager.Count); _myWorld.Process(); // Process the pending queue to add definitely the game object to the world Output.WriteLine(ObjectInWorldAfter, _myWorld.GameObjectManager.Count); }
/// <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); }
/// <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(); }