예제 #1
0
        private void Update()
        {
            timeSinceLastAttack += Time.deltaTime;

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

            bool isInRange = Vector3.Distance(transform.position, target.transform.position) < currentWeapon.value.GetRange();

            if (!isInRange)
            {
                mover.MoveTo(target.transform.position, 1f);
            }
            else
            {
                mover.Cancel();
                AttackBehaviour();
            }
        }
예제 #2
0
        private void Update()
        {
            m_TimeSinceLastAttack += Time.deltaTime;
            if (m_Target == null || m_Target.IsDead || attackDisabled)
            {
                return;
            }

            if (CombatTargetChanged(m_Target))
            {
                StopAttack();
            }

            if (!GetIsInRange(m_Target.transform))
            {
                m_Mover.MoveTo(m_Target.transform.position, 1f);
                m_Stopped = false;
            }
            else
            {
                if (!m_Stopped)
                {
                    m_Mover.Cancel();
                    m_Stopped = true;
                }

                AttackBehaviour();
            }
        }
예제 #3
0
파일: Fighter.cs 프로젝트: DutchRascal/RPG
        private void Update()
        {
            timeSinceLastAttack += Time.deltaTime;
            if (!target)
            {
                return;
            }
            // if (target.IsDead())

            if (!mover.NavMeshAgent.isStopped)
            {
                animator.ResetTrigger("attack");
                animator.SetTrigger("stopAttack");
            }

            if (target.IsDead())
            {
                animator.SetTrigger("stopAttack");
                return;
            }

            if (!GetIsInRange())
            {
                mover.MoveTo(target.transform.position, 1f);
            }
            else
            {
                mover.Cancel();
                AttackBehaviour();
            }
        }
예제 #4
0
        public void Update()
        {
            timeSinceLastAttack += Time.deltaTime;

            if (target == null)
            {
                return;
            }
            Health targetHealth = target.GetComponent <Health>();

            if (targetHealth != null && targetHealth.IsDead)
            {
                return;
            }

            if (!GetIsInRange())
            {
                _moverComponent.MoveTo(target.transform.position, 1f);
            }
            else
            {
                _moverComponent.Cancel();
                AttackBehaviour();
            }
        }
예제 #5
0
        private void Update()
        {
            timeSinceLastAttack += Time.deltaTime;

            if (target == null)
            {
                return;
            }

            if (target.IsDead())
            {
                return;
            }

            if (!GetIsInRange())
            {
                mover.MoveTo(target.transform.position, 1f
                             );
            }
            else
            {
                mover.Cancel();
                AttackBehaviour();
            }
        }
예제 #6
0
파일: Fighter.cs 프로젝트: zeatful/RPG
        private void Update()
        {
            timeSinceLastAttack += Time.deltaTime;

            if (target == null)
            {
                return;
            }

            if (target.IsDead())
            {
                return;
            }

            // ensure there is already a target
            if (target != null && !IsInRange())
            {
                // move until in weapon range
                mover.MoveTo(target.transform.position, 1f);
            }
            else
            {
                // in weapon range, stop moving
                mover.Cancel();
                AttackBehavior();
            }
        }
예제 #7
0
 void AttackBehaviour()
 {
     animator.SetTrigger("attack");
     moveController.Cancel();
     timeSinceLastAttack = 0f;
     transform.LookAt(target.transform);
 }
예제 #8
0
        private void Update()
        {
            m_timeSinceLastAttack += Time.deltaTime;

            // No target exists
            if (m_target == null)
            {
                return;
            }

            // Target is already dead
            if (m_target.IsDead)
            {
                return;
            }

            // Get in range of the target
            if (m_target != null && !GetIsInRange(m_target.transform, m_currentWeaponConfig.WeaponRange))
            {
                m_mover.MoveTo(m_target.transform.position, 1f);
            }
            else
            {
                // Attack the target when in range
                m_mover.Cancel();
                AttackBehavior();
            }
        }
        private void GettingToTarget()
        {
            timeSinceLastAttack += Time.deltaTime;
            timeFromLastAttack  += Time.deltaTime;

            if (targetHealth == null)
            {
                return;
            }
            if (targetHealth.IsDead())
            {
                return;
            }


            if (Vector3.Distance(transform.position, targetHealth.transform.position) > currentWeaponConfig.Range)
            {
                mover.MoveTo(targetHealth.transform.position);
            }
            else
            {
                mover.Cancel();
                AttackBehaviour();
            }
        }
예제 #10
0
        // Update is called once per frame
        void Update()
        {
            //updat Time since last attack
            m_timeSinceLastAttack += Time.deltaTime;


            if (m_Target == null)
            {
                return;
            }

            if (m_Target.GetIsDead())
            {
                return;
            }
            bool isInRange = Vector3.Distance(transform.position, m_Target.transform.position) < m_WeaponRange;

            Mover mover = GetComponent <Mover>();

            //move to target
            if (!isInRange)
            {
                mover.MoveTo(m_Target.transform.position);
            }
            else
            {
                mover.Cancel();
                AttackBehavior();
            }
        }
