GetEnemyBulletSpawnPoint() public method

public GetEnemyBulletSpawnPoint ( Vector3 gun ) : Vector3
gun Vector3
return Vector3
Exemplo n.º 1
0
    IEnumerator RandomSpray(float speed, int seed)
    {
        //Random spray speed doesn't change.  We use the speed value to adjust intensity.

        System.Random rng = new System.Random(seed);

        float actionMultiplier = 1; //(1 / speed);

        Debug.Log("Rapid Cannon start At: " + Time.time);

        Netman.Enemy.animation["randomspray"].layer     = 2;
        Netman.Enemy.animation["randomspray"].speed     = 0.85f; //hmm!
        Netman.Enemy.animation["randomspray"].blendMode = AnimationBlendMode.Additive;
        Netman.Enemy.animation.CrossFade("randomspray");

        GameObject gun1 = GameObject.Find("ArmGunL");
        GameObject gun2 = GameObject.Find("ArmGunR");
        GameObject gun3 = null;

        if (BackGunActive)
        {
            gun3 = GameObject.Find("GunMid/Gun");
        }
        GameObject projectile;
        EnemySmallShotProjectile bullet;
        Vector3 aim;

        int intensity = (int)((speed - 1f) * 10);

        float wait        = 0.5f;
        int   shotstofire = 1;
        int   maxshots    = 1 + (intensity * Netman.difficulty) / 3;

        float maxangle = 85f;
        int   minspeed = 20;
        int   maxspeed = 60;

        yield return(new WaitForSeconds(1.1f * actionMultiplier));

        int firecount = 40;

        if (Netman.difficulty == 3)
        {
            firecount = 45;
        }
        if (Netman.difficulty == 0)
        {
            firecount = 25;
        }

        for (int i = 0; i < firecount; i++)
        {
            Vector3 gun1point = BMan.GetEnemyBulletSpawnPoint(gun1.transform.position);
            Vector3 gun2point = BMan.GetEnemyBulletSpawnPoint(gun2.transform.position);
            Vector3 gun3point = Vector3.zero;
            if (gun3 != null)
            {
                gun3point = BMan.GetEnemyBulletSpawnPoint(gun3.transform.position + (Quaternion.Euler(gun3.transform.rotation.eulerAngles) * new Vector3(-25.2f, 0f, 0f)));
            }


            for (int j = 0; j < shotstofire; j++)
            {
                float shotspeed = (float)rng.Next(minspeed * 10, maxspeed * 10) / 10f;
                float angle     = (float)rng.Next(0, (int)maxangle * 2) - maxangle;

                aim              = -gun1.transform.right;
                projectile       = GameObject.Instantiate(BulletSmallShot, gun1point, Quaternion.identity) as GameObject;
                bullet           = projectile.GetComponent <EnemySmallShotProjectile>();
                bullet.direction = Quaternion.Euler(new Vector3(0f, angle, 0f)) * aim;
                bullet.direction = new Vector3(bullet.direction.x, 0f, bullet.direction.z);
                bullet.speed     = shotspeed;
            }

            for (int j = 0; j < shotstofire; j++)
            {
                float shotspeed = (float)rng.Next(minspeed * 10, maxspeed * 10) / 10f;
                float angle     = (float)rng.Next(0, (int)maxangle * 2) - maxangle;

                aim              = -gun2.transform.right;
                projectile       = GameObject.Instantiate(BulletSmallShot, gun2point, Quaternion.identity) as GameObject;
                bullet           = projectile.GetComponent <EnemySmallShotProjectile>();
                bullet.direction = Quaternion.Euler(new Vector3(0f, angle, 0f)) * aim;
                bullet.direction = new Vector3(bullet.direction.x, 0f, bullet.direction.z);
                bullet.speed     = shotspeed;
            }

            if (gun3 != null)
            {
                for (int j = 0; j < Mathf.Clamp(shotstofire / 2, 1, 3); j++)
                {
                    float shotspeed = (float)rng.Next(minspeed * 10, maxspeed * 10) / 10f;
                    float angle     = (float)rng.Next(0, (int)maxangle * 2) - maxangle;

                    aim              = -gun3.transform.right;
                    projectile       = GameObject.Instantiate(BulletSmallShot, gun3point, Quaternion.identity) as GameObject;
                    bullet           = projectile.GetComponent <EnemySmallShotProjectile>();
                    bullet.direction = Quaternion.Euler(new Vector3(0f, angle, 0f)) * aim;
                    bullet.direction = new Vector3(bullet.direction.x, 0f, bullet.direction.z);
                    bullet.speed     = shotspeed;
                }
            }


            GameObject.Instantiate(SoundRegularShot, Vector3.zero, Quaternion.identity);

            yield return(new WaitForSeconds(wait));

            wait -= 0.05f;
            if (wait < 0.1f && Netman.difficulty < 3)
            {
                wait = 0.1f;
            }
            if (wait < 0.07f)
            {
                wait = 0.07f;
            }
            if (wait < 0.2f && Netman.difficulty == 0)
            {
                wait = 0.2f;
            }

            if (Netman.difficulty < 3)
            {
                shotstofire = i / 2;
            }
            else
            {
                shotstofire = i + 1;
            }

            if (shotstofire <= 0)
            {
                shotstofire = 1;
            }

            if (shotstofire > maxshots)
            {
                shotstofire = maxshots;
            }

            if (shotstofire < 2 && Netman.difficulty == 3)
            {
                shotstofire = 2;
            }
        }

        yield return(null);
    }