コード例 #1
0
    // ======================================================================================
    private void UpdateAnimator()
    {
        m_animator.SetDirection(m_states[m_actualState].m_facingDir);
        if (m_states[m_actualState].m_attack)
        {
            m_animator.StartAttack(m_states[m_actualState].m_attkType, m_states[m_actualState].m_upAttkDir, false);
            if (m_watcherToShowWeapon != null)
            {
                switch (m_states[m_actualState].m_attkType)
                {
                case PlayerAnimatorController.eAttackType.Fists:
                    m_watcherToShowWeapon.Drop();
                    break;

                case PlayerAnimatorController.eAttackType.Saber:
                    m_watcherToShowWeapon.PickSaber();
                    break;

                case PlayerAnimatorController.eAttackType.Pistol:
                    m_watcherToShowWeapon.PickPistol();
                    break;
                }
            }
        }
        else
        {
            m_animator.SetState(m_states[m_actualState].m_state);
        }
    }
コード例 #2
0
    // ======================================================================================
    public void Update()
    {
#if UNITY_EDITOR
        m_useAnimation = m_animator != null;

        if (!Application.isPlaying)
        {
            return;
        }
#endif
        if (GameMgr.IsGameOver)
        {
            return;
        }

        float horizontal = 0, vertical = 0;
        bool  doJump = false, doDash = false;

        if (!isStunned)
        {
            // get input
            horizontal = InputMgr.GetAxis((int)m_player, InputMgr.eAxis.HORIZONTAL);          //Input.GetAxis("Horizontal");
            vertical   = InputMgr.GetAxis((int)m_player, InputMgr.eAxis.VERTICAL);            //Input.GetAxis("Vertical");
            doJump     = InputMgr.GetButton((int)m_player, InputMgr.eButton.JUMP);            //Input.GetButtonDown("Jump");
            doDash     = InputMgr.GetButton((int)m_player, InputMgr.eButton.DASH);            //Input.GetButtonDown("Dash");

            // get pick up item input
            if (InputMgr.GetButton((int)m_player, InputMgr.eButton.GRAB) && !grabButtonPressed)
            {
                if (WeaponList.Count > 0)
                {
                    PickupWeapon();
                }
            }
            grabButtonPressed = InputMgr.GetButton((int)m_player, InputMgr.eButton.GRAB);

            // get throw item input
            if (InputMgr.GetButton((int)m_player, InputMgr.eButton.TOSS))
            {
                if (EquippedWeapon != WeaponPickup.WeaponType.FISTS)
                {
                    ThrowWeapon();
                }
            }

            // get attack input
            if (InputMgr.GetButton((int)m_player, InputMgr.eButton.ATTACK) && !isAttacking)
            {
                isAttacking = true;
                switch (EquippedWeapon)
                {
                case WeaponPickup.WeaponType.FISTS:
                    PunchAttack();
                    break;

                case WeaponPickup.WeaponType.SABER:
                    SaberAttack();
                    break;

                case WeaponPickup.WeaponType.PISTOL:
                    PistolAttack();
                    break;
                }
            }
        }

        // update position
        UpdateTransform(horizontal, vertical, doJump, doDash);



        // OBS: UptadeAnimator MAYBE is OUT OF DATE!!!!
        // TODO: Test with anims and update if necessary
        if (m_useAnimation)
        {
            m_animator.SetState(m_state);
            m_animator.SetDirection(m_direction);
        }
    }
コード例 #3
0
    // ======================================================================================
    private void UpdateAnimator()
    {
        switch (State)
        {
        case eStates.Attack:

            switch (m_playerAttack.EquipWeap)
            {
            case PlayerAttack.eWeapon.Fists:
                m_playerAnimCtl.StartAttack(PlayerAnimatorController.eAttackType.Fists, m_playerAttack.AttackDirection.y, m_playerCtl.IsJumping);
                break;

            case PlayerAttack.eWeapon.Pistol:
                m_playerAnimCtl.StartAttack(PlayerAnimatorController.eAttackType.Pistol, m_playerAttack.AttackDirection.y, m_playerCtl.IsJumping);
                break;

            case PlayerAttack.eWeapon.Saber:
                m_playerAnimCtl.StartAttack(PlayerAnimatorController.eAttackType.Saber, m_playerAttack.AttackDirection.y, m_playerCtl.IsJumping);
                break;
            }
            break;

        case eStates.Idle:
            m_playerAnimCtl.SetState(PlayerAnimatorController.eStates.Idle);
            break;

        case eStates.Walking:
            m_playerAnimCtl.SetState(PlayerAnimatorController.eStates.Walking);
            break;

        case eStates.Jumping:
            m_playerAnimCtl.SetState(PlayerAnimatorController.eStates.Jumping);
            break;

        case eStates.Falling:
            m_playerAnimCtl.SetState(PlayerAnimatorController.eStates.Falling);
            break;

        case eStates.WallSliding:
            m_playerAnimCtl.SetState(PlayerAnimatorController.eStates.WallSliding);
            break;

        case eStates.WallEjecting:
            m_playerAnimCtl.SetState(PlayerAnimatorController.eStates.WallEjecting);                 // TO DO : Wall Eject
            break;

        case eStates.Dashing:
            m_playerAnimCtl.SetState(PlayerAnimatorController.eStates.Dashing);
            break;

        case eStates.Dead:
            m_playerAnimCtl.SetState(PlayerAnimatorController.eStates.Dead);
            break;

        case eStates.Stunned:
            m_playerAnimCtl.SetState(PlayerAnimatorController.eStates.Stunned);
            break;
        }

        switch (m_playerCtl.ForwardDir)
        {
        case PlayerController.eDirection.Left:
            m_playerAnimCtl.SetDirection(PlayerAnimatorController.eDirections.Left);
            break;

        case PlayerController.eDirection.Right:
            m_playerAnimCtl.SetDirection(PlayerAnimatorController.eDirections.Right);
            break;
        }
    }