public void SuccessfullyCastSpell(
            EnemyAnimatorManager animationHandler,
            EnemyManager enemyManager,
            EnemyWeaponSlotManager weaponSlotManager)
        {
            GameObject instantiatedSpellFX = Instantiate(spellCastFX, weaponSlotManager.rightHandSlot.transform.position,
                                                         Quaternion.identity);

            rigidbody = instantiatedSpellFX.GetComponent <Rigidbody>();

            //aiming spell angle w/ or w/o lock on
            if (enemyManager.currentTarget != null)
            {
                instantiatedSpellFX.transform.LookAt(enemyManager.currentTarget.transform);
            }
            else
            {
                instantiatedSpellFX.transform.rotation = Quaternion.Euler(enemyManager.transform.eulerAngles.x, enemyManager.transform.eulerAngles.y, 0);
            }

            rigidbody.AddForce(instantiatedSpellFX.transform.forward * projectileForwardVelocity);
            rigidbody.AddForce(instantiatedSpellFX.transform.up * projectileUpwardVelocity);
            rigidbody.useGravity = isEffectedByGravity;
            rigidbody.mass       = projectileMass;
            instantiatedSpellFX.transform.parent = null;
        }
示例#2
0
        // Start is called before the first frame update
        private void Awake()
        {
            enemyLocomotionManager = GetComponent <EnemyLocomotionManager>();
            enemyAnimatorManager   = GetComponentInChildren <EnemyAnimatorManager>();
            enemyFXManager         = GetComponentInChildren <EnemyFXManager>();
            enemyStats             = GetComponent <EnemyStats>();
            enemyRigidbody         = GetComponent <Rigidbody>();

            //backStabCollider = GetComponentInChildren<DeathblowsCollider>();
            navMeshAgent         = GetComponentInChildren <NavMeshAgent>();
            navMeshAgent.enabled = false;
        }
        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.SignedAngle(targetDirection, enemyManager.transform.forward, Vector3.up);

            HandleRotateTowardsTarget(enemyManager);

            /*if (viewableAngle > 65 || viewableAngle < -65)
             *  return lookForTargetState;*/

            if (enemyManager.isInteracting)
            {
                return(this);
            }

            if (enemyManager.isPerformingAction)
            {
                enemyAnimatorManager.anim.SetFloat("Vertical", 0, 0.1f, Time.deltaTime);
                return(this);
            }

            if (distanceFromTarget > enemyManager.maximumAttackRange)
            {
                if (gameObject.tag == "Boss")
                {
                    enemyAnimatorManager.anim.SetFloat("Vertical", 0.4f, 0.1f, Time.deltaTime);
                }
                else if (gameObject.tag == "Slow Mob")
                {
                    enemyAnimatorManager.anim.SetFloat("Vertical", 0.6f, 0.1f, Time.deltaTime);
                }
                else
                {
                    enemyAnimatorManager.anim.SetFloat("Vertical", 1, 0.1f, Time.deltaTime);
                }

                //if performing some action , stop all movement on the pursuit state
            }

            if (distanceFromTarget <= enemyManager.maximumAttackRange)
            {
                return(combatStanceState);
            }
            else
            {
                return(this);
            }
        }
