public Projectile CreateProjectile(ProjectileType projectileType, int?index) { if (this.Delegate == null) { throw new Exception("No Delegate"); } Projectile projectile = null; switch (projectileType) { case ProjectileType.Cannonball: projectile = TrailBallProjectile.Create(this.cannonball, index, this.Delegate.GameDefinitions); break; // Add other projectile types here as needed case ProjectileType.Chicken: projectile = ChickenProjectile.Create(this.chicken, index, this.Delegate.GameDefinitions); break; default: throw new Exception("Trying to get .none projectile"); } projectile.AddComponent(new RemoveWhenFallenComponent()); return(projectile); }
private void SetProjectileOnCatapult(Catapult catapult, ProjectileType projectileType) { if (this.Delegate == null) { throw new Exception("No delegate"); } var projectile = TrailBallProjectile.Create(this.dummyBall.Clone()); projectile.IsAlive = true; projectile.Team = catapult.Team; if (projectile.PhysicsNode == null) { throw new Exception("Projectile has no physicsNode"); } projectile.PhysicsNode.PhysicsBody = null; this.Delegate.AddNodeToLevel(projectile.PhysicsNode); catapult.SetProjectileType(projectileType, projectile.ObjectRootNode); }