Ejemplo n.º 1
0
        public bool CanAttack(GameObject cTarget)
        {
            if (cTarget == null || gameObject.name == cTarget.gameObject.name)
            {
                return(false);
            }
            Health targetToTest = cTarget.GetComponent <Health>();

            return(targetToTest != null && !targetToTest.IsDead());
        }
Ejemplo n.º 2
0
        public bool CanAttack(GameObject combatTarget)
        {
            if (combatTarget == null)
            {
                return(false);
            }
            Health targetToTest = combatTarget.GetComponent <Health>();

            return(targetToTest != null && !targetToTest.IsDead());
        }
Ejemplo n.º 3
0
        public bool CanAttack(CombatTarget combatTarget)
        {
            if (combatTarget == null)
            {
                return(false);
            }

            Health targetToAttack = combatTarget.GetComponent <Health>();

            return(targetToAttack != null && !targetToAttack.IsDead());
        }
Ejemplo n.º 4
0
        public bool PlayerCanAttack(GameObject combatTarget)
        {
            if (combatTarget == null || combatTarget == player)
            {
                return(false);
            }
            Health targetToTest = combatTarget.GetComponent <Health>();

            //return true if..
            return(targetToTest != null && !targetToTest.IsDead()); //continuing from previous line
        }
Ejemplo n.º 5
0
        public bool CanAttack(GameObject combatTarget)
        {
            if (combatTarget == null)
            {
                return(false);
            }

            Health health = combatTarget.GetComponent <Health>();

            return(health != null && !health.IsDead());
        }
Ejemplo n.º 6
0
 private bool isTargetInvalid()
 {
     if (target != null)
     {
         if (!target.IsDead())
         {
             return(false);
         }
     }
     return(true);
 }
Ejemplo n.º 7
0
        public bool CanAttack(GameObject combatTarget)
        {
            // tied to InteractWithCombat() in PlayerController.cs
            if (combatTarget == null)
            {
                return(false);
            }
            Health targetToTest = combatTarget.GetComponent <Health>();

            return(targetToTest != null && !targetToTest.IsDead());
        }
Ejemplo n.º 8
0
        public bool CanAttack(GameObject combatTarget) //Falls kein CombatTarget ausgewählt ist oder der target isDead ist, wird false zurück gegeben.
        {
            if (combatTarget == null)
            {
                return(false);
            }

            Health targetToTest = combatTarget.GetComponent <Health>();

            return(targetToTest != null && !targetToTest.IsDead());
        }
Ejemplo n.º 9
0
        //ignores dead enimies such as their hit box (checks is they are dead)
        public bool CanAttack(CombatTarget combatTarget)
        {
            //if we click on the terrain instead of target return false
            if (combatTarget == null)
            {
                return(false);
            }
            Health targetToTest = combatTarget.GetComponent <Health>();

            return(targetToTest != null && !targetToTest.IsDead());
        }
Ejemplo n.º 10
0
 void Update()
 {
     if (target == null)
     {
         return;
     }
     if (isHomingProjectile && !target.IsDead())
     {
         transform.LookAt(GetAimLocation());
     }
     transform.Translate(Vector3.forward * speed * Time.deltaTime);
 }
Ejemplo n.º 11
0
 private void AttackBehaviour()
 {
     //A little bit different from lesson in lesson if dead he puts a return in
     // the update i prefer to check here so we can still move to the guy
     if (timeSinceLastAttack > timeBetweenAttacks && !target.IsDead())
     {
         //this will trigger the void Hit() event
         gameObject.transform.LookAt(target.transform);
         TriggerAttackAnim();
         timeSinceLastAttack = 0;
     }
 }
Ejemplo n.º 12
0
        public bool CanAttack(GameObject combatTarget)
        {
            if (combatTarget == null)
            {
                return(false);
            }

            Health targetToTest = combatTarget.GetComponent <Health>();

            //se o target nao for null e não estiver morto
            return(targetToTest != null && !targetToTest.IsDead());
        }
Ejemplo n.º 13
0
        private void Update()
        {
            if (target == null)
            {
                return;
            }

            if (targetTransform == Vector3.zero || isHoming && !target.IsDead())
            {
                transform.LookAt(GetAimLocation());
            }
            transform.Translate(Vector3.forward * moveSpeed * Time.deltaTime);
        }
