Exemple #1
0
    public void HandleWeaponCombo(WeaponItem weapon)
    {
        if (inputHandler.comboFlag)
        {
            animHandler.SetAnimBool(PlayerAnimatorHandler.hashCanCombo, false);

            string attack = null;
            if (lastAttack == weapon.oneHandLightAttack1)
            {
                attack = weapon.oneHandLightAttack2;
            }
            else if (lastAttack == weapon.oneHandLightAttack2)
            {
                attack = weapon.oneHandLightAttack3;
            }
            else if (lastAttack == weapon.twoHandLightAttack1)
            {
                attack = weapon.twoHandLightAttack2;
            }

            if (attack == null)
            {
                throw new System.NullReferenceException();
            }
            animHandler.PlayTargetAnimation(attack, true);
            lastAttack = attack;
        }
    }
Exemple #2
0
    public override void TakeDamage(int damage)
    {
        if (currentHealth <= 0)
        {
            return;
        }
        currentHealth = Mathf.Clamp(currentHealth - damage, 0, maxHealth);

        healthbar?.SetFill(currentHealth, maxHealth);

        if (currentHealth <= 0)
        {
            currentHealth = 0;
            animHandler.PlayTargetAnimation(PlayerAnimatorHandler.hashDeath1, true);
            //TODO: Handle player death
        }
        else
        {
            animHandler.PlayTargetAnimation(PlayerAnimatorHandler.hashDamage1, true);
        }
    }
Exemple #3
0
    public void HandleRollingAndSprinting(float delta)
    {
        if (playerManager.isInteracting)
        {
            return;
        }

        if (inputHandler.rollFlag)
        {
            moveDirection  = cameraObject.forward * inputHandler.vertical;
            moveDirection += cameraObject.right * inputHandler.horizontal;

            if (inputHandler.moveAmount > 0f)
            {
                animHandler.PlayTargetAnimation(PlayerAnimatorHandler.hashRoll, true);

                moveDirection.y = 0f;
                Quaternion rollRotation = Quaternion.LookRotation(moveDirection);
                transform.rotation = rollRotation;
            }
            else
            {
                animHandler.PlayTargetAnimation(PlayerAnimatorHandler.hashBackstep, true);
            }
        }
    }
Exemple #4
0
    private void PickUpWeapon(PlayerManager playerManager)
    {
        PlayerInventory       playerInventory  = playerManager.GetComponent <PlayerInventory>();
        PlayerLocomotion      playerLocomotion = playerManager.GetComponent <PlayerLocomotion>();
        PlayerAnimatorHandler animatorHandler  = playerManager.GetComponentInChildren <PlayerAnimatorHandler>();

        playerLocomotion.rigid.velocity = Vector3.zero;
        animatorHandler.PlayTargetAnimation(PlayerAnimatorHandler.hashPickUpItem, true);
        playerInventory.weaponsInventory.Add(weapon);

        playerManager.itemInteractableGO.SetActive(true);
        playerManager.itemInteractableGO.GetComponentInChildren <UnityEngine.UI.Text>().text = weapon.name;

        Destroy(gameObject);
    }