Example #1
0
        //Attacks Occur on Left Mouse Click--------------------------------------
        private void OnLeftMouseClickAttack(NPCAi enemy)
        {
            GameObject enemyObj = enemy.gameObject;

            if (specialAbilities.isAbilitySelected == false)
            {
                if (Input.GetMouseButtonDown(0) && weaponSystem.IsTargetInAttackRange(enemyObj) == true)
                {
                    weaponSystem.AttackTarget(enemyObj);
                }

                else if (weaponSystem.GetWeaponInUse().isBowInUse == false && Input.GetMouseButtonDown(0) && weaponSystem.IsTargetInAttackRange(enemyObj) == false)
                {
                    StartCoroutine(MoveToTargetRoutine(enemyObj));
                }
            }

            else
            {
                if (weaponSystem.IsTargetInAttackRange(enemyObj))
                {
                    if (Input.GetMouseButtonDown(0))
                    {
                        transform.LookAt(enemyObj.transform);
                        specialAbilities.UseAbilityOnEnemy(enemyObj, weaponSystem.GetWeaponInUse().weaponDamage);
                        anim.SetTrigger("Attacking");

                        //Use the ability or cast the spell...
                        specialAbilities.isAbilitySelected = false;
                    }
                }
            }
        }
Example #2
0
        void OnMouseOverEnemy(EnemyAI enemy)
        {
            if (Input.GetMouseButtonDown(0) && IsTargetInRange(enemy.gameObject))
            {
                weaponSystem.AttackTarget(enemy.gameObject);
            }
            else if (Input.GetMouseButtonDown(0) && !IsTargetInRange(enemy.gameObject))
            {
                StartCoroutine(MoveAndAttack(enemy));
            }

            for (int keyIndex = 0; keyIndex < abilities.GetNumberOfAbilities(); keyIndex++)
            {
                if (abilities.GetRequiresTarget(keyIndex))
                {
                    if (Input.GetKeyDown(keyIndex.ToString()) && IsTargetInRange(enemy.gameObject))   // Alphanumeric keys
                    {
                        abilities.AttemptSpecialAbility(keyIndex, enemy.gameObject);
                    }
                    else if (Input.GetKeyDown(keyIndex.ToString()) && !IsTargetInRange(enemy.gameObject))
                    {
                        StartCoroutine(MoveAndSpecialAttack(enemy.gameObject));
                    }
                    else if (Input.GetMouseButtonDown(1) && IsTargetInRange(enemy.gameObject))     // Right Click
                    {
                        abilities.AttemptSpecialAbility(0, enemy.gameObject);
                    }
                    else if (Input.GetMouseButtonDown(1) && !IsTargetInRange(enemy.gameObject))
                    {
                        StartCoroutine(MoveAndPowerAttack(enemy));
                    }
                }
            }
        }
Example #3
0
        void OnMouseOverDestroyable(Destroyable destroyable)
        {
            var currTarget = destroyable.gameObject;

            if (Input.GetMouseButton(0) && IsTargetInRange(currTarget))
            {
                weaponSystem.AttackTarget(currTarget);
            }
            else if (Input.GetMouseButton(0) && !IsTargetInRange(currTarget))
            {
                StartCoroutine(MoveAndAttack(currTarget));
            }
        }
Example #4
0
        private void Update()
        {
            distanceToPlayer   = Vector3.Distance(player.transform.position, transform.position);
            currentWeaponRange = weaponSystem.GetWeaponConfig().GetMaxAttackRange();

            bool inWeaponCircle = distanceToPlayer <= currentWeaponRange;
            bool inChaseRing    = distanceToPlayer > currentWeaponRange
                                  &&
                                  distanceToPlayer <= chaseRadius;

            bool outsideChaseRing = distanceToPlayer > chaseRadius;

            if (outsideChaseRing)
            {
                StopAttacking();
                character.setSelectedAnimatorForward();
                StartCoroutine(Patrol());
            }
            if (inChaseRing)
            {
                character.setMaximumAnimatorForward();
                StopAttacking();
                StartCoroutine(ChasePlayer());
            }
            if (inWeaponCircle)
            {
                StopAllCoroutines();
                weaponSystem.AttackTarget(player.gameObject);
            }
        }
