public void Init(TracerFX a_tracer, Vector3 a_start, Vector3 a_end)
        {
            speed = a_tracer.speed * a_tracer.speed;
            start = a_start;
            end   = a_end;

            particleSys = GetComponent <ParticleSystem>();
        }
Exemplo n.º 2
0
        /// <summary>
        /// Initializing the tracer data.
        /// </summary>
        /// <param name="a_tracer">What tracerFX is it?</param>
        /// <param name="a_start">Tracer origin</param>
        /// <param name="a_end">Tracer finish</param>
        /// <param name="a_data">Data to reflect tracer</param>
        public void Init(TracerFX a_tracer, Vector3 a_start, Vector3 a_end, BulletData a_data)
        {
            speed       = a_tracer._tracerSpeed * a_tracer._tracerSpeed;
            start       = a_start;
            end         = a_end;
            impactFX    = a_tracer._impactFX;
            impactTimer = a_tracer._impactDestroyTimer;
            data        = a_data;

            particleSys = GetComponent <ParticleSystem>();
        }
 public static void ShootBullets(Vector3 a_shootPos, Vector3 a_shootDir, int a_bulletNum, Vector3 a_spread, float a_force, float a_damage, float a_penetration, TracerFX a_tracer, LayerMask a_filter)
 {
     for (int i = 0; i < a_bulletNum; i++)
     {
         Bullet.Initiate(a_shootPos, a_shootDir, a_spread, a_force, a_damage, a_penetration, a_tracer, a_filter);
     }
 }
        public static void Initiate(Vector3 a_shootPos, Vector3 a_shootDir, Vector3 a_spread, float a_force, float a_damage, float a_penetration, TracerFX a_tracer, LayerMask a_filter)
        {
            a_shootDir = a_shootDir + new Vector3(Random.Range(-a_spread.x, a_spread.x), Random.Range(-a_spread.y, a_spread.y), Random.Range(-a_spread.z, a_spread.z));

            RaycastHit hit;
            if (Physics.Raycast(a_shootPos, a_shootDir, out hit, 1000, a_filter))
            {
                a_tracer.CreateTracer(a_shootPos, new Quaternion(), a_shootPos, hit.point);

                Bullet.ApplyDamage(a_force, hit, a_damage);
            }
            else
            {
                a_tracer.CreateTracer(a_shootPos, new Quaternion(), a_shootPos, a_shootPos + a_shootDir * 100);
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Initiating a bullet and shooting it with respected effects.
        /// </summary>
        /// <param name="a_shootPos">Where does the bullet start from?</param>
        /// <param name="a_shootDir">In which direction will the bullet shoot from the shoot pos?</param>
        /// <param name="a_spread">The spread which will be randomly calculated between the negative to the positive of this value.</param>
        /// <param name="a_force">How much force will the bullet apply to the hit object?</param>
        /// <param name="a_damage">How much damage will it deal if the object is damageable?</param>
        /// <param name="a_penetration">How many objects will the bullet pass through before destroying itself?</param>
        /// <param name="a_tracer">What tracer will it use?</param>
        /// <param name="a_filter">What layers will the bullet ignore?</param>
        /// <returns>Returns the bullet hit as its shot using raycast.</returns>
        public static RaycastHit Initiate(Vector3 a_shootPos, Vector3 a_shootDir, Vector3 a_spread, float a_force, float a_damage, float a_penetration = 0, TracerFX a_tracer = null, LayerMask a_filter = default, bool a_applyTracer = true)
        {
            a_shootDir += new Vector3(Random.Range(-a_spread.x, a_spread.x), Random.Range(-a_spread.y, a_spread.y), Random.Range(-a_spread.z, a_spread.z));

            // I love inline initialization <3
            BulletData data = new BulletData {
                origin      = a_shootPos,
                direction   = a_shootDir,
                spread      = a_spread,
                force       = a_force,
                damage      = a_damage,
                penetration = a_penetration,
                tracer      = a_tracer,
                filter      = a_filter
            };

            RaycastHit hit;

            if (Physics.Raycast(a_shootPos, a_shootDir, out hit, 1000, a_filter))
            {
                if (!a_applyTracer)
                {
                    Bullet.ApplyDamage(a_force, hit, a_damage);

                    if (a_penetration > 0)
                    {
                        a_penetration -= 1;

                        Bullet.Initiate(hit.point + a_shootDir * 0.5f, a_shootDir, a_spread, a_force, a_damage, a_penetration, a_tracer, a_filter, false);
                    }
                }
            }
            else
            {
                hit.point = a_shootPos + a_shootDir * 100;
            }

            if (a_applyTracer)
            {
                Tracer tracer = a_tracer.CreateTracer(a_shootPos, new Quaternion(), a_shootPos, hit.point, data);
                tracer.hit = hit;
            }

            return(hit);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Initiating a bullet and shooting it with respected effects.
        /// </summary>
        /// <param name="a_shootPos">Where does the bullet start from?</param>
        /// <param name="a_shootDir">In which direction will the bullet shoot from the shoot pos?</param>
        /// <param name="a_bulletNum">How many bullets do we shoot?</param>
        /// <param name="a_spread">The spread which will be randomly calculated between the negative to the positive of this value.</param>
        /// <param name="a_force">How much force will the bullet apply to the hit object?</param>
        /// <param name="a_damage">How much damage will it deal if the object is damageable?</param>
        /// <param name="a_penetration">How many objects will the bullet pass through before destroying itself?</param>
        /// <param name="a_tracer">What tracer will it use?</param>
        /// <param name="a_filter">What layers will the bullet ignore?</param>
        public static List <RaycastHit> ShootBullets(Vector3 a_shootPos, Vector3 a_shootDir, int a_bulletNum, Vector3 a_spread, float a_force, float a_damage, float a_penetration = 0, TracerFX a_tracer = null, LayerMask a_filter = default)
        {
            List <RaycastHit> bulletHits = new List <RaycastHit>();

            for (int i = 0; i < a_bulletNum; i++)
            {
                bulletHits.Add(Bullet.Initiate(a_shootPos, a_shootDir, a_spread, a_force, a_damage, a_penetration, a_tracer, a_filter));
            }

            return(bulletHits);
        }