예제 #1
0
    // Update is called once per frame
    void Update()
    {
        if (GameManager.Instance.Pause)
        {
            this.rgdBdy.gravityScale = 0.0f;
            this.rgdBdy.velocity     = Vector2.zero;
            return;
        }

        addForce = false;
        if (!moveToHive)
        {
            if (!harvesting && !_dmgEffect.Invincible())
            {
                if (Input.GetKey(KeyCode.W))
                {
                    addForce = true;

                    if (firstAction)
                    {
                        firstAction = false;
                        TimeOfDayManager.Instance.StartDay();
                        ScrollManager.Instance.ResumeScroll();
                        rgdBdy.gravityScale = 1.0f;
                    }
                }
            }
            else if (harvesting)
            {
                harvestElapsed += Time.deltaTime;
                _currentNectar  = Mathf.Clamp(_currentNectar + Time.deltaTime * nectarPerSecond, 0f, maxNectar);
                if (harvestElapsed >= harvestTime)
                {
                    ScrollManager.Instance.ResumeScroll();
                    rgdBdy.gravityScale = 1.0f;
                    rgdBdy.AddForce(Vector2.up * 5.0f, ForceMode2D.Impulse);
                    harvesting     = false;
                    harvestElapsed = 0.0f;
                    _animator.SetBool("Eating", false);
                }
            }
        }

        transform.eulerAngles = new Vector3(0f, 0f, Mathf.LerpUnclamped(-35.0f, 35.0f, (rgdBdy.velocity.y + MAX_VELOCITY) / (MAX_VELOCITY * 2.0f)));
    }