Example #5
0
        void Update()
        {
            var playerHealth = player.GetComponent <HealthSystem>().healthAsPercentage;

            if (playerHealth <= Mathf.Epsilon)
            {
                StopAllCoroutines();
                return;
            }

            distanceToPlayer = Vector3.Distance(player.transform.position, transform.position);
            WeaponSystem weaponSystem = GetComponent <WeaponSystem>();

            currentWeaponRange = weaponSystem.CurrectWeaponConfig.MaxAttackRange;

            if (distanceToPlayer > chaseRadius && state != State.patrolling)
            {
                StopAllCoroutines();
                weaponSystem.StopAttacking();
                StartCoroutine(Patrol);
            }
            if (distanceToPlayer <= chaseRadius && state != State.chasing)
            {
                StopAllCoroutines();
                weaponSystem.StopAttacking();
                StartCoroutine(ChasePlayer);
            }
            if (distanceToPlayer <= currentWeaponRange && state != State.attacking)
            {
                StopAllCoroutines();
                state = State.attacking;
                weaponSystem.AttackTarget(player.gameObject);
            }
        }
Example #6
0
        void Update()
        {
            WeaponSystem weaponSystem = GetComponent <WeaponSystem>();

            currentWeaponRange = weaponSystem.GetCurrentWeapon().GetMaxAttackRange();

            distanceToPlayer = Vector3.Distance(player.transform.position, transform.position);

            if (distanceToPlayer > chaseRadius && state != State.patrolling)
            {
                StopAllCoroutines();
                StartCoroutine(Patrol());
            }

            if (distanceToPlayer <= chaseRadius && state != State.chasing)
            {
                StopAllCoroutines();
                StartCoroutine(ChasePlayer());
            }

            if (distanceToPlayer <= currentWeaponRange && state != State.attacking)
            {
                StopAllCoroutines();
                state = State.attacking;
                weaponSystem.AttackTarget(player);
            }
        }
Example #7
0
        void Update()
        {
            distanceToPlayer = Vector3.Distance(player.transform.position, transform.position);
            WeaponSystem weaponSystem = GetComponent <WeaponSystem>(); // No performance issue

            currentWeaponRange = weaponSystem.GetCurrentWeapon().GetMaxAttackRange();

            bool inWeaponRadius     = distanceToPlayer <= currentWeaponRange;
            bool inChaseRadius      = distanceToPlayer > currentWeaponRange && distanceToPlayer <= chaseRadius;
            bool outsideChaseRadius = distanceToPlayer > chaseRadius;

            if (inWeaponRadius)
            {
                StopAllCoroutines();
                state = State.attacking;
                transform.LookAt(player.gameObject.transform);
                weaponSystem.AttackTarget(player.gameObject);
                character.GetNavMeshAgent().Move(Vector3.zero);
                character.GetNavMeshAgent().velocity = Vector3.zero;
            }

            if (outsideChaseRadius)
            {
                StopAllCoroutines();
                //weaponSystem.StopAttacking();
                StartCoroutine(Patrol());
            }

            if (inChaseRadius)
            {
                StopAllCoroutines();
                weaponSystem.StopAttacking();
                StartCoroutine(ChasePlayer());
            }
        }
Example #8
0
        public void Update()
        {
            distanceToPlayer   = Vector3.Distance(player.transform.position, transform.position);
            weaponSystem       = GetComponent <WeaponSystem>();
            currentWeaponRange = weaponSystem.GetWeaponConfig().GetMaxAttackRange();

            bool inWeaponCricle     = distanceToPlayer <= currentWeaponRange;
            bool inChaseCircle      = distanceToPlayer > currentWeaponRange && distanceToPlayer <= chaseRadius;
            bool outsideChaseCircle = distanceToPlayer > chaseRadius;

            if (outsideChaseCircle && state != State.patrolling)
            {
                StopAllCoroutines();
                weaponSystem.StopAttacking();
                StartCoroutine(Patrol());
            }
            if (inChaseCircle && state != State.chasing)
            {
                StopAllCoroutines();
                weaponSystem.StopAttacking();
                StartCoroutine(ChasePlayer());
            }
            if (inWeaponCricle && state != State.attacking)
            {
                StopAllCoroutines();
                character.SetDestination(gameObject.transform.position);
                state = State.attacking;
                weaponSystem.AttackTarget(player.gameObject);
            }
        }
