public EntityPool(int maxEntities, Func<Texture2D, Entity> createFunc, Texture2D spriteSheet) { Instance = this; _maxEntities = maxEntities; Entities = new List<Entity>(); for(int i=0;i<maxEntities;i++) Entities.Add(createFunc(spriteSheet)); BoxCollidesWith = new List<object>(); PolyCollidesWith = new List<object>(); }
public EntityPool(int maxEntities, Func <Texture2D, Entity> createFunc, Texture2D spriteSheet) { Instance = this; _maxEntities = maxEntities; Entities = new List <Entity>(); for (int i = 0; i < maxEntities; i++) { Entities.Add(createFunc(spriteSheet)); } BoxCollidesWith = new List <object>(); PolyCollidesWith = new List <object>(); }
public override void LoadContent() { ContentManager content = ScreenManager.Game.Content; //map = content.Load<Map>("map"); // Old XNB loader map = new Map(content, "map"); MapObject spawn = ((MapObjectLayer) map.GetLayer("spawn")).Objects[0]; camera = new Camera(ScreenManager.Game.RenderWidth, ScreenManager.Game.RenderHeight, map); camera.Target = new Vector2(ScreenManager.Game.RenderWidth, ScreenManager.Game.RenderHeight)/2f; heroPool = new EntityPool(100, sheet => new Hero(sheet, new Rectangle(0, 0, 10, 10), new Vector2(0, -5)), content.Load<Texture2D>("testhero")); heroPool.BoxCollidesWith.Add(heroPool); rotBoxPool = new EntityPool(100, sheet => new RotBox(sheet, new Rectangle(0, 0, 32, 32), null, Vector2.Zero), ScreenManager.blankTexture); rotBoxPool.PolyCollidesWith.Add(rotBoxPool); rotBoxPool.Spawn(entity => { entity.Position = new Vector2(100,100); }); rotBoxPool.Spawn(entity => { entity.Position = new Vector2(140, 100); }); particleController.LoadContent(content); // TimerController.Instance.Create("shake", () => camera.Shake(500, 2f), 3000, true); TweenController.Instance.Create("spintext", TweenFuncs.SineEaseInOut, (tween) => { textScale = 0.8f+ (tween.Value *0.4f); }, 3000, true, true); //// More crazy tween examples //TweenController.Instance.Create("spincam", TweenFuncs.Linear, (tween) => //{ // camera.Rotation = MathHelper.TwoPi * tween.Value; //}, 10000, false, true, TweenDirection.Reverse); //TweenController.Instance.Create("zoomcam", TweenFuncs.Bounce, (tween) => //{ // camera.Zoom = 1f + tween.Value; //}, 3000, true, true); particleController.Add(new Vector2(195, 150), Vector2.Zero, 0, 1000, 0, false, false, new Rectangle(18, 0, 100, 100), Color.White, ParticleFunctions.PermaLight, 1f, 0f, 1, ParticleBlend.Multiplicative); base.LoadContent(); }