/// <summary>
 /// Add a new projectile
 /// </summary>
 public void Add(Projectile p)
 {
     projectiles.AddLast(p);
 }
Beispiel #2
0
        /// <summary>
        /// Create a new projectile and add it to the projectile manager
        /// </summary>
        public Projectile AddProjectile(
            ProjectileType type,
            int player,
            Matrix transform,
            float velocity,
            float damage,
            RenderTechnique technique)
        {
            // get source and destination positions for projectile
            Vector3 source = transform.Translation;
            Vector3 destination = source + transform.Forward * 10000;

            // ray intersect level to find out where projetile is going to hit
            float hitDist;
            Vector3 hitPos, hitNormal;
            if (levelCollision.PointIntersect(source, destination,
                                        out hitDist, out hitPos, out hitNormal))
                destination = hitPos;
            else
                hitNormal = transform.Backward;

            // create projectile
            Projectile p = new Projectile(type, projectileModels[(int)type],
                player, velocity, damage, transform, destination, technique);

            // add it to the projectile manager
            projectile.Add(p);

            return p;
        }