Пример #1
0
    private void HandleBranchSpawning()
    {
        branchSpawnTimer -= Time.deltaTime;
        if (branchSpawnTimer < 0)
        {
            //spawn another branch
            branchSpawnTimer += branchSpawnTimerMax;              //reset timer
            float minWidth = Oscar.GetInstance().GetOscarWidth(); //set minimum branch width
            float maxWidth = GetCameraHalfWidth() * 2f -
                             Oscar.GetInstance().GetOscarWidth(); //set maximum branch width

            //set up single branch
            float width = Random.Range(minWidth, maxWidth);

            //set up branch pair
            float pairRightWidth = Random.Range(minWidth, maxWidth);
            float pairLeftWidth  = maxWidth - pairRightWidth;

            if (TryGeneratBranchPair() == true)
            {
                CreateBranchPair(pairRightWidth, pairLeftWidth, BRANCH_SPAWN_Y_POSITION);
                branchesSpawned++;
                branchesSpawned++;
            }
            else
            {
                CreateBranch(width, BRANCH_SPAWN_Y_POSITION, GetRandomBranchType());
                branchesSpawned++;
            }
            SetDifficulty(GetDifficulty());
        }
    }
Пример #2
0
    private void HandleBranchMovement() //branches are moving while Oscar always remains in the same position on the y-axis
    {
        for (int i = 0; i < branchList.Count; i++)
        {
            Branch branch = branchList[i];

            //check that branches have not moved below Oscar before moving
            bool branchIsaboveOscar = branch.GetYPosition() > Oscar.GetInstance().GetOscarYPosition();
            branch.Move();

            //check if branch that was previously above Oscar is now below him
            if (branchIsaboveOscar && branch.GetYPosition() < Oscar.GetInstance().GetOscarYPosition())
            {
                branchesPassed++;
                //SoundManager.PlaySound(SoundManager.Sound.Score);
                SoundManager.PlaySound(SoundManager.Sound.Bark);
            }
            if (branch.GetYPosition() < BRANCH_DESTROY_Y_POSITION)
            {
                //Destroy branch
                branch.DestroySelf();
                branchList.Remove(branch);
                i--;
            }
        }
    }
Пример #3
0
 private void Start()
 {
     highscoreText.text = "HIGHSCORE: " + Score.GetHighScore().ToString();
     Hide();
     Oscar.GetInstance().OnStartPlaying += ScoreWindow_OnStartPlaying;
     Oscar.GetInstance().OnHit          += ScoreWindow_OnHit;
 }
Пример #4
0
    private void SetDifficulty(Difficulty difficulty)
    {
        switch (difficulty)
        {
        case Difficulty.Easy:
            branchSpawnTimerMax = 1.6f;
            break;

        case Difficulty.Medium:
            branchSpawnTimerMax = 1.4f;
            cloudMoveSpeed      = MOVE_SPEED * 0.3f;
            cloudSpawnTimerMax  = 2.6f;
            break;

        case Difficulty.Hard:
            branchSpawnTimerMax = 1.2f;
            cloudMoveSpeed      = MOVE_SPEED * 0.4f;
            cloudSpawnTimerMax  = 2.2f;
            break;

        case Difficulty.Brutal:
            branchSpawnTimerMax = 1.0f;
            cloudMoveSpeed      = MOVE_SPEED * 0.5f;
            cloudSpawnTimerMax  = 1.9f;
            break;

        case Difficulty.Nightmare1:
            branchSpawnTimerMax = 0.8f;
            cloudMoveSpeed      = MOVE_SPEED * 0.6f;
            cloudSpawnTimerMax  = 1.6f;
            //make Oscar faster as branch spawn time gets smaller
            Oscar.GetInstance().SetOscarMoveSpeed(40f);
            break;

        case Difficulty.Nightmare2:
            branchSpawnTimerMax = 0.6f;
            cloudMoveSpeed      = MOVE_SPEED * 0.8f;
            cloudSpawnTimerMax  = 1.3f;
            break;

        case Difficulty.Nightmare3:
            Oscar.GetInstance().SetOscarMoveSpeed(100f);
            branchSpawnTimerMax = 0.5f;
            cloudMoveSpeed      = MOVE_SPEED * 0.9f;
            cloudSpawnTimerMax  = 1.0f;
            break;

        case Difficulty.Impossible:
            Oscar.GetInstance().SetOscarMoveSpeed(200f);
            branchSpawnTimerMax = 0.45f;
            cloudMoveSpeed      = MOVE_SPEED;
            cloudSpawnTimerMax  = 0.8f;
            break;
        }
    }
Пример #5
0
 private void Start()
 {
     Oscar.GetInstance().OnHit          += Oscar_OnHit;
     Oscar.GetInstance().OnStartPlaying += Oscar_OnStartPlaying;
 }
Пример #6
0
 public static void Start()
 {
     Oscar.GetInstance().OnHit += Oscar_OnHit;
 }
Пример #7
0
 private void Start()
 {
     Oscar.GetInstance().OnHit += Oscar_OnHit;
     Hide();
 }
Пример #8
0
 private void Start()
 {
     Oscar.GetInstance().OnStartPlaying += WaitingToStartWindow_OnStartPlaying;
 }