Beispiel #1
0
    private void GetNewBlock()
    {
        if (!tutorialCompleted)
        {
            tutorialCount++;

            if (tutorialCount == 2)
            {
                tutorialManager.DisplayArrowTutorial();
            }
            else if (tutorialCount == 6)
            {
                tutorialManager.DisplayChargeTutorial();
            }
            else if (tutorialCount == 7)
            {
                tutorialManager.DisplayStaminaTutorial();
            }
            else if (tutorialCount == 9)
            {
                tutorialManager.SetTutorialCompleted();
                tutorialCompleted = true;
            }
        }

        LevelBlock _newBlock = null;

        if (staminaSpawnCounter >= currentStaminaSpawn)
        {
            _newBlock           = levelBlockPooler.GetLevelBlock(BlockDifficulty.Stamina);
            staminaSpawnCounter = 0;
            currentStaminaSpawn = GenerateStaminaSpawnNumber();
        }
        else if (powerUpSpawnCounter >= currentPowerUpSpawn)
        {
            _newBlock           = levelBlockPooler.GetPowerUpBlock(avaliableUpgrades);
            powerUpSpawnCounter = 0;
            currentPowerUpSpawn = GeneratePowerUpSpawnNumber();
        }
        else
        {
            _newBlock = DetermineBlock(currentDifficulty);
        }

        _newBlock.gameObject.SetActive(true);
        _newBlock.InitializeBlock(CollectableCallback, numBlocksGenerated, coinSpinTime);
        _newBlock.SetPosition(levelBlocks[levelBlocks.Count - 1].GetPosition() + (Vector3.forward * levelBlockSize));
        _newBlock.SetSpeed(currentBlockSpeed);
        levelBlocks.Add(_newBlock);
        levelBlocks.RemoveAt(0);
        numBlocksGenerated++;
        blocksPassed++;
        totalBlocksPassed++;
        staminaSpawnCounter++;
        powerUpSpawnCounter++;

        if (blocksPassed >= difficultyThreshold)
        {
            blocksPassed = 0;
            IncreaseDifficulty();
        }

        if (OnBlockPassed != null)
        {
            OnBlockPassed();
        }

        IncreaseSpeed();
    }