示例#4
0
        public override State Tick(EnemyManager enemyManager, EnemyStats enemyStats, EnemyAnimatorManager enemyAnimatorManager)
        {
            if (isSleeping && enemyManager.isInteracting == false)
            {
                enemyAnimatorManager.PlayTargetAnimation(sleepAnimation, true);
            }

            #region Handle Target Detection
            Collider[] colliders = Physics.OverlapSphere(enemyManager.transform.position, detectionRadius, detectionLayer);

            for (int i = 0; i < colliders.Length; i++)
            {
                //search all colliders finds for a player manager variable
                CharacterStats characterStats = colliders[i].transform.GetComponent <CharacterStats>();

                //if its finds it , continue the logic

                if (characterStats != null)
                {
                    Vector3 targetDirection = characterStats.transform.position - enemyManager.transform.position;
                    float   viewableAngle   = Vector3.Angle(targetDirection, enemyManager.transform.forward);

                    if (viewableAngle > enemyManager.minimumDetectionAngle && viewableAngle < enemyManager.maximumDetectionAngle)
                    {
                        enemyManager.currentTarget = characterStats;
                        isSleeping = false;

                        enemyAnimatorManager.PlayTargetAnimation(wakeAnimation, true);
                    }
                }
            }

            #endregion

            #region Handle State Change

            if (enemyManager.currentTarget != null)
            {
                return(pursueTargetState);
            }
            else
            {
                return(this);
            }
            #endregion
        }
        public override State Tick(EnemyManager enemyManager, EnemyStats enemyStats, EnemyAnimatorManager enemyAnimatorManager)
        {
            if (enemyManager.isInteracting)
            {
                return(this);
            }
            if (playerManager.isUsingRightHand)
            {
                int ran = Random.Range(0, 100);
                if (ran < 90)
                {
                    enemyAnimatorManager.PlayTargetAnimation("Rolling", true);
                }
            }

            // Check for attack range

            //walk around target

            float distanceFromTarget = Vector3.Distance(enemyManager.currentTarget.transform.position, enemyManager.transform.position);

            Debug.Log(distanceFromTarget);
            HandleRotateTowardsTarget(enemyManager);

            if (enemyManager.isPerformingAction)
            {
                //after atk return to combat state
                enemyAnimatorManager.anim.SetFloat("Vertical", 0, 0.1f, Time.deltaTime);
            }

            if (enemyManager.currentRecoveryTime <= 0 && distanceFromTarget <= enemyManager.maximumAttackRange)
            {
                return(attackState);
                // if still in the atk range , return atk state
            }
            else if (distanceFromTarget > enemyManager.maximumAttackRange)
            {
                return(pursueTargetState);
                //in cooldown attacking , return this state and continue focus player
            }
            else
            {
                return(this);
                //fail safe
            }
        }
        private void Awake()
        {
            enemyManager  = GetComponentInParent <EnemyManager>();
            enemyStats    = GetComponentInParent <EnemyStats>();
            enemyAnimator = GetComponent <EnemyAnimatorManager>();

            WeaponHolderSlot[] weaponHolderSlots = GetComponentsInChildren <WeaponHolderSlot>();
            foreach (WeaponHolderSlot weaponSlot in weaponHolderSlots)
            {
                if (weaponSlot.isLeftHandSlot)
                {
                    leftHandSlot = weaponSlot;
                }
                else if (weaponSlot.isRightHandSlot)
                {
                    rightHandSlot = weaponSlot;
                }
            }
        }
        public override State Tick(EnemyManager enemyManager, EnemyStats enemyStats, EnemyAnimatorManager enemyAnimatorManager)
        {
            enemyAnimatorManager.anim.SetFloat("Vertical", 0);
            enemyAnimatorManager.anim.SetFloat("Horizontal", 0);

            Vector3 targetDirection = enemyManager.currentTarget.transform.position - enemyManager.transform.position;
            float   viewableAngle   = Vector3.SignedAngle(targetDirection, enemyManager.transform.forward, Vector3.up);

            if (enemyManager.isInteracting)
            {
                return(this); // when we enter the state we will still be interacting from the attack animation so we pause here until it has finished
            }
            //these if conditions values can tune up
            if (viewableAngle >= 100 && viewableAngle <= 180 && !enemyManager.isInteracting)
            {
                enemyAnimatorManager.PlayTargetAnimationWithRootRotation("Turn Behind", true);
                Debug.Log("Turn 180");
                return(combatStanceState);
            }
            else if (viewableAngle <= -101 && viewableAngle >= -180 && !enemyManager.isInteracting)
            {
                enemyAnimatorManager.PlayTargetAnimationWithRootRotation("Turn Behind", true);
                Debug.Log("Turn 180");
                return(combatStanceState);
            }
            else if (viewableAngle <= -45 && viewableAngle >= -100 && !enemyManager.isInteracting)
            {
                enemyAnimatorManager.PlayTargetAnimationWithRootRotation("Turn Right", true);
                Debug.Log("Turn Right");
                return(combatStanceState);
            }
            else if (viewableAngle >= 45 && viewableAngle <= 100 && !enemyManager.isInteracting)
            {
                enemyAnimatorManager.PlayTargetAnimationWithRootRotation("Turn Left", true);
                Debug.Log("Turn Left");
                return(combatStanceState);
            }

            return(combatStanceState);
        }
示例#8
0
        public override State Tick(EnemyManager enemyManager, EnemyStats enemyStats, EnemyAnimatorManager enemyAnimatorManager)
        {
            // Look for target
            #region Target Detection

            Collider[] colliders = Physics.OverlapSphere(transform.position, enemyManager.detectionRadius, detectionLayer);

            for (int i = 0; i < colliders.Length; i++)
            {
                CharacterStats characterStats = colliders[i].transform.GetComponent <CharacterStats>();

                if (characterStats != null)
                {
                    //check ID

                    Vector3 targetDirection = characterStats.transform.position - transform.position;
                    float   viewableAngle   = Vector3.Angle(targetDirection, transform.forward);

                    if (viewableAngle > enemyManager.minimumDetectionAngle && viewableAngle < enemyManager.maximumDetectionAngle)
                    {
                        enemyManager.currentTarget = characterStats;
                    }
                }
            }
            #endregion

            #region Switch State
            if (enemyManager.currentTarget != null)
            {
                //Switch state when found the target
                return(pursueTargetState);
            }
            else
            {
                //if not , return to this state
                return(this);
            }
            #endregion
        }
 public void AttemptToCastSpell(
     EnemyAnimatorManager animationHandler)
 {
     animationHandler.PlayTargetAnimation(actionAnimation, true);
 }
示例#10
0
        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);
        }
示例#11
0
 public abstract State Tick(EnemyManager enemyManager, EnemyStats enemyStats, EnemyAnimatorManager enemyAnimatorManager);
示例#12
0
 private void Awake()
 {
     enemyManager         = GetComponent <EnemyManager>();
     enemyAnimatorManager = GetComponentInChildren <EnemyAnimatorManager>();
 }
示例#13
0
 private void Awake()
 {
     enemyAnimatorManager = GetComponentInChildren <EnemyAnimatorManager>();
     maxHealth            = SetMaxHealthFromHealthLevel();
     CurrentHealth        = maxHealth;
 }