예제 #11
0
        private void Update()
        {
            Health health = GetComponent <Health>();

            if (health == null || !health.Alive)
            {
                return;
            }
            timeSinceLastAttack += Time.deltaTime;

            if (target == null)
            {
                return;
            }
            if (GetIsInRange())
            {
                mover.Cancel();
                transform.rotation = Quaternion.RotateTowards(transform.rotation, Quaternion.LookRotation(target.position - transform.position, Vector3.up), attackRotationSpeed);
                if (timeSinceLastAttack > currentWeapon.GetTimeBetweenAttacks())
                {
                    AttackBehavoiur();
                    timeSinceLastAttack = 0f;
                }
            }
            else
            {
                mover.MoveTo(target.position, 1f);
            }
        }
예제 #12
0
        private void Update()
        {
            timeSinceLastAttack += Time.deltaTime;

            /* This script only works after having an attack attackTarget
             * and this attackTarget is not dead.
             */
            if (!attackTarget || attackTarget.IsDead())
            {
                return;
            }
            if (!GetIsInRange())
            {
                /* If character is too far from attackTarget,
                 * it should move to the attackTarget at first.
                 */
                mover.MoveTo(attackTarget.transform.position, 1f);
            }
            else
            {
                // Stop move and do attack behaviour.
                mover.Cancel();
                AttackBehaviour();
            }
        }
예제 #13
0
        private void Update()
        {
            timeSinceLastAttack += Time.deltaTime;
            if (target == null)
            {
                return;
            }

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

            if (!GetInRange())
            {
                // we want to move towards it probs
                mover.MoveTo(target.transform.position);
            }
            else
            {
                mover.Cancel();
                AttackBehavior();
            }
        }
예제 #14
0
        private void Update()
        {
            timeSinceLastAttack += Time.deltaTime;

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

            if (Vector3.Distance(transform.position, target.transform.position) > currentWeapon.value.GetWeaponRange())
            {
                moveComponent.MoveTo(target.transform.position);
            }
            else
            {
                moveComponent.Cancel();
                if (timeSinceLastAttack >= timeBetweenAttacks)
                {
                    AttackBehaviour();
                    timeSinceLastAttack = 0;
                }
            }
        }
예제 #15
0
        void Update()
        {
            _timeSinceLastSawPlayer += Time.deltaTime;
            _timeSinceLastPatrolled += Time.deltaTime;
            _timeSinceAggravated    += Time.deltaTime;

            if (_player.IsAlive() && _fighter.enabled && ShouldAttack())
            {
                if (Vector3.Distance(transform.position, _player.transform.position) - _weaponsRange >= Mathf.Epsilon)
                {
                    _fighter.Attack(_player.gameObject);
                    _mover.SetSpeed(_chaseSpeed);
                }

                _timeSinceLastSawPlayer = 0;
            }
            else if (_timeSinceLastSawPlayer - _suspicionTime <= Mathf.Epsilon)
            {
                _mover.Cancel();
            }
            else
            {
                PatrolBehaviour();
            }
        }
예제 #16
0
 private void Update()
 {
     timeSinceLastAttack += Time.deltaTime;
     if (currentTarget == null || currentTarget.IsDead)
     {
         return;
     }
     if (Vector3.Distance(transform.position, currentTarget.transform.position) > equippedWeaponConfig.Range)
     {
         mover.MoveTo(currentTarget.transform.position, 1);
     }
     else
     {
         mover.Cancel();
         AttackBehaviour();
     }
 }
예제 #17
0
        private void Update()
        {
            timeSinceLastAttack += Time.deltaTime;

            if (target && !target.IsDead())
            {
                if (!GetIsRange())
                {
                    Vector3 destination = GetDistanceFromTarget();
                    mover.MoveTo(destination);
                }
                else
                {
                    mover.Cancel();
                    AttackBehaviour();
                }
            }
        }
예제 #18
0
        private void Update()
        {
            timeSinceLastAttack += Time.deltaTime;

            if (!target || target.IsDead)
            {
                return;
            }

            if (Vector3.Distance(transform.position, target.transform.position) <= weaponRange)
            {
                AttackBehaviour();
                mover.Cancel();
            }
            else
            {
                mover.MoveTo(target.transform.position);
            }
        }
예제 #19
0
    // Update is called once per frame
    void Update()
    {
        timeSinceLastAttack += Time.deltaTime;

        if (target == null)
        {
            return;
        }

        if (GetIsInRange())
        {
            mover.SetDestination(target.transform.position, 1f);
        }
        else
        {
            mover.Cancel();
            AttackBehaviour();
        }
    }
