public void Healing(EnemyStats enemyStats) { //GameObject instantiatedSpellFX = Instantiate(spellCastFX, animationHandler.transform); enemyStats.RestoreHP(50); Debug.Log("Heal Successful"); }
public override State Tick(EnemyManager enemyManager, EnemyStats enemyStats, EnemyAnimatorManager enemyAnimatorManager) { Vector3 targetDirection = enemyManager.currentTarget.transform.position - enemyManager.transform.position; float distanceFromTarget = Vector3.Distance(enemyManager.currentTarget.transform.position, enemyManager.transform.position); float viewableAngle = Vector3.Angle(targetDirection, enemyManager.transform.forward); phaseLimit = enemyStats.MaxHealth / 2; HandleRotateTowardsTarget(enemyManager); if (enemyManager.isInteracting && enemyManager.canDoCombo == false) { return(this); } else if (enemyManager.isInteracting && enemyManager.canDoCombo) { if (comboOnNextAttack) { comboOnNextAttack = false; //CUSTOM if (enemyManager.currentAttack.usingWeapon) { enemyAnimatorManager.anim.SetBool("isUsingWeapon", true); } if (!enemyManager.currentAttack.isLeft) { enemyAnimatorManager.anim.SetBool("isUsingRightHand", true); } else if (enemyManager.currentAttack.isLeft) { enemyAnimatorManager.anim.SetBool("isUsingLeftHand", true); } // enemyAnimatorManager.PlayTargetAnimation(enemyManager.currentAttack.actionAnimation, true); } } if (enemyManager.isPerformingAction) { return(lookForTargetState); } if (gameObject.tag == "Enemy") { if (enemyStats.CurrentHealth < phaseLimit && rageCount < 1) { enemyAnimatorManager.PlayTargetAnimation("Rage", true); enemyStats.RestoreHP(phaseLimit / 2); rageCount++; } } if (enemyManager.currentAttack != null) { //CUSTOM if (enemyManager.currentAttack.usingWeapon) { enemyAnimatorManager.anim.SetBool("isUsingWeapon", true); } if (!enemyManager.currentAttack.isLeft) { enemyAnimatorManager.anim.SetBool("isUsingRightHand", true); } else if (enemyManager.currentAttack.isLeft) { enemyAnimatorManager.anim.SetBool("isUsingLeftHand", true); } // //if we are too close to the enemy to perform current attack , get a new attack if (distanceFromTarget < enemyManager.currentAttack.minimumDistanceNeededToAttack) { return(this); } //if we are close enough to attack , then proceed else if (distanceFromTarget < enemyManager.currentAttack.maximumDistanceNeededToAttack) { //if our enemy is within our attacks viewable angle, we attack if (viewableAngle <= enemyManager.currentAttack.maximumAttackAngle && viewableAngle >= enemyManager.currentAttack.minimumAttackAngle) { if (enemyManager.currentRecoveryTime <= 0 && enemyManager.isPerformingAction == false) { enemyAnimatorManager.anim.SetFloat("Vertical", 0, 0.1f, Time.deltaTime); enemyAnimatorManager.anim.SetFloat("Horizontal", 0, 0.1f, Time.deltaTime); enemyAnimatorManager.PlayTargetAnimation(enemyManager.currentAttack.actionAnimation, true); enemyManager.isPerformingAction = true; RollForComboChance(enemyManager); if (enemyManager.currentAttack.canDoCombo && comboOnNextAttack) { enemyManager.currentAttack = enemyManager.currentAttack.comboAction; return(this); } else { enemyManager.currentRecoveryTime = enemyManager.currentAttack.recoveryTime; enemyManager.currentAttack = null; return(lookForTargetState); } } } } } else if (enemyManager.currentMagicAttack != null) { if (distanceFromTarget < enemyManager.currentMagicAttack.maximumDistanceNeededToAttack) { //if our enemy is within our attacks viewable angle, we attack if (viewableAngle <= enemyManager.currentMagicAttack.maximumAttackAngle && viewableAngle >= enemyManager.currentMagicAttack.minimumAttackAngle) { if (enemyManager.currentRecoveryTime <= 0 && enemyManager.isPerformingAction == false) { enemyAnimatorManager.anim.SetFloat("Vertical", 0, 0.1f, Time.deltaTime); enemyAnimatorManager.anim.SetFloat("Horizontal", 0, 0.1f, Time.deltaTime); enemyManager.currentMagicAttack.AttemptToCastSpell(enemyAnimatorManager); enemyManager.isPerformingAction = true; enemyManager.currentRecoveryTime = enemyManager.currentMagicAttack.recoveryTime; //enemyManager.currentMagicAttack = null; return(lookForTargetState); } else if (enemyManager.currentRecoveryTime > 0 && distanceFromTarget <= enemyManager.maximumAttackRange) { return(lookForTargetState); } } } } else { GetNewAttack(enemyManager); } return(lookForTargetState); }