Beispiel #1
0
    void Update()
    {
        if (!_birdBehaviour.isAlive)
        {
            return;
        }
        if (recentlyFlapped)
        {
            flapCooldown -= Time.deltaTime;
            if (flapCooldown <= 0)
            {
                recentlyFlapped = false;
            }
        }

        if (recentlyRolled)
        {
            rerollDelay -= Time.deltaTime;
            if (rerollDelay <= 0)
            {
                recentlyRolled = false;
            }
        }
        //First 2 methods return shouldFlap
        if (BetweenObstaclesAndFarFromTop())
        {
            _birdBehaviour.Flap(Random.Range(1, 1.25f));
        }
        else if (TooCloseToGround())
        {
            _birdBehaviour.Flap(Random.Range(1.25f, 1.5f));
        }
        else if (HasObstacleAhead())
        {
            if (HoleAbove())
            {
                if (!recentlyFlapped)
                {
                    recentlyFlapped = true;
                    flapCooldown    = Random.Range(0.2f, .7f);
                    _birdBehaviour.Flap(Random.Range(1.0f, 1.5f));
                }
            }
        }
        else if (!recentlyRolled && ShouldRandomFlap())
        {
            if (!recentlyFlapped)
            {
                recentlyFlapped = true;
                flapCooldown    = Random.Range(0.1f, .3f);
                _birdBehaviour.Flap(Random.Range(1.0f, 1.5f));
            }
        }
    }
Beispiel #2
0
    void Update()
    {
        if (recentlyFlapped)
        {
            flapCooldown -= Time.deltaTime;
            if (flapCooldown < 0)
            {
                recentlyFlapped = false;
            }
        }
        if (!recentlyFlapped && _audioMeasure.GetDB() >= GameSettings.minDBToFlap)
        {
            var mapped = _audioMeasure.GetDB().Remap(GameSettings.minDBToFlap, GameSettings.maxDB,
                                                     GameSettings.BaseFlapForce, GameSettings.MaxFlapForce);
            Debug.Log("DB: " + _audioMeasure.GetDB() + "-forcE:" + mapped);
            recentlyFlapped = true;
            flapCooldown    = GameSettings.PlayerFlapCooldown;


            _birdBehaviour.Flap(mapped);
            if (!LevelManager.Instance.levelStarted)
            {
                LevelManager.Instance.LevelStarted();
            }
        }
    }
Beispiel #3
0
 void Update()
 {
     if (Input.GetKeyDown(KeyCode.Space))
     {
         _birdBehaviour.Flap();
         if (!LevelManager.Instance.levelStarted)
         {
             LevelManager.Instance.LevelStarted();
         }
     }
 }