示例#1
0
    // use this only if already checked if weapon is ready to fire
    public override void DoFire()
    {
        if (error == true)
        {
            return;
        }
        if (active == false)
        {
            return;
        }

        // fire weapon
        // create shot
        for (int spr = 0; spr < shotsPerRound; spr++)
        {
            GameObject myShot  = (GameObject)Instantiate(shot, exits[curExit].transform.position, exits[curExit].transform.rotation);
            Vector2    errorV2 = Random.insideUnitCircle * curInaccuracy;
            myShot.transform.rotation *= Quaternion.Euler(errorV2.x, errorV2.y, 0);
            Rigidbody _rb = myShot.GetComponent <Rigidbody>();
            _rb.velocity   = platformVelocity + (myShot.transform.forward * shotSpeed);
            _rb.useGravity = usingGravity;
            MF_B_Projectile shotScript = myShot.GetComponent <MF_B_Projectile>();
            shotScript.duration = shotDuration;
        }

        base.DoFire();
    }
示例#2
0
    public override void DoFire(Transform target)
    {
        if (error == true)
        {
            return;
        }
        if (active == false)
        {
            return;
        }

        // fire weapon
        // create shot
        GameObject myShot = null;

        for (int spr = 0; spr < shotsPerRound; spr++)
        {
            if (objectPool == true)
            {
                myShot = MF_AutoPool.Spawn(shot.gameObject, exits[curExit].transform.position, exits[curExit].transform.rotation);
            }
            else
            {
                myShot = (GameObject)Instantiate(shot.gameObject, exits[curExit].transform.position, exits[curExit].transform.rotation);
            }
            if (myShot != null)
            {
                Vector2 errorV2 = Random.insideUnitCircle * curInaccuracy;
                myShot.transform.rotation *= Quaternion.Euler(errorV2.x, errorV2.y, 0);
                Rigidbody _rb = myShot.GetComponent <Rigidbody>();
                _rb.velocity   = platformVelocity + (myShot.transform.forward * shotSpeed);
                _rb.useGravity = usingGravity;
                MF_B_Projectile shotScript = myShot.GetComponent <MF_B_Projectile>();
                shotScript.duration = shotDuration;
            }
        }
        if (myShot != null)             // at least one shot was created
        {
            base.DoFire(target);
        }
    }