Example #9
0
        private void Update()
        {
            distanceToPlayer = Vector3.Distance(player.transform.position, transform.position);
            WeaponSystem weaponSystem     = GetComponent <WeaponSystem>();
            bool         inWeaponCircle   = distanceToPlayer <= currentWeaponRange;
            bool         inChaseRing      = distanceToPlayer > currentWeaponRange && distanceToPlayer <= chaseRadius;
            bool         outsideChaseRing = distanceToPlayer > chaseRadius;

            currentWeaponRange = weaponSystem.GetCurrentWeapon().GetMaxAttackRange();
            if (outsideChaseRing)
            {
                StopAllCoroutines();
                weaponSystem.StopAttacking();
                StartCoroutine(Patrol());
            }
            if (inChaseRing)
            {
                StopAllCoroutines();
                weaponSystem.StopAttacking();
                StartCoroutine(ChasePlayer());
            }
            if (inWeaponCircle)
            {
                StopAllCoroutines();
                weaponSystem.AttackTarget(player.gameObject);
                state = State.attacking;
            }
        }
Example #10
0
 IEnumerator AttackPlayer()
 {
     state = State.attacking;
     while (distanceToPlayer <= currentWeaponRange)
     {
         weaponSystem.AttackTarget(player.gameObject);
         yield return(new WaitForEndOfFrame());
     }
 }
Example #11
0
 void OnMouseOverEnemy(EnemyAI enemy)
 {
     if (Input.GetMouseButton(0) && IsTargetInRamge(enemy.gameObject))
     {
         weaponSystem.AttackTarget(enemy.gameObject);
     }
     else if (Input.GetMouseButton(0) && !IsTargetInRamge(enemy.gameObject))
     {
         StartCoroutine(MoveAndAttack(enemy));
     }
     else if (Input.GetMouseButtonDown(1) && IsTargetInRamge(enemy.gameObject)) //bjc
     {
         abilities.AttemptSpecialAblity(0, enemy.gameObject);
     }
     else if (Input.GetMouseButtonDown(1) && !IsTargetInRamge(enemy.gameObject)) //bjc
     {
         StartCoroutine(MoveAndPowerAttack(enemy));
     }
 }
Example #12
0
 private void OnMouseOverEnemy(EnemyAI enemyAi)
 {
     if (Input.GetMouseButton(0) && IsEnemyInRange(enemyAi.gameObject))
     {
         weaponSystem.AttackTarget(enemyAi.gameObject);
     }
     else if (Input.GetMouseButton(0) && !IsEnemyInRange(enemyAi.gameObject))
     {
         StartCoroutine(MoveAndAttack(enemyAi.gameObject));
     }
     else if (Input.GetMouseButtonDown(1) && IsEnemyInRange(enemyAi.gameObject))
     {
         abilities.AttemptSpecialAbility(0, enemyAi.gameObject);
     }
     else if (Input.GetMouseButtonDown(1) && !IsEnemyInRange(enemyAi.gameObject))
     {
         StartCoroutine(MoveAndSpecialAbility(0, enemyAi.gameObject));
     }
 }
Example #13
0
        void Update()
        {
            distanceToPlayer = Vector3.Distance(player.transform.position, transform.position);

            WeaponSystem weaponSystem = GetComponent <WeaponSystem>();

            currentWeaponRange = weaponSystem.GetCurrentWeapon().GetMaxAttackRange();

            bool inWeaponCircle     = distanceToPlayer <= currentWeaponRange;
            bool inChaseCircle      = distanceToPlayer > currentWeaponRange && distanceToPlayer <= chaseRadious;
            bool outsideChaseCircle = distanceToPlayer > chaseRadious;

            if (outsideChaseCircle)
            {
                StopAllCoroutines();
                weaponSystem.StopAttacking();
                StartCoroutine(Patrol());
            }
            if (inChaseCircle)
            {
                StopAllCoroutines();
                weaponSystem.StopAttacking();
                StartCoroutine(ChasePlayer());
            }
            if (inWeaponCircle)
            {
                StopAllCoroutines();

                state = State.attacking;
                //state = State.attacking; si activo deja de funcionar el health del player
                weaponSystem.AttackTarget(player.gameObject);
            }

////////////////////////////////////////////////////
            // if (distanceToPlayer > chaseRadious && state != State.patrolling)
            // {
            //  StopAllCoroutines();
            //  weaponSystem.StopAttacking();
            //  StartCoroutine( Patrol() );
            // }
            // if (distanceToPlayer <= chaseRadious && state != State.chasing)
            // {
            //  StopAllCoroutines();
            //  weaponSystem.StopAttacking();
            //  StartCoroutine(ChasePlayer());
            // }
            // if (distanceToPlayer <= currentWeaponRange && state != State.attacking)
            // {
            //  StopAllCoroutines();
            //  //state = State.attacking; si activo deja de funcionar el health del player
            //  weaponSystem.AttackTarget(player.gameObject);
            // }
///////////////////////////////////////////////////////
        }
