public void UseItem() { if (currentReserve > 0 && !effectActive && GameObject.FindObjectOfType <ProgressTracker>().GameStillInSession()) { player = GameObject.FindObjectOfType <PlayerBehaviour>(); HealthBehavior playerHealth = player.GetComponent <HealthBehavior>(); switch (itemType) { case ItemType.healing: { if (player && playerHealth.GetCurrentHealth() > 0) { playerHealth.IncreaseHealth(potency); DecreaseCurrentReserveBy(1); DisplayEffect(player.transform); } } break; case ItemType.buff: { if (player && playerHealth.GetCurrentHealth() > 0) { /*int isDeadHash = Animator.StringToHash("Dead"); * AnimatorStateInfo info = player.GetPlayerAnimator().GetCurrentAnimatorStateInfo(0); * Debug.Log("Player's current int state is: " + info.fullPathHash); * Debug.Log("Player's dead animation state is: " + isDeadHash);*/ OffenseBehavior playerAtk = player.GetComponent <OffenseBehavior>(); playerAtk.BuffAttackPowerBy(potency, timeLengthOfEffect); effectActive = true; Invoke("EndOfEffect", timeLengthOfEffect + 0.5f); DecreaseCurrentReserveBy(1); } } break; case ItemType.damage: { enemy = GameObject.FindObjectOfType <EnemyBehaviour>(); HealthBehavior enemyHealth = enemy.GetComponent <HealthBehavior>(); if (enemy && playerHealth.GetCurrentHealth() > 0 && enemyHealth.GetCurrentHealth() > 0) { enemyHealth.ReduceHealth(potency); StartCoroutine(DisplayAndTrackEffect(enemy.transform)); DecreaseCurrentReserveBy(1); } } break; default: { Debug.Log("Item Type for this item was not specified."); } break; } } else { Debug.Log("Cannot use this Item anymore"); } }