Ejemplo n.º 14
0
        public bool CanAttack(GameObject target)
        {
            Health targetHealthComponent = target.GetComponent <Health>();

            if (targetHealthComponent == null || targetHealthComponent.IsDead())
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
Ejemplo n.º 15
0
        public bool CanAttack(GameObject combatTarget)
        {
            if (combatTarget == null)
            {
                return(false);
            }
            Health targetHealth = combatTarget.GetComponent <Health>();

            if (targetHealth.IsDead())
            {
                return(false);
            }
            return(true);
        }
Ejemplo n.º 16
0
        public bool CanAttack(GameObject combatTarget)
        {
            if (combatTarget == null)
            {
                return(false);
            }
            if (!GetComponent <Mover>().CanMoveTo(combatTarget.transform.position) && !GetIsInRange(combatTarget.transform))
            {
                return(false);
            }
            Health targetToTest = combatTarget.GetComponent <Health>();

            return(targetToTest != null && !targetToTest.IsDead());
        }
Ejemplo n.º 17
0
        //function to check if the enemy that was hit by raycast is targetable
        public bool CanAttack(CombatTarget combatTarget)
        {
            //if the combatTarget passed in is null then return false (we cannot attack a null object)
            if (combatTarget == null)
            {
                return(false);
            }

            //get Health component from the passed combatTarget
            Health targetToTest = combatTarget.GetComponent <Health>();

            //return true if target is not null AND target is not dead
            return(targetToTest != null && !targetToTest.IsDead());
        }
Ejemplo n.º 18
0
        public bool CanAttack(GameObject target)
        {
            if (target == null)
            {
                return(false);
            }
            if (!GetComponent <Mover>().CanMoveTo(target.transform.position))
            {
                return(false);
            }

            Health targetToCheck = target.GetComponent <Health>();

            return(targetToCheck != null && !targetToCheck.IsDead());
        }
Ejemplo n.º 19
0
 private void Update()
 {
     timeSinceLastAttack += Time.deltaTime;
     if (target == null || target.IsDead())
     {
         return;
     }
     if (!GetIsInRange())
     {
         GetComponent <Mover>().MoveTo(target.transform.position, 1f);
     }
     else
     {
         GetComponent <Mover>().Cancel();
         AttackBehaviour();
     }
 }
Ejemplo n.º 20
0
        public bool CanAttack(GameObject combatTarget)
        {
            //If we have no target we cannot attack
            if (combatTarget == null)
            {
                return(false);
            }
            if (!GetComponent <Mover>().CanMoveTo(combatTarget.transform.position) &&
                !GetIsInRange(combatTarget.transform))
            {
                return(false);
            }
            //Gets health of current target we want to test
            Health targetToTest = combatTarget.GetComponent <Health>();

            //If we have a target and they are not dead, return true.
            return(targetToTest != null && !targetToTest.IsDead());
        }
Ejemplo n.º 21
0
        private void Update()
        {
            timeSinceLastAttack += Time.deltaTime; // starts count on cooldown between attacks

            if (target == null) return; // checking if there is an enemy
                                        // if there is check if he is dead
            if (target.IsDead()) return; // stop attacking the target if they are dead
                                        // if the enemy is not dead is he in range
            if (!GetIsInRange()) // move only if a target is NOT within range
            {
                GetComponent<Mover>().MoveTo(target.transform.position, 1f); // move to target only if they are not in range
            }
            else // in range, attack!
            {
                GetComponent<Mover>().Cancel(); // stop moving
                AttackBehavior(); // attack
            }
        }
Ejemplo n.º 22
0
        private void Update()
        {
            timeSinceLastAttack += Time.deltaTime;

            if (target && !target.IsDead())
            {
                if (!GetIsRange())
                {
                    Vector3 destination = GetDistanceFromTarget();
                    mover.MoveTo(destination);
                }
                else
                {
                    mover.Cancel();
                    AttackBehaviour();
                }
            }
        }
Ejemplo n.º 23
0
        private void Update()
        {
            timeSincesLastAttack += Time.deltaTime;

            if (target == null || target.IsDead())
            {
                return;
            }

            if (!this.GetIsInRange())
            {
                this.mover.MoveTo(this.target.transform.position, 1f);
            }
            else
            {
                this.mover.Cancel();
                this.AttackBehaviour();
            }
        }
Ejemplo n.º 24
0
        private void OnTriggerEnter(Collider other)
        {
            Health health = other.GetComponent <Health>();

            if (target != null && health != target)
            {
                return;
            }
            if (health == null || health.IsDead())
            {
                return;
            }
            if (other.gameObject == instigator)
            {
                return;
            }
            health.TakeDamage(instigator, damage);
            ProjectileImpact();
        }
Ejemplo n.º 25
0
        private void Update()
        {
            timeSinceLastAttack += Time.deltaTime;

            if (target == null || target.IsDead())
            {
                return;
            }

            if (!GetIsInRange())
            {
                mover.MoveTo(target.transform.position);
            }
            else
            {
                mover.Cancel();
                AttackBehavior();
            }
        }
Ejemplo n.º 26
0
        /// <summary>
        /// Returns whether or not the taret can be attacked
        /// </summary>
        /// <param name="target"></param>
        /// <returns></returns>
        public bool CanAttack(GameObject target)
        {
            //Make sure target is not null
            if (target == null)
            {
                return(false);
            }

            //If we can't move to the object and the object is our of weapon range we cannot attack
            if (!GetComponent <CharacterMovement>().CanMoveTo(target.transform.position) && !InWeaponRange(target.transform))
            {
                return(false);
            }

            //Make sure target has a health component and is alive
            Health targetHealth = target.GetComponent <Health>();

            return(targetHealth != null && !targetHealth.IsDead());
        }
Ejemplo n.º 27
0
        private void OnTriggerEnter(Collider other)
        {
            if (other.GetComponent <Health>() != target)
            {
                return;
            }
            if (target.IsDead())
            {
                return;
            }
            target.TakeDamage(damage);
            speed = 0;
            foreach (GameObject toDestroy in destroyOnHit)
            {
                Destroy(toDestroy);
            }

            Destroy(gameObject, lifeAfterImpact);
        }
Ejemplo n.º 28
0
        private void OnTriggerEnter(Collider other)
        {
            if (other.GetComponent <Health>() != target)
            {
                return;
            }
            if (target.IsDead())
            {
                return;
            }

            target.TakeDamage(instigator, damage);

            if (hitEffect != null)
            {
                Instantiate(hitEffect, GetAimLocation(), transform.rotation);
            }

            Destroy(gameObject);
        }
Ejemplo n.º 29
0
 private void OnTriggerEnter(Collider other)
 {
     if (target != null)
     {
         // Enemy AI
         if (other.GetComponent <Health>() != target)
         {
             return;
         }
         if (target.IsDead())
         {
             return;
         }
         target.TakeDamage(instigator, damage);
         if (hitEffect != null)
         {
             Instantiate(hitEffect, target.GetHitLocation(), transform.rotation);
         }
     }
     else
     {
         // Player
         Health hitCharacter = other.GetComponent <Health>();
         if (hitCharacter == null || hitCharacter.IsDead() || hitCharacter.GetComponent <CombatTarget>() == null)
         {
             return;
         }
         hitCharacter.TakeDamage(instigator, damage);
         if (hitEffect != null)
         {
             Instantiate(hitEffect, hitCharacter.GetHitLocation(), transform.rotation);
         }
     }
     onHit.Invoke();
     speed = 0f;
     foreach (GameObject toDestroy in destroyOnHit)
     {
         Destroy(toDestroy);
     }
     Destroy(this.gameObject, lifeAfterImpact);
 }
Ejemplo n.º 30
0
        private void Update()
        {
            if (target == null)
            {
                return;
            }
            if (target.IsDead())
            {
                return;
            }

            if (!GetIsInRange())
            {
                GetComponent <CharacterMovement>().MoveTo(target.transform.position, 1f);
            }
            else
            {
                GetComponent <CharacterMovement>().Cancel();
                AttackBehavior();
            }
        }