/// LoadContent called once and is the place to load all of your content. protected override void LoadContent() { /// Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); LoadTextures(); // ***************Default Aspect Builder --Subject to change!--*************** AspectBuilder defaultAspectBuilder = new AspectBuilder(); fireGridMaxX = (int)(screenWidth / fire_1.Width); fireGridMaxY = (int)(screenHeight / fire_1.Height); fireGrid = new int[fireGridMaxX, fireGridMaxY]; // initialize fireGrid to fit the users screen dimensions fireGridMaxX -= 1; fireGridMaxY -= 1; // Load world *********************************************************************************** _world = new WorldBuilder() .AddSystem(new Systems.MovementSystem(screenWidth, screenHeight)) .AddSystem(new Systems.RenderSystem(defaultAspectBuilder)) .AddSystem(new Systems.SpawnSystem()) .AddSystem(new Systems.EntityDestructSystem()) .AddSystem(new Systems.FireSpawnSystem(defaultAspectBuilder)) .AddSystem(new Systems.UpdateFrontEndSystem(defaultAspectBuilder)) .AddSystem(new Systems.DamageSystem(5)) .AddSystem(new Systems.AnimationSystem(defaultAspectBuilder)) .AddSystem(new Systems.FireBurnoutSystem(defaultAspectBuilder)) /// Add systems here via ".AddSystem(new [SystemName](Parameters))" .Build(); //load and build village Entity VillageEntity = _world.CreateEntity(); ECSComponents.PositionComponent villageposition = new ECSComponents.PositionComponent((float)1 / 2 * screenWidth, (float)1 / 2 * screenHeight, 0); ECSComponents.StatusComponent villagestatus = new ECSComponents.StatusComponent(false, EntityType.Village); ECSComponents.SpriteComponent villagesprite = new ECSComponents.SpriteComponent(SpriteDict["village"], 1); ECSComponents.CollisionBoxComponet villageHitBox = new ECSComponents.CollisionBoxComponet(villagesprite.Sprite, villageposition); ECSComponents.HealthComponent villageHealth = new ECSComponents.HealthComponent(100); VillageEntity.Attach(villageposition); VillageEntity.Attach(villagestatus); VillageEntity.Attach(villagesprite); VillageEntity.Attach(villageHitBox); VillageEntity.Attach(villageHealth); VillageID = VillageEntity.Id; // *********************************************************************************************** }
/// LoadContent called once and is the place to load all of your content. protected override void LoadContent() { /// Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); map = Content.Load <Texture2D>("map"); village = Content.Load <Texture2D>("Village"); lightning = Content.Load <Texture2D>("lightning"); meteor = Content.Load <Texture2D>("meteor"); fire = Content.Load <Texture2D>("fire"); /// Creates the SpriteTextureComponents so they can be attached to entities SpriteClass lightningSprite = new SpriteClass(GraphicsDevice, "Assets/Lightning.png", 1); // scale of sprites may be adjusted here SpriteClass meteorSprite = new SpriteClass(GraphicsDevice, "Assets/Meteor.png", 1); // scale of sprites may be adjusted here SpriteClass fireSprite = new SpriteClass(GraphicsDevice, "Assets/Fire.png", 1); // scale of sprites may be adjusted here SpriteClass villageSprite = new SpriteClass(GraphicsDevice, "Assets/Village.png", 1); // scale of sprites may be adjusted here SpriteDict.Add("lightning", lightningSprite); SpriteDict.Add("meteor", meteorSprite); SpriteDict.Add("fire", fireSprite); SpriteDict.Add("village", villageSprite); // ***************Default Aspect Builder --Subject to change!--*************** AspectBuilder defaultAspectBuilder = new AspectBuilder(); fireGridMaxX = (int)(screenWidth / fire.Width); fireGridMaxY = (int)(screenHeight / fire.Height); fireGrid = new int[fireGridMaxX, fireGridMaxY]; // initialize fireGrid to fit the users screen dimensions fireGridMaxX -= 1; fireGridMaxY -= 1; // Load world *********************************************************************************** _world = new WorldBuilder() .AddSystem(new Systems.MovementSystem(screenWidth, screenHeight)) .AddSystem(new Systems.RenderSystem(defaultAspectBuilder)) .AddSystem(new Systems.SpawnSystem(90)) .AddSystem(new Systems.EntityDestructSystem()) .AddSystem(new Systems.FireSpawnSystem(defaultAspectBuilder)) .AddSystem(new Systems.UpdateFrontEndSystem(defaultAspectBuilder)) .AddSystem(new Systems.DamageSystem(5)) /// Add systems here via ".AddSystem(new [SystemName](Parameters))" .Build(); //load and build village Entity VillageEntity = _world.CreateEntity(); ECSComponents.PositionComponent villageposition = new ECSComponents.PositionComponent((float)1 / 2 * screenWidth, (float)1 / 2 * screenHeight, 0); ECSComponents.StatusComponent villagestatus = new ECSComponents.StatusComponent(false, EntityType.Village); ECSComponents.SpriteComponent villagesprite = new ECSComponents.SpriteComponent(SpriteDict["village"], 1); ECSComponents.CollisionBoxComponet villageHitBox = new ECSComponents.CollisionBoxComponet(villagesprite.Sprite, villageposition); ECSComponents.HealthComponent villageHealth = new ECSComponents.HealthComponent(100); VillageEntity.Attach(villageposition); VillageEntity.Attach(villagestatus); VillageEntity.Attach(villagesprite); VillageEntity.Attach(villageHitBox); VillageEntity.Attach(villageHealth); VillageID = VillageEntity.Id; // *********************************************************************************************** }