コード例 #1
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;
        }
    }
コード例 #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);
        int   i    = 0;
        float num6 = default(float);

        if (num4 < (float)5)
        {
            num4 = (float)5;
        }
        if (num5 < (float)4)
        {
            num5 = (float)5;
        }
        num4 = (float)(360 / this.radialDivisions);
        num5 = (this.outerRadius - this.innerRadius) / (float)this.arcDivisions;
        while (i < this.nLayers)
        {
            for (num2 = (float)0; num2 < (float)360; num2 += num4)
            {
                float num7 = this.worldSize * 0.5f;
                for (num3 = this.innerRadius; num3 < this.outerRadius; num3 += num5)
                {
                    int num8 = Random.Range(this.maxAsteroidSize, this.minAsteroidSize);
                    if (!this.manualVelocityScale)
                    {
                        this.velocityScale = (float)GameController.instance.gameLevel * 1.25f;
                    }
                    float num9  = num3 * Mathf.Cos(num2);
                    float num10 = num3 * Mathf.Sin(num2);
                    num6   = (float)(checked (i * 10));
                    num9  += Mathf.Lerp(-num7, num7, Random.get_value());
                    num6   = Mathf.Lerp(-this.worldSize, this.worldSize, Random.get_value());
                    num10 += this.offsetXYZ.get_Item(2) + Mathf.Lerp(-num7, num7, Random.get_value());
                    Renderer renderer = (Renderer)this.asteroidPrefab.GetComponent(typeof(Renderer));
                    float    num11    = (renderer.get_bounds().get_max() - renderer.get_bounds().get_min()).get_magnitude() * (float)num8 * 0.5f;
                    float    num12    = default(float);
                    bool     flag     = true;
                    if (num9 >= (float)0 && num10 >= (float)0)
                    {
                        num12 = Mathf.Atan2(Mathf.Abs(num10), Mathf.Abs(num9)) * 57.29578f;
                        if (num12 < (float)10)
                        {
                            flag = false;
                        }
                    }
                    else if (num9 >= (float)0 && num10 < (float)0)
                    {
                        num12 = Mathf.Atan2(Mathf.Abs(num10), Mathf.Abs(num9)) * 57.29578f;
                        if (num12 < (float)5)
                        {
                            flag = false;
                        }
                    }
                    if (!Physics.CheckSphere(new Vector3(num9, num6, num10), num11 * (float)2) && flag)
                    {
                        if (Random.Range(0, 2) == 0)
                        {
                            Asteroid asteroid = (Asteroid)Object.Instantiate(this.asteroidPrefab);
                            asteroid.get_transform().set_position(new Vector3(num9, num6, num10));
                            asteroid.get_transform().set_parent(this.get_transform());
                            asteroid.Setup((float)num8, this.velocityScale);
                        }
                        else
                        {
                            Asterpinata asterpinata = (Asterpinata)Object.Instantiate(this.asterpinataPrefab);
                            asterpinata.get_transform().set_position(new Vector3(num9, num6, num10));
                            asterpinata.get_transform().set_parent(this.get_transform());
                            asterpinata.Setup((float)num8, this.velocityScale / (float)5);
                        }
                        checked
                        {
                            num++;
                        }
                    }
                }
            }
            checked
            {
                i++;
            }
        }
        this.SpawnPowerUp();
        GameObject gameObject = GameObject.Find("Radar");

        UnityRuntimeServices.Invoke(gameObject.GetComponent(typeof(Radar)), "SetAsteroidDonutField", new object[]
        {
            this
        }, typeof(MonoBehaviour));
    }
コード例 #3
0
    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);
    }