public static Entity AddBehavior(Engine engine, Entity entity, ProcessManager processManager) { entity.AddComponent(new ShootingEnemyComponent(CVars.Get <int>("shooting_enemy_projectile_ammo"))); entity.AddComponent(new RotationComponent(CVars.Get <float>("shooting_enemy_rotational_speed"))); float angle = entity.GetComponent <TransformComponent>().Rotation; entity.AddComponent(new MovementComponent(new Vector2((float)Math.Cos(angle), (float)Math.Sin(angle)), CVars.Get <float>("shooting_enemy_speed"))); entity.AddComponent(new EnemyComponent()); entity.AddComponent(new BounceComponent()); entity.AddComponent(new QuadTreeReferenceComponent(new QuadTreeNode(new BoundingRect()))); entity.AddComponent(new CollisionComponent(new PolygonCollisionShape(new Vector2[] { new Vector2(-2, 5), new Vector2(2, 4), new Vector2(4, 0), new Vector2(2, -4), new Vector2(-2, -5) }))); entity.GetComponent <CollisionComponent>().CollisionGroup = Constants.Collision.COLLISION_GROUP_ENEMIES; FireProjectileProcess fpp = new FireProjectileProcess(entity, engine); processManager.Attach(fpp); entity.AddComponent(new ProjectileSpawningProcessComponent(fpp)); return(entity); }
public static Entity Create(Engine engine, Texture2D texture, Vector2 position, ProcessManager processManager, ContentManager conTENt) { Entity entity = engine.CreateEntity(); entity.AddComponent(new TransformComponent(position)); entity.AddComponent(new SpriteComponent(texture, Constants.ObjectBounds.SHOOTING_SHIP_BOUNDS)); entity.AddComponent(new ShootingEnemyComponent(Constants.GamePlay.SHOOTING_ENEMY_PROJECTILE_AMMO)); entity.AddComponent(new RotationComponent(Constants.GamePlay.SHOOTING_ENEMY_ROTATION_SPEED)); entity.AddComponent(new MovementComponent()); entity.AddComponent(new EnemyComponent()); entity.AddComponent(new CollisionComponent(new BoundingRect(0, 0, 17.5f, 35))); FireProjectileProcess fpp = new FireProjectileProcess(entity, engine, conTENt); processManager.Attach(fpp); entity.AddComponent(new ProjectileSpawningProcessComponent(fpp)); return(entity); }