예제 #20
0
        private void MoveToEnemyToAttack()
        {
            if (target == null)
            {
                return;
            }
            if (target.IsDead())
            {
                return;
            }

            if (!GetIsInRange(target.transform))
            {
                mover.MoveTo(target.transform.position, 1f);
            }
            else
            {
                mover.Cancel();
                AttackBehaviour();
            }
        }
예제 #21
0
파일: Fighter.cs 프로젝트: SVell/Diabloid
        private void MoveToTheTarget()
        {
            if (target == null)
            {
                return;
            }
            if (target.IsDead())
            {
                return;
            }

            if (target != null && !IsInRange(target.transform))
            {
                mover.MoveTo(target.transform.position, 1f);
            }
            else
            {
                mover.Cancel();
                AttackBehaviour();
            }
        }
예제 #22
0
 private void ProcessAttack()
 {
     if (GetIsInRange(target.transform))
     {
         mover.Cancel();
         AttackBehaviour();
     }
     else
     {
         mover.MoveTo(target.transform.position, 1f);
     }
 }
예제 #23
0
        private void MoveToAttack()
        {
            if (_target == null)
            {
                return;
            }

            if (!GetIsInRange())
            {
                _mover.MoveTo(_target.transform.position, 1f);
            }
            else
            {
                _mover.Cancel();

                if (_timeSinceLastAttack > _timeBetweenAttacks)
                {
                    AttackBehaviour();
                    _timeSinceLastAttack = 0;
                }
            }
        }
예제 #24
0
        private void Update()
        {
            timeSinceLastAttack += Time.deltaTime;
            if (target != null)
            {
                mover.MoveTo(target.transform.position, agent, 1);
                if (TargetIsInWeaponRange())
                {
                    mover.Cancel();

                    AttackBehaviour();
                }
            }
        }
예제 #25
0
 private void Update()
 {
     if (target != null && CanAttack(target.gameObject))
     {
         if (!GetIsInRange())
         {
             mover.MoveTo(target.transform.position, attackSpeedFraction);
         }
         else
         {
             mover.Cancel();
             AttackBehaviour();
         }
     }
 }
예제 #26
0
        private void Update()
        {
            timeSinceLastAttack += Time.deltaTime;
            bool isInAttack = GetComponent <Animator>().GetCurrentAnimatorStateInfo(0).IsName("Attack");

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

            if (!GetIsInRange(target.transform))
            {
                if (isInAttack)
                {
                    GetComponent <Animator>().SetTrigger("attackCancel");
                }
                mover.MoveTo(target.transform.position, 1f);
            }
            else
            {
                mover.Cancel();
                AttackBehaviour();
            }
        }
예제 #27
0
        private void Update()
        {
            timeSinceLastAttack += Time.deltaTime;
            //print(timeSinceLastAttack);

            if (target == null)
            {
                return;
            }
            if (target.GetComponent <Health>().IsDead())
            {
                return;
            }

            if (IsInRange())
            {
                _mover.Cancel();
                AttackBehavior();
            }
            else
            {
                _mover.MoveTo(target.position, 1f);
            }
        }
예제 #28
0
        // Update is called once per frame
        void Update()
        {
            anim.SetFloat("attackSpeed", attackSpeed);
            timeSinceAttack += Time.deltaTime;
            // print("timeSinceAttack: " + timeSinceAttack);
            if (numberOfAttack > maxNumberOfAttack || timeSinceAttack > maxTimeGapBetweenAttacks)
            {
                tempMaxNumberOfAttack = 1;
                numberOfAttack        = 0;
                StopAttack();
            }
            if (target == null)
            {
                return;
            }
            if (target.IsDead())
            {
                StopAttack();
                target = null;
                return;
            }

            // if (!GetIsInRange(target.transform)&&!isAttacking)
            // {
            //     mover.MoveTo(target.transform.position, 1f);
            // }
            // else if (target)
            if (GetIsInRange(target.transform) && !isAttacking && target)
            {
                mover.Cancel();
                if (stamina.HasStaminaLeft())
                {
                    AttackBehaviour(20f);
                }
            }
        }
예제 #29
0
        void Update()
        {
            if (target == null)
            {
                return;
            }

            if (!CheckIsInRange())
            {
                mover.MoveTo(target.position);
            }
            else
            {
                mover.Cancel();
            }
        }
예제 #30
0
파일: Fighter.cs 프로젝트: ipevr/RPG2
        void Update()
        {
            if (!target)
            {
                return;
            }
            bool isInRange = Vector3.Distance(target.position, transform.position) <= weaponRange;

            if (!isInRange)
            {
                mover.MoveTo(target.position);
            }
            else
            {
                mover.Cancel();
            }
        }