public void addResource(float x, float y) { if (gameWorld.EntityManager.GetAll(typeof(Resource)).Count <= 1000) { Resource res = new Resource(this, x, y); res.LoadContent(gameWorld.GameRef.Content); gameWorld.EntityManager.AddEntity(res); } }
public void removeResource(Resource resource) { resource.Alive = false; gameWorld.EntityManager.RemoveEntity(resource); if (gameWorld.EntityManager.GetAll(typeof(Resource)).Count <= 3) { CreateResourceCluster(5, 150, new Vector2(150, 150)); CreateResourceCluster(5, 150, new Vector2(Game1.ScreenBounds.Width - 150, 150)); CreateResourceCluster(5, 150, new Vector2(150, Game1.ScreenBounds.Height - 150)); CreateResourceCluster(5, 150, new Vector2(Game1.ScreenBounds.Width - 150, Game1.ScreenBounds.Height - 150)); CreateResourceCluster(5, 150, new Vector2((Game1.ScreenBounds.Width - 150) / 2, (Game1.ScreenBounds.Height - 150) / 2)); } }
public void addResource(Resource resource) { if (gameWorld.EntityManager.GetAll(typeof(Resource)).Count <= 1000) { float x = resource.Position.X + Randomiser.nextInt(-25, 25); float y = resource.Position.Y + Randomiser.nextInt(-25, 25); if (!Game1.ScreenBounds.Contains((int)x, (int)y)) { addResource(resource); } else { Resource res = new Resource(this, x, y, resource.Texture); res.LoadContent(gameWorld.GameRef.Content); gameWorld.EntityManager.AddEntity(res); } } }