Ejemplo n.º 1
0
    private void Shoot()
    {
        if (shootInput)
        {
            // Chose the shot spawn configuration
            GameObject shotSpawners = shotSpawns.transform.FindChild("Powerup " + numberOfShots).gameObject;

            GameObject tempBullet;

            foreach (Transform shotSpawn in shotSpawners.transform)
            {
                tempBullet = (GameObject)Instantiate(bullet, shotSpawn.position, shotSpawn.rotation);
                Vector2 shotVector = new Vector2(0, shotForce);
                shotVector = AuxFunctions.RotateVector2d(shotVector, shotSpawn.eulerAngles.z);
                tempBullet.GetComponent <Rigidbody2D>().velocity = shotVector;
            }
            shootInput = false;
            shotTimer  = minShotInterval;

            audioSource.PlayOneShot(laserShotAudio[Random.Range(0, laserShotAudio.Length)]);
        }
    }