Ejemplo n.º 1
0
        public virtual Projectile SpawnProjectile(Vector2f pos, float direction, float offset, Vector2f? targetPos = null)
        {
            Projectile proj = new Projectile(Game, GetProjectileModel(), this);

            // Position and Velocity
            proj.SetPosition(pos);
            proj.Rotate(direction);

            float angle = offset == 0 ? (float)Utils.ToRadians(direction) : (float)Utils.ToRadians(direction + offset);
            proj.Velocity = new Vector2f((float)Math.Cos(angle) * ProjectileSpeed, (float)Math.Sin(angle) * ProjectileSpeed);

            // Stats
            proj.Damage = Damage;
            proj.SetLifeSpan(ProjectileLifeSpan);
            if (targetPos.HasValue)
                proj.SetTargetPosition(targetPos.Value);
            if (ProjectileRotateSpeed != 0)
            {
                proj.RotateSpeed = ProjectileRotateSpeed*(Utils.RandomInt() == 1 ? 1 : -1);
                proj.Rotate(Utils.RandomInt(0, 359));
            }

            Game.Layer_Other.AddChild(proj);

            return proj;
        }
Ejemplo n.º 2
0
 public virtual void OnProjectileCollision(Projectile proj, dynamic hitTarget = null)
 {
     Explode(proj.Position);
 }