void Start()
    {
        allObstaclesAreDestroyed = false;
        normalObstacleMode       = true;
        oMS            = obstacle.GetComponent <ObstacleMovementScript>();
        oMS.speed      = obstacleSpeed;
        oMS.shadowTime = obstacleChargingTime;

        InvokeRepeating //wywoluje funkcje co okreslony czas w sekundach
            ("IncreaseChanceForDubleObstacle", regularIncreasingDubleObstacleChanceTime, regularIncreasingDubleObstacleChanceTime);

        //obliczenia miejsc spawnu przeszkod
        float cameraWidth = Camera.main.pixelWidth;

        leftSpawnPoint     = new Vector3(0, 0, 10);
        rightSpawnPoint    = new Vector3(cameraWidth, 0, 10);
        leftSpawnPoint     = Camera.main.ScreenToWorldPoint(leftSpawnPoint);
        rightSpawnPoint    = Camera.main.ScreenToWorldPoint(rightSpawnPoint);
        leftSpawnPoint.x   = leftSpawnPoint.x + offSet;
        rightSpawnPoint.x  = rightSpawnPoint.x - offSet;
        leftSpawnPoint.y   = 0;
        rightSpawnPoint.y  = 0;
        leftSpawnPoint2.x  = leftSpawnPoint.x - 15 * offSet;
        rightSpawnPoint2.x = rightSpawnPoint.x + 15 * offSet;
        //spawnowanie pierwszej przeszkody
        StartCoroutine(Waiting());

        increasingObstacleSpeedUnit = (maxObstacleSpeed - obstacleSpeed) / speedIncreasingTimesTab.Length;
    }
示例#2
0
    void SpawnObstacle()
    {
        float      rng = Random.value;
        GameObject instantiatedObject  = null;
        int        speedUpTimeMultiple = (int)Mathf.Ceil(speedUpTimer / speedUpInterval);

        if (speedUpTimeMultiple > speedUpMultipleCap)
        {
            speedUpTimeMultiple = speedUpMultipleCap;
        }

        if (rng < 0.5f)
        {
            InstantiateCapsule(5);
            restPeriod = 5f;
        }
        else if (rng < 0.6f)
        {
            instantiatedObject = Instantiate(twoWall, gameObject.transform.position, new Quaternion());
            restPeriod         = 3f;
        }
        else if (rng < 0.68f)
        {
            instantiatedObject = Instantiate(threeWall, gameObject.transform.position, new Quaternion());
            restPeriod         = 3f;
        }
        else if (rng < 0.78f)
        {
            instantiatedObject = Instantiate(fourWall, gameObject.transform.position, new Quaternion());
            restPeriod         = 3f;
        }
        else if (rng < 0.86f)
        {
            instantiatedObject = Instantiate(diamond, gameObject.transform.position, new Quaternion());
            restPeriod         = 7f;
        }
        else if (rng < 0.95f)
        {
            instantiatedObject = Instantiate(doubleV, gameObject.transform.position, new Quaternion());
            restPeriod         = 7f;
        }
        else
        {
            instantiatedObject = Instantiate(xObstacle, gameObject.transform.position, new Quaternion());
            restPeriod         = 6f;
        }

        if (instantiatedObject)
        {
            ObstacleMovementScript obsMovement = instantiatedObject.GetComponent <ObstacleMovementScript>();
            obsMovement.speed = obsMovement.speed * (speedUpMultiplier * speedUpTimeMultiple / 1.35f);
        }
        lastObstacleSpawnTime = Time.time;
        restPeriod            = restPeriod / ((speedUpTimeMultiple == 0 ? 1 : speedUpTimeMultiple) * 1.2f);
    }