Пример #1
0
    // Start is called before the first frame update

    public void Explode()
    {
        RadiusSpawner spawnerScript = radiusSpawner.GetComponent <RadiusSpawner>();

        spawnerScript.projectile           = bombProjectile;
        spawnerScript.minRotation          = 1;
        spawnerScript.maxRotation          = 360;
        spawnerScript.bulletSpeed          = 3.0f;
        spawnerScript.totalProjectiles     = 30;
        spawnerScript.totalProjectileWaves = 1;
        spawnerScript.isRandom             = false;
        spawnerScript.isBombBullet         = true;

        Instantiate(spawnerScript, transform.position, Quaternion.identity);
    }
Пример #2
0
    private void SpawnSpawner()
    {
        string projectileType = projectileTypes[random.Next(projectileTypes.Length)];

        // projectileType = "FireWork";
        if (projectileType == "Sinusoidal")
        {
            string  projectileDirection = projectileDirections[random.Next(projectileDirections.Length)];
            Spawner spawnerScript       = spawner.GetComponent <Spawner>();
            spawnerScript.projectile = sinusoidalProjectile;
            spawnerScript.delayBetweenProjectiles = 0.3f;
            spawnerScript.bulletSpeed             = UnityEngine.Random.Range(1f, 1f + (difficulty / 2));
            spawnerScript.totalProjectiles        = random.Next(6, 6 + (difficulty / 2));
            spawnerScript.audioController         = audioController;
            switch (projectileDirection)
            {
            case "Left":
                spawnerScript.projectileDirection = Vector3.left;
                if (isStill)
                {
                    Instantiate(spawner, new Vector3(cameraLimitXRound, random.Next((int)(playerPosition.y - stillnessRadio), (int)(playerPosition.y + stillnessRadio)), 0), Quaternion.identity);
                }
                else
                {
                    Instantiate(spawner, new Vector3(cameraLimitXRound, random.Next(-cameraLimitYRound, cameraLimitYRound), 0), Quaternion.identity);
                }
                break;

            case "Right":
                spawnerScript.projectileDirection = Vector3.right;
                if (isStill)
                {
                    Instantiate(spawner, new Vector3(-cameraLimitXRound, random.Next((int)(playerPosition.y - stillnessRadio), (int)(playerPosition.y + stillnessRadio)), 0), Quaternion.identity);
                }
                else
                {
                    Instantiate(spawner, new Vector3(-cameraLimitXRound, random.Next(-cameraLimitYRound, cameraLimitYRound), 0), Quaternion.identity);
                }
                break;

            case "Up":
                spawnerScript.projectileDirection = Vector3.up;
                if (isStill)
                {
                    Instantiate(spawner, new Vector3(random.Next((int)(playerPosition.x - stillnessRadio), (int)(playerPosition.x - stillnessRadio)), -cameraLimitYRound, 0), Quaternion.identity);
                }
                else
                {
                    Instantiate(spawner, new Vector3(random.Next(-cameraLimitXRound, cameraLimitXRound), -cameraLimitYRound, 0), Quaternion.identity);
                }
                break;

            case "Down":
                spawnerScript.projectileDirection = Vector3.down;
                if (isStill)
                {
                    Instantiate(spawner, new Vector3(random.Next((int)(playerPosition.x - stillnessRadio), (int)(playerPosition.x - stillnessRadio)), cameraLimitYRound, 0), Quaternion.identity);
                }
                else
                {
                    Instantiate(spawner, new Vector3(random.Next(-cameraLimitXRound, cameraLimitXRound), cameraLimitYRound, 0), Quaternion.identity);
                }
                break;
            }
        }
        else if (projectileType == "LineBeam")
        {
            string  projectileDirection = projectileDirections[random.Next(projectileDirections.Length)];
            Spawner spawnerScript       = spawner.GetComponent <Spawner>();
            spawnerScript.projectile = lineBeamProjectile;
            spawnerScript.delayBetweenProjectiles = 2.0f;
            spawnerScript.totalProjectiles        = random.Next(3, 3 + (difficulty / 2));
            spawnerScript.bulletSpeed             = UnityEngine.Random.Range(1f, 1f + (difficulty / 2));
            spawnerScript.audioController         = audioController;
            switch (projectileDirection)
            {
            case "Left":
                spawnerScript.projectileDirection = Vector3.left;
                if (isStill)
                {
                    Instantiate(spawner, new Vector3(cameraLimitXRound, random.Next((int)(playerPosition.y - stillnessRadio), (int)(playerPosition.y + stillnessRadio)), 0), Quaternion.identity);
                }
                else
                {
                    Instantiate(spawner, new Vector3(cameraLimitXRound, random.Next(-cameraLimitYRound, cameraLimitYRound), 0), Quaternion.identity);
                }
                break;

            case "Right":
                spawnerScript.projectileDirection = Vector3.right;
                if (isStill)
                {
                    Instantiate(spawner, new Vector3(-cameraLimitXRound, random.Next((int)(playerPosition.y - stillnessRadio), (int)(playerPosition.y + stillnessRadio)), 0), Quaternion.identity);
                }
                else
                {
                    Instantiate(spawner, new Vector3(-cameraLimitXRound, random.Next(-cameraLimitYRound, cameraLimitYRound), 0), Quaternion.identity);
                }
                break;

            case "Up":
                spawnerScript.projectileDirection = Vector3.up;
                if (isStill)
                {
                    Instantiate(spawner, new Vector3(random.Next((int)(playerPosition.x - stillnessRadio), (int)(playerPosition.x - stillnessRadio)), -cameraLimitYRound, 0), Quaternion.identity);
                }
                else
                {
                    Instantiate(spawner, new Vector3(random.Next(-cameraLimitXRound, cameraLimitXRound), -cameraLimitYRound, 0), Quaternion.identity);
                }
                break;

            case "Down":
                spawnerScript.projectileDirection = Vector3.down;
                if (isStill)
                {
                    Instantiate(spawner, new Vector3(random.Next((int)(playerPosition.x - stillnessRadio), (int)(playerPosition.x - stillnessRadio)), cameraLimitYRound, 0), Quaternion.identity);
                }
                else
                {
                    Instantiate(spawner, new Vector3(random.Next(-cameraLimitXRound, cameraLimitXRound), cameraLimitYRound, 0), Quaternion.identity);
                }
                break;
            }
        }
        else if (projectileType == "FireWork")
        {
            RadiusSpawner spawnerScript = radiusSpawner.GetComponent <RadiusSpawner>();
            spawnerScript.projectile           = shurikenProjectile;
            spawnerScript.minRotation          = 1;
            spawnerScript.maxRotation          = 360;
            spawnerScript.bulletSpeed          = UnityEngine.Random.Range(3f, 3f + (difficulty / 2));
            spawnerScript.totalProjectiles     = random.Next(6, 6 + (difficulty / 2));
            spawnerScript.totalProjectileWaves = random.Next(3, 3 + (difficulty / 2));
            spawnerScript.isRandom             = random.Next(1, difficulty) > 1;
            spawnerScript.isBombBullet         = false;
            spawnerScript.audioController      = audioController;

            if (isStill)
            {
                Instantiate(radiusSpawner, new Vector3(random.Next((int)(playerPosition.x - stillnessRadio), (int)(playerPosition.x + stillnessRadio)),
                                                       random.Next((int)(playerPosition.y - stillnessRadio), (int)(playerPosition.y + stillnessRadio)), 0), Quaternion.identity);
            }
            else
            {
                Instantiate(radiusSpawner, new Vector3(random.Next(-cameraLimitXRound, cameraLimitXRound), random.Next(-cameraLimitYRound, cameraLimitYRound), 0), Quaternion.identity);
            }
        }
        else if (projectileType == "Flamethrower")
        {
            RadiusSpawner spawnerScript       = radiusSpawner.GetComponent <RadiusSpawner>();
            string        projectileDirection = projectileDirections[random.Next(projectileDirections.Length)];
            spawnerScript.projectile           = greenProjectile;
            spawnerScript.totalProjectiles     = random.Next(3, 3 + (difficulty / 2));
            spawnerScript.totalProjectileWaves = random.Next(6, 6 + (difficulty / 2));
            spawnerScript.bulletSpeed          = UnityEngine.Random.Range(3f, 3f + (difficulty / 2));
            spawnerScript.isRandom             = random.Next(1, difficulty) > 30;
            spawnerScript.isBombBullet         = false;
            spawnerScript.audioController      = audioController;

            switch (projectileDirection)
            {
            case "Left":
                spawnerScript.minRotation = 135;
                spawnerScript.maxRotation = 225;
                if (isStill)
                {
                    Instantiate(radiusSpawner, new Vector3(cameraLimitXRound, random.Next((int)(playerPosition.y - stillnessRadio), (int)(playerPosition.y + stillnessRadio)), 0), Quaternion.identity);
                }
                else
                {
                    Instantiate(radiusSpawner, new Vector3(cameraLimitXRound, random.Next(-cameraLimitYRound, cameraLimitYRound), 0), Quaternion.identity);
                }
                break;

            case "Right":
                spawnerScript.minRotation = 315;
                spawnerScript.maxRotation = 405;
                if (isStill)
                {
                    Instantiate(radiusSpawner, new Vector3(-cameraLimitXRound, random.Next((int)(playerPosition.y - stillnessRadio), (int)(playerPosition.y + stillnessRadio)), 0), Quaternion.identity);
                }
                else
                {
                    Instantiate(radiusSpawner, new Vector3(-cameraLimitXRound, random.Next(-cameraLimitYRound, cameraLimitYRound), 0), Quaternion.identity);
                }
                break;

            case "Up":
                spawnerScript.minRotation = 45;
                spawnerScript.maxRotation = 135;
                if (isStill)
                {
                    Instantiate(radiusSpawner, new Vector3(random.Next((int)(playerPosition.x - stillnessRadio), (int)(playerPosition.x - stillnessRadio)), -cameraLimitYRound, 0), Quaternion.identity);
                }
                else
                {
                    Instantiate(radiusSpawner, new Vector3(random.Next(-cameraLimitXRound, cameraLimitXRound), -cameraLimitYRound, 0), Quaternion.identity);
                }
                break;

            case "Down":
                spawnerScript.minRotation = 225;
                spawnerScript.maxRotation = 315;
                if (isStill)
                {
                    Instantiate(radiusSpawner, new Vector3(random.Next((int)(playerPosition.x - stillnessRadio), (int)(playerPosition.x - stillnessRadio)), cameraLimitYRound, 0), Quaternion.identity);
                }
                else
                {
                    Instantiate(radiusSpawner, new Vector3(random.Next(-cameraLimitXRound, cameraLimitXRound), cameraLimitYRound, 0), Quaternion.identity);
                }
                break;
            }
        }
    }