public override void GenerateLevel()
    {
        int   num   = 0;
        float num2  = (float)20;
        float num3  = default(float);
        float num4  = default(float);
        float num5  = default(float);
        float num6  = default(float);
        float num7  = default(float);
        float num8  = default(float);
        float num9  = default(float);
        float num10 = (float)150;
        float num11 = this.worldSize * 0.5f;
        float num12 = default(float);

        num12         = num10 / this.xDim;
        this.xDensity = this.xDim / (float)this.xDivisions;
        this.yDensity = this.yDim / (float)this.yDivisions;
        this.zDensity = this.zDim / (float)this.zDivisions;
        num3          = (float)0;
        Vector3 vector = default(Vector3);

        num4 = (float)0;
        MonoBehaviour.print("\tyDivisions = " + this.yDivisions);
        while (num4 < (float)this.yDivisions)
        {
            for (int i = 0; i < this.xDivisions; i = checked (i + 1))
            {
                float num13 = (float)Random.Range(this.minAsteroidSize, this.maxAsteroidSize);
                if (!this.manualVelocityScale)
                {
                    this.velocityScale = (float)GameController.instance.gameLevel * 1.25f;
                }
                vector.x = this.get_transform().get_position().x - this.xDim / (float)2 + (float)i * this.xDensity + Random.Range(-0.125f * num11, 0.125f * num11);
                vector.y = this.get_transform().get_position().y - this.yDim / (float)2 + this.offsetXYZ.get_Item(1) + num4 * this.yDensity + Random.Range(-0.125f * num11, 0.125f * num11);
                vector.z = this.get_transform().get_position().z + this.offsetXYZ.get_Item(2) + Random.Range(-0.5f * num11, 0.5f * num11);
                Renderer renderer = (Renderer)this.asterpinataPrefab.GetComponent(typeof(Renderer));
                float    num14    = (renderer.get_bounds().get_max() - renderer.get_bounds().get_min()).get_magnitude() * 0.5f;
                num14 *= num13;
                float num15 = default(float);
                bool  flag  = true;
                if (!Physics.CheckSphere(vector, num14 * 2f) && flag)
                {
                    int num16 = Random.Range(0, 3);
                    if (num16 == 0)
                    {
                        Asteroid asteroid = (Asteroid)Object.Instantiate(this.asteroidPrefab);
                        asteroid.get_transform().set_position(vector);
                        asteroid.Setup(num14, this.velocityScale * (float)2);
                        checked
                        {
                            num++;
                            asteroid.set_name("donkeypinata" + num);
                            if (vector.x > (float)0)
                            {
                                asteroid.get_rigidbody().AddForce((float)500 * new Vector3(-0.1f, (float)0, (float)-1), 1);
                            }
                            else
                            {
                                asteroid.get_rigidbody().AddForce((float)500 * new Vector3(0.1f, (float)0, (float)-1), 1);
                            }
                        }
                    }
                    else if (num16 == 1)
                    {
                        Asterpinata asterpinata = (Asterpinata)Object.Instantiate(this.asterpinataPrefab);
                        asterpinata.get_transform().set_position(vector);
                        asterpinata.Setup(num14, this.velocityScale * (float)4);
                        checked
                        {
                            num++;
                            asterpinata.set_name("asterpinata" + num);
                            if (vector.x > (float)0)
                            {
                                asterpinata.get_rigidbody().AddForce((float)500 * new Vector3(-0.1f, (float)0, (float)-1), 1);
                            }
                            else
                            {
                                asterpinata.get_rigidbody().AddForce((float)500 * new Vector3(0.1f, (float)0, (float)-1), 1);
                            }
                        }
                    }
                    else if (num16 == 2)
                    {
                        StarPinata starPinata = (StarPinata)Object.Instantiate(this.starPinataPrefab);
                        starPinata.get_transform().set_position(vector);
                        starPinata.Setup(num14, this.velocityScale * (float)3);
                        checked
                        {
                            num++;
                            starPinata.set_name("starpinata" + num);
                            if (vector.x > (float)0)
                            {
                                starPinata.get_rigidbody().AddForce((float)500 * new Vector3(-0.1f, (float)0, (float)-1), 1);
                            }
                            else
                            {
                                starPinata.get_rigidbody().AddForce((float)500 * new Vector3(0.1f, (float)0, (float)-1), 1);
                            }
                        }
                    }
                    if (num > this.maxAsteroidCount)
                    {
                        MonoBehaviour.print("too many spawned asteroids  = " + num);
                        return;
                    }
                }
            }
            num4 += (float)1;
        }
        MonoBehaviour.print("ASTEROID band generated asteroids  = " + num);
    }