Example #14
0
 void OnMouseOverEnemy(EnemyAI enemyToSet)
 {
     this.enemy = enemyToSet;
     if (Input.GetMouseButton(0) && IsTargetInRange(enemy.gameObject))
     {
         weaponSystem.AttackTarget(enemy.gameObject);
     }
     else if (Input.GetMouseButtonDown(1))
     {
         abilities.AttemptSpecialAbility(0);
     }
 }
Example #15
0
        private void onMouseOverEnemy(EnemyAI enemy)
        {
            var gameObject = enemy.gameObject;

            if (Input.GetMouseButton(0) && IsTargetInRange(gameObject))
            {
                weaponSystem.AttackTarget(gameObject);
            }
            else if (Input.GetMouseButton(0) && !IsTargetInRange(gameObject))
            {
                StartCoroutine(MoveAndAttack(gameObject));
            }
            else if (Input.GetMouseButtonDown(1) && IsTargetInRange(gameObject))
            {
                abilities.AttemptSpecialAbility(0, gameObject);
            }
            else if (Input.GetMouseButtonDown(1) && IsTargetInRange(gameObject))
            {
                StartCoroutine(MoveAndPowerAttack(gameObject));
            }
        }
Example #16
0
        void OnMouseOverEnemy(EnemyAI enemyToSet)
        {
            this.target = enemyToSet;
            HealthSystem enemyCharacterHealth = this.target.GetComponent <HealthSystem>();

            if (Input.GetMouseButton(0) && playerCharacter.IsTargetInRange(enemyCharacterHealth.GetComponent <Character>()))
            {
                weaponSystem.AttackTarget(enemyCharacterHealth);
            }
            else if (Input.GetMouseButtonDown(1) && playerCharacter.IsTargetInRange(enemyCharacterHealth.GetComponent <Character>()))
            {
                playerAbilities.AttemptSpecialAbility(0, enemyCharacterHealth, characterStats.GetDamage());
            }
        }
Example #17
0
 private void ProcessMouseOverEnemy(EnemyAI enemy)
 {
     if (Input.GetMouseButton(0) && IsTargetInRange(enemy.gameObject))
     {
         StopAllCoroutines();
         weaponSystem.AttackTarget(enemy.gameObject);
     }
     else if (Input.GetMouseButton(0) && !IsTargetInRange(enemy.gameObject))
     {
         StopAllCoroutines();
         StartCoroutine(MoveAndAttackTarget(enemy.gameObject));
     }
     else if (Input.GetMouseButtonDown(1) && IsTargetInRange(enemy.gameObject))
     {
         StopAllCoroutines();
         specialAbilties.AttemptSpecialAbility(0, enemy.gameObject);
     }
     else if (Input.GetMouseButtonDown(1) && !IsTargetInRange(enemy.gameObject))
     {
         StopAllCoroutines();
         StartCoroutine(MoveAndPowerAttackTarget(enemy.gameObject));
     }
 }
