예제 #1
0
    public void SpawnRandomCollectable()
    {
        if (Random.value <= collectableChance)
        {
            if (!(powerUpController.powerUpActive) && (GameObject.FindGameObjectWithTag("Collectable") == null))
            {
                float r = Random.value;

                if (r > 0.70f)
                {
                    newCollectable = Collectable.CreateSpeed();
                }
                else if (r > 0.35f)
                {
                    newCollectable = Collectable.CreateIncrease();
                }
                else if (r > 0.05f)
                {
                    newCollectable = Collectable.CreateDecrease();
                }
                else
                {
                    newCollectable = Collectable.CreateDeath();
                }

                if (equalPowerUps)
                {
                    newCollectable.gameObject.transform.position = new Vector3(-100.0f, Random.Range(boundsBottom, boundsTop), 0.0f);
                    this.MoveCollectable(new Vector2(-1, 0), newCollectable);
                    equalPowerUps = false;
                }
                else
                {
                    newCollectable.gameObject.transform.position = new Vector3(100.0f, Random.Range(boundsBottom, boundsTop), 0.0f);
                    this.MoveCollectable(new Vector2(1, 0), newCollectable);
                    equalPowerUps = true;
                }
            }
        }
    }