Exemplo n.º 1
0
    void SetHitscanProperties(GameObject bullet)
    {
        HitscanProjectile hitscanProjectile = bullet.GetComponent <HitscanProjectile>();

        hitscanProjectile.SetDecayTimerLength(projectileData.decayTimerLength);
        hitscanProjectile.SetInstantTravel(projectileData.instantTravel);
    }
Exemplo n.º 2
0
    public void CreateProjectiles(Transform tr)
    {
        int num = (int)pellets;

        //Debug.Log("" + num.MidA() + "-" + num.MidB());

        for (int i = 0; i < num; i++)
        {
            float rot = RandomF.unit * spread * .5f;
            float f   = ((float)i + .5f) / pellets;

            if (uniformDirection)
            {
                rot = -spread / 2f + spread * f;
                if (num == 1)
                {
                    rot = 0;
                }
            }

            if (spins)
            {
                rot += spin;
            }
            Vector3 off = Vector3.Scale(Random.insideUnitSphere, offset * .5f);

            if (uniformPosition)
            {
                //Adds offset for index position
                off = -offset / 2f + offset * f;

                //Adds mirrorOffset for index position
                int n = 0;
                if (i < num.MidA())
                {
                    n = i - num.MidA();
                }
                else if (i > num.MidB())
                {
                    n = i - num.MidB();
                }
                off += (-.5f + ((float)n).Abs() * 2f / pellets) * mirrorOffset;
            }
            DealsDamage bullet;
            if (projectile == null)
            {
                bullet = HitscanProjectile.Factory();
                bullet.transform.position = tr.position;
                bullet.transform.rotation = tr.rotation;
            }
            else
            {
                bullet = Transform.Instantiate(projectile, tr.position, tr.rotation) as DealsDamage;
            }

            if (bullet.sticksToSource)
            {
                bullet.transform.parent = tr;
            }
            bullet.source = holder.GetComponent <Unit>();
            bullet.atk    = damage;
            bullet.transform.Translate(off);

            if (use2dRotation)
            {
                Vector3 forward = bullet.transform.forward;
                forward.y = 0;
                bullet.transform.forward = forward;
                bullet.transform.Rotate(0, rot, 0);
            }
            else
            {
                Vector3 axis = Random.onUnitSphere;
                bullet.transform.Rotate(axis * rot);
            }
        }
    }