Example #18
0
        private void Update()
        {
            WeaponSystem weaponSystem = GetComponent <WeaponSystem>();

            attackRange = weaponSystem.GetCurrentWeapon().GetMaxAttackRange();

            distanceToTarget = Vector3.Distance(playerControl.transform.position, transform.position);

            bool inWeaponRange     = distanceToTarget <= attackRange;
            bool inChaseRange      = distanceToTarget > attackRange && distanceToTarget <= chaseRadius;
            bool outsideChaseRange = distanceToTarget > chaseRadius;

            if (outsideChaseRange && state != State.patrolling)
            {
                StopAllCoroutines();
                weaponSystem.StopAttacking();
                StartCoroutine(Patrol());
            }
            if (inChaseRange && state != State.chasing)
            {
                StopAllCoroutines();
                weaponSystem.StopAttacking();
                StartCoroutine(ChasePlayer());
            }
            if (inWeaponRange && state != State.attacking)
            {
                StopAllCoroutines();
                state = State.attacking;
                weaponSystem.AttackTarget(playerControl.gameObject);
            }
            if (isFriendly && distanceToTarget <= chaseRadius && state != State.following)
            {
                // follow state // following is moving to a spot right behind the player
            }
            if (health.HealthAsPercentage() <= .05 && state != State.fleeing)
            {
                // flee state
            }
        }
Example #19
0
        void Update()
        {
            WeaponSystem weaponSystem = GetComponent <WeaponSystem>();

            currentWeaponRange = weaponSystem.GetCurrentWeapon().GetMaxAttackRange();
            distanceToPlayer   = Vector3.Distance(player.transform.position, transform.position);

            if (isAlive)
            {
                bool inWeaponRange     = distanceToPlayer <= currentWeaponRange;
                bool inChaseRange      = distanceToPlayer > currentWeaponRange && distanceToPlayer <= chaseRadius;
                bool outsideChaseRange = distanceToPlayer > chaseRadius;

                if (inChaseRange)
                {
                    StopAllCoroutines();
                    weaponSystem.StopAttacking();
                    StartCoroutine(ChasePlayer());
                    character.ReturnAnimationFowardCap();
                }
                else if (inWeaponRange)
                {
                    StopAllCoroutines();
                    state = State.attacking;
                    weaponSystem.AttackTarget(player.gameObject);
                }
                else if (outsideChaseRange && state != State.patrolling)
                {
                    StopAllCoroutines();
                    weaponSystem.StopAttacking();
                    StartCoroutine(Patrol());
                }
            }
            else
            {
                StopAllCoroutines();
            }
        }
Example #20
0
        void Update()
        {
            WeaponSystem weaponSystem = GetComponent <WeaponSystem>();

            currentWeaponRange = weaponSystem.GetCurrentWeapon().GetMaxAttackRange();

            distanceToPlayer = Vector3.Distance(player.transform.position, transform.position);

            //bool playerIsOutOfRangeAndEnemyIsNotPatrolling = distanceToPlayer > chaseRadius && state != State.patrolling;

            bool inWeaponCircle     = distanceToPlayer <= currentWeaponRange;
            bool inChaseCircle      = distanceToPlayer > currentWeaponRange && distanceToPlayer <= chaseRadius;
            bool outsideChaseCircle = distanceToPlayer > chaseRadius;

            if (outsideChaseCircle)
            {
                StopAllCoroutines();
                weaponSystem.StopAttacking();
                StartCoroutine(Patrol());
            }

            //bool playerIsInRangeAndEnemyIsNotChasing = distanceToPlayer <= chaseRadius && state != State.chasing;
            if (inChaseCircle)
            {
                StopAllCoroutines();
                weaponSystem.StopAttacking();
                StartCoroutine(ChasePlayer());
            }

            //bool playerIsInWeaponRangeAndEnenyIsNotAttacking = distanceToPlayer <= currentWeaponRange && state != State.attacking;
            if (inWeaponCircle)
            {
                StopAllCoroutines();
                state = State.attacking;
                weaponSystem.AttackTarget(player.gameObject);
            }
        }
Example #21
0
 void Attack()
 {
     state = State.attacking;
     weaponSystem.AttackTarget(player);
 }
Example #22
0
 void AttackTarget()
 {
     weaponSystem.AttackTarget(player.GetComponent <HealthSystem>());
 }
Example #23
0
 public void AttackPlayer()
 {
     weaponSystem.AttackTarget(player.gameObject);
 }
Example #24
0
        IEnumerator MoveAndAttack(EnemyAI target)
        {
            yield return(StartCoroutine(MoveToTarget(target)));

            weaponSystem.AttackTarget(target.gameObject);
        }