Esempio n. 2
0
    public override void GenerateLevel()
    {
        int num = 0;

        this.asteroidCount = checked (5 + GameController.instance.gameLevel * 5);
        float num2  = (float)20;
        float num3  = default(float);
        float num4  = default(float);
        float num5  = default(float);
        float num6  = default(float);
        float num7  = default(float);
        float num8  = default(float);
        float num9  = default(float);
        float num10 = (float)150;
        float num11 = this.worldSize * 0.5f;
        float num12 = default(float);

        MonoBehaviour.print("MAKE A BLOODY ASTEROID FIELD ALREADY!!!!");
        num12         = num10 / this.xDim;
        this.xDensity = this.xDim / (float)this.xDivisions;
        this.yDensity = this.yDim / (float)this.yDivisions;
        this.zDensity = this.zDim / (float)this.zDivisions;
        num3          = (float)0;
        Vector3 vector = default(Vector3);

        while (num3 < (float)this.zDivisions)
        {
            MonoBehaviour.print("zCount = " + num3);
            float num13 = (float)this.yDivisions + num3 * num12;
            num7 = num13 * this.yDensity;
            num4 = (float)0;
            if (num3 == (float)0)
            {
                MonoBehaviour.print("\tyDivisions = " + this.yDivisions);
            }
            if (num3 == (float)0)
            {
                MonoBehaviour.print("\tyDimInc = " + num7);
            }
            if (num3 == (float)0)
            {
                MonoBehaviour.print("\tyDivisionsInc = " + num13);
            }
            if (num3 == (float)0)
            {
                MonoBehaviour.print("\tyDim = " + this.yDim);
            }
            while (num4 < num13)
            {
                int   num14 = 0;
                float num15 = (float)this.xDivisions + num3 * num12;
                num9 = num15 * this.xDensity;
                if (num3 == (float)0)
                {
                    MonoBehaviour.print("\t\tyCount = " + num4);
                }
                if (num3 == (float)0)
                {
                    MonoBehaviour.print("\t\txDimInc = " + num9);
                }
                if (num3 == (float)0)
                {
                    MonoBehaviour.print("\t\txDivisionsInc = " + num15);
                }
                while ((float)num14 < num15)
                {
                    if (num3 == (float)0)
                    {
                        MonoBehaviour.print("\t\txCount = " + num14);
                    }
                    float num16 = (float)Random.Range(this.minAsteroidSize, this.maxAsteroidSize);
                    if (num3 == (float)0)
                    {
                        num16 = (float)this.minAsteroidSize;
                    }
                    if (!this.manualVelocityScale)
                    {
                        this.velocityScale = (float)GameController.instance.gameLevel * 1.25f;
                    }
                    vector.x = this.get_transform().get_position().x - num9 / (float)2 + (float)num14 * this.xDensity + Random.Range(-0.125f * num11, 0.125f * num11);
                    vector.y = this.get_transform().get_position().y - num7 / (float)2 + this.offsetXYZ.get_Item(1) + num4 * this.yDensity + Random.Range(-0.125f * num11, 0.125f * num11);
                    vector.z = this.get_transform().get_position().z + this.offsetXYZ.get_Item(2) + num3 * this.zDensity + Random.Range(-num11, num11);
                    if (num3 == (float)0)
                    {
                        MonoBehaviour.print("\t\tzCount = " + num3 + ", xPos = " + vector.x + ", yPos = " + vector.y + ", zPos = " + vector.z);
                    }
                    Renderer renderer = (Renderer)this.asterpinataPrefab.GetComponent(typeof(Renderer));
                    float    num17    = (renderer.get_bounds().get_max() - renderer.get_bounds().get_min()).get_magnitude() * 0.5f;
                    if (num3 == (float)0)
                    {
                        MonoBehaviour.print("renderer radius = " + num17 + ", rand = " + num16);
                    }
                    num17 *= num16;
                    float num18 = default(float);
                    bool  flag  = true;
                    float num19 = 6f;
                    if (num3 == (float)0)
                    {
                        num19 = 1f;
                        MonoBehaviour.print("XXXXXX final radius = " + num17);
                    }
                    checked
                    {
                        if (!Physics.CheckSphere(vector, unchecked (num17 * num19)) && flag)
                        {
                            int num20 = Random.Range(0, 3);
                            if (num20 == 0)
                            {
                                Asteroid asteroid = (Asteroid)Object.Instantiate(this.asteroidPrefab);
                                asteroid.get_transform().set_position(vector);
                                asteroid.Setup(num17, this.velocityScale);
                                num++;
                                asteroid.set_name("donkeypinata" + num);
                            }
                            else if (num20 == 1)
                            {
                                Asterpinata asterpinata = (Asterpinata)Object.Instantiate(this.asterpinataPrefab);
                                asterpinata.get_transform().set_position(vector);
                                asterpinata.Setup(num17, this.velocityScale);
                                num++;
                                asterpinata.set_name("asterpinata" + num);
                            }
                            else if (num20 == 2)
                            {
                                StarPinata starPinata = (StarPinata)Object.Instantiate(this.starPinataPrefab);
                                starPinata.get_transform().set_position(vector);
                                starPinata.Setup(num17, this.velocityScale);
                                num++;
                                starPinata.set_name("starpinata" + num);
                            }
                            if (num > this.maxAsteroidCount)
                            {
                                MonoBehaviour.print("too many spawned asteroids  = " + num);
                                return;
                            }
                            if (num3 == (float)0)
                            {
                                MonoBehaviour.print("spawned asteroids  = " + num);
                            }
                        }
                        else if (num3 == (float)0)
                        {
                            MonoBehaviour.print("CHECK SPHERE : did not spawn asteroid");
                        }
                        num14++;
                    }
                }
                num4 += (float)1;
            }
            num3 += (float)1;
        }
    }
    public override void OnTriggerEnter(Collider other)
    {
        Asteroid asteroid = (Asteroid)other.get_transform().GetComponent(typeof(Asteroid));

        if (asteroid != null)
        {
            MonoBehaviour.print("BEAM TRIGGER ENTER name = " + other.get_name());
            asteroid.Hit();
            GameObject gameObject = (GameObject)Object.Instantiate(this.miniExplosion, this.get_transform().get_position(), this.get_transform().get_rotation());
            object     component  = gameObject.GetComponent("Detonator");
            RuntimeServices.SetProperty(component, "size", 1);
            AudioSource.PlayClipAtPoint(this.miniExplosionSound, this.get_transform().get_position(), 0.5f);
            Object.Destroy(this.get_gameObject());
        }
        if (asteroid == null)
        {
            Asterpinata asterpinata = (Asterpinata)other.get_transform().GetComponent(typeof(Asterpinata));
            if (asterpinata != null)
            {
                MonoBehaviour.print("BEAM TRIGGER ENTER name = " + other.get_name());
                asterpinata.Hit();
                GameObject gameObject = (GameObject)Object.Instantiate(this.miniExplosion, this.get_transform().get_position(), this.get_transform().get_rotation());
                object     component  = gameObject.GetComponent("Detonator");
                RuntimeServices.SetProperty(component, "size", 1);
                AudioSource.PlayClipAtPoint(this.miniExplosionSound, this.get_transform().get_position(), 0.5f);
                Object.Destroy(this.get_gameObject());
            }
        }
        StarPinata starPinata = (StarPinata)other.get_transform().GetComponent(typeof(StarPinata));

        if (starPinata != null)
        {
            MonoBehaviour.print("BEAM TRIGGER ENTER name = " + other.get_name());
            starPinata.Hit();
            GameObject gameObject = (GameObject)Object.Instantiate(this.miniExplosion, this.get_transform().get_position(), this.get_transform().get_rotation());
            object     component  = gameObject.GetComponent("Detonator");
            RuntimeServices.SetProperty(component, "size", 1);
            AudioSource.PlayClipAtPoint(this.miniExplosionSound, this.get_transform().get_position(), 0.5f);
            Object.Destroy(this.get_gameObject());
        }
        YellowHardCandy yellowHardCandy = (YellowHardCandy)other.get_transform().GetComponent(typeof(YellowHardCandy));

        if (yellowHardCandy != null)
        {
            MonoBehaviour.print("BEAM TRIGGER ENTER name = " + other.get_name());
            if (yellowHardCandy.Hit() != 0)
            {
                GameObject gameObject = (GameObject)Object.Instantiate(this.miniExplosion, this.get_transform().get_position(), this.get_transform().get_rotation());
                object     component  = gameObject.GetComponent("Detonator");
                RuntimeServices.SetProperty(component, "size", 1);
                AudioSource.PlayClipAtPoint(this.miniExplosionSound, this.get_transform().get_position(), 0.5f);
                Object.Destroy(this.get_gameObject());
            }
        }
        Lolly lolly = (Lolly)other.get_transform().GetComponent(typeof(Lolly));

        if (lolly != null)
        {
            MonoBehaviour.print("BEAM TRIGGER ENTER name = " + other.get_name());
            if (lolly.Hit() != 0)
            {
                GameObject gameObject = (GameObject)Object.Instantiate(this.miniExplosion, this.get_transform().get_position(), this.get_transform().get_rotation());
                object     component  = gameObject.GetComponent("Detonator");
                RuntimeServices.SetProperty(component, "size", 1);
                AudioSource.PlayClipAtPoint(this.miniExplosionSound, this.get_transform().get_position(), 0.5f);
                Object.Destroy(this.get_gameObject());
            }
        }
        BlueWhistle blueWhistle = (BlueWhistle)other.get_transform().GetComponent(typeof(BlueWhistle));

        if (blueWhistle != null)
        {
            MonoBehaviour.print("BEAM TRIGGER ENTER name = " + other.get_name());
            if (blueWhistle.Hit() != 0)
            {
                GameObject gameObject = (GameObject)Object.Instantiate(this.miniExplosion, this.get_transform().get_position(), this.get_transform().get_rotation());
                object     component  = gameObject.GetComponent("Detonator");
                RuntimeServices.SetProperty(component, "size", 1);
                AudioSource.PlayClipAtPoint(this.miniExplosionSound, this.get_transform().get_position(), 0.5f);
                Object.Destroy(this.get_gameObject());
            }
        }
    }