public override void PopShell(float x, float y, int dir)
        {
            ShotgunShell shotgunShell = new ShotgunShell(x, y);

            shotgunShell.hSpeed = (float)dir * (1.5f + Rando.Float(1f));
            Level.Add((Thing)shotgunShell);
        }
Esempio n. 2
0
    protected override void Start()
    {
        base.Start();

        if (muzzleFlash != null)
        {
            GameObject flashEffect = Instantiate(muzzleFlash, transform.position, transform.rotation);
            Destroy(flashEffect, flashTime);
        }

        for (int i = 0; i < burstCount; i++)
        {
            ShotgunShell newProjectile = Instantiate(this, transform.position, Quaternion.identity);
            newProjectile.Damage      = Damage;
            newProjectile.Target      = Target;
            newProjectile.speed       = speed * Random.Range(minSpeedOffset, maxSpeedOffset);
            newProjectile.muzzleFlash = null;
            newProjectile.burstCount  = 0;
        }
    }
Esempio n. 3
0
    public void Eject()
    {
        GameObject   clone = Instantiate(m_shell, m_ejectionPort.transform.position, m_shell.transform.rotation);
        ShotgunShell shell = clone.GetComponent <ShotgunShell>();

        if (shell)
        {
            shell.UserTimerSelfDestruct = true;
        }
        Rigidbody rb = clone.GetComponent <Rigidbody>();

        m_shellImpulsePoint = clone.transform.GetChild(0).gameObject;
        if (rb)
        {
            rb.isKinematic = false;
            Vector3 impulse = (m_ejectionPort.transform.right.normalized * m_impulse.x)                                 //x
                              + (m_ejectionPort.transform.up.normalized * m_impulse.y)                                  //y
                              + (m_ejectionPort.transform.forward.normalized * m_impulse.z);                            //z

            rb.AddForceAtPosition(impulse, m_shellImpulsePoint.transform.position, ForceMode.Impulse);
        }
    }