// ----------------------------------------------------------------------- **

    private void Start()
    {
        hudManager        = HudManager.Singleton;
        stateAnim         = StateAnimation.close;
        canvasGroup       = GetComponent <CanvasGroup>();
        canvasGroup.alpha = 0f;

        hoverSlotTime = 0f;
    }
Esempio n. 2
0
    void Update()
    {
        _direction = Input.GetAxis("Horizontal");
        Move(_direction);
        if (_direction != 0)
        {
            _stateAnimation = StateAnimation.move;
        }
        else
        {
            _stateAnimation = StateAnimation.stay;
        }

        //Добавить условие для вызова Interaction()

        #region Jump
        if (Physics2D.OverlapCircle(_groundCheckPosition.position, _radiusGroundCheck, _ground))
        {
            _canJump = true;
        }
        else
        {
            _canJump = false;
        }

        if (Input.GetKeyDown(KeyCode.Space) && _canJump)
        {
            _currentJumpTime = 0;
        }

        if (Input.GetKey(KeyCode.Space))
        {
            if (_rb.velocity.y >= 0)
            {
                _rb.velocity = new Vector2(_rb.velocity.x, -1 * (Mathf.Pow(_currentJumpTime, 2) * _speedJumpUp) + _jumpHeight);
            }
        }

        if (_rb.velocity.y < 0)
        {
            _rb.velocity = new Vector2(_rb.velocity.x, _rb.velocity.y * _speedFall);
        }

        _currentJumpTime += Time.deltaTime;
        #endregion

        //PlayAnimation();
    }
    // ----------------------------------------------------------------------- **

    private void UpdateAnim()
    {
        if (stateAnim == StateAnimation.opening)
        {
            canvasGroup.alpha += Time.deltaTime;
            if (canvasGroup.alpha >= 1)
            {
                canvasGroup.alpha = 1;
                stateAnim         = StateAnimation.open;
                AllowSlotsUpdate(true);
            }
        }
        else if (stateAnim == StateAnimation.closing)
        {
            canvasGroup.alpha -= Time.deltaTime;
            if (canvasGroup.alpha <= 0)
            {
                canvasGroup.alpha = 0;
                stateAnim         = StateAnimation.close;
            }
        }
    }
    // ----------------------------------------------------------------------- **

    public void Close()
    {
        stateAnim = StateAnimation.closing;
        AllowSlotsUpdate(false);
    }
    // ----------------------------------------------------------------------- **

    public void Open()
    {
        stateAnim = StateAnimation.opening;
        GameManager.Singleton.inputControler.OpenMerchant();
    }
Esempio n. 6
0
 private void Interaction()
 {
     _stateAnimation = StateAnimation.interraction;
 }