Esempio n. 1
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);
            }
        }
Esempio n. 2
0
 private void onMouseOverWalkable(Vector3 destination)
 {
     if (Input.GetMouseButton(0))
     {
         character.SetDestination(destination);
     }
 }
Esempio n. 3
0
 void OnMouseOverPotWalkable(Vector3 destination)
 {
     if (Input.GetMouseButton(0) && healthSystem.healthAsPercentage >= Mathf.Epsilon)
     {
         character.SetDestination(destination);
         weaponSystem.StopAttacking();
     }
 }
Esempio n. 4
0
 void OnMousePotentionallyWalkable(Vector3 destionation)
 {
     if (Input.GetMouseButton(0))
     {
         weaponSystem.StopAttacking();
         character.SetDestination(destionation);
     }
 }
Esempio n. 5
0
 void OnMouseOverTerrain(Vector3 destination)
 {
     if (Input.GetMouseButton(0))
     {
         weaponSystem.StopAttacking();
         character.SetDestination(destination);
     }
 }
Esempio n. 6
0
 private void OnMouseOverPossiblyWalkable(Vector3 destination)
 {
     if (Input.GetMouseButton(0))
     {
         weaponSystem.StopAttacking();
         character.SetDestination(destination);
     }
 }
Esempio n. 7
0
        void Update()
        {
            ScanForAbilityKeyDown();

            if (isAttacking && updatedTarget && updatedTarget.transform.hasChanged)
            {
                character.SetDestination(updatedTarget.transform.position);
            }
        }
Esempio n. 8
0
 IEnumerator MoveToTarget(GameObject target)
 {
     character.SetDestination(target.transform.position);
     while (!IsTargetInRange(target))
     {
         yield return(new WaitForEndOfFrame());
     }
     yield return(new WaitForEndOfFrame());
 }
Esempio n. 9
0
 private void ProcessMouseOverTerrain(Vector3 destination)
 {
     if (Input.GetMouseButton(0) == true)
     {
         StopAllCoroutines();
         weaponSystem.StopAttacking();
         character.SetDestination(destination);
     }
 }
Esempio n. 10
0
        IEnumerator MoveToTarget(EnemyAI target)
        {
            character.SetDestination(target.transform.position);

            // allowing the character to continue to move to it's destination
            while (!IsTargetInRange(target.gameObject))
            {
                yield return(new WaitForEndOfFrame());
            }
            yield return(new WaitForEndOfFrame());
        }
Esempio n. 11
0
 IEnumerator Patrol()
 {
     state = State.patrolling;
     while (patrolPath != null)
     {
         Vector3 nextWaypointPos = patrolPath.transform.GetChild(nextWaypointIndex).position;
         character.SetDestination(nextWaypointPos);
         CycleWaypoint(nextWaypointPos);
         yield return(new WaitForSecondsRealtime(waypointTime));
     }
 }
Esempio n. 12
0
 IEnumerator Patrol()
 {
     state = State.patrolling;
     while (true)
     {
         Vector3 nextWaypointPos = patrolPath.transform.GetChild(nextWaypointIndex).position;
         character.SetDestination(nextWaypointPos);
         CycleWaypointWhenClose(nextWaypointPos);
         yield return(new WaitForSeconds(waypointDwellTime));
     }
 }
Esempio n. 13
0
 IEnumerator Patrol()
 {
     while (patrollPathContainer != null)
     {
         Vector3 nextWaypointPosition = patrollPathContainer.transform.GetChild(nextWaypointIndex).position;
         character.SetDestination(nextWaypointPosition);
         CycleWaypointWhenClose(nextWaypointPosition);
         yield return(new WaitForSecondsRealtime(dwellTime));
     }
     yield return(new WaitForEndOfFrame());
 }
 void OnMouseOverPotentiallyWalkable(Vector3 destination)  // reads LMB from CameraRaycaster if walkable layer hit
 {
     if (Input.GetMouseButton(0) && !shiftPressed && !character.IsDefending && !character.IsAttacking && !character.IsResting)
     {
         weaponSystem.StopAttacking(); // if target is fighting, stop the fight before moving
         character.SetDestination(destination);
     }
     else if (Input.GetMouseButton(0) && shiftPressed && !character.IsDefending && !character.IsAttacking)
     {
         var currentTransform = Vector3.Lerp(transform.position, destination, 2f);
         transform.LookAt(currentTransform);
     }
 }
Esempio n. 15
0
        IEnumerator Patrol()
        {
            state = State.patrolling;
            while (patrolPath != null)
            {
                Vector3 nextWaypointPosition = patrolPath.transform.GetChild(nextWaypointIndex).position;
                character.SetDestination(nextWaypointPosition);
                CycleWaypointWhenClose(nextWaypointPosition);
                yield return(new WaitForSeconds(waypointDwellTime));
            }

            //audioManager.PlayMusicBattle(combatMusic, false);
        }
Esempio n. 16
0
        IEnumerator Patrol()
        {
            state = State.patroling;
            int nextWaypointIndex = 0;

            while (patrolPath != null)
            {
                Vector3 destinationWaypoint = patrolPath.GetChild(nextWaypointIndex).position;
                character.SetDestination(destinationWaypoint);
                nextWaypointIndex = GetNextWaypointIndex(destinationWaypoint, nextWaypointIndex);
                yield return(new WaitForSeconds(timeToWaitAtWaypoint));
            }
        }
Esempio n. 17
0
        private IEnumerator Patrol()
        {
            currentState = State.Patrol;

            while (true)
            {
                Vector3 nextWaypointPosition = patrolPath.transform.GetChild(nextWaypointIndex).position;
                //Set destination
                enemyCharacter.SetDestination(nextWaypointPosition);
                //Cycle waypoints
                SwitchToNextWaypoint(nextWaypointPosition);

                yield return(new WaitForSeconds(.5f));
            }
        }
Esempio n. 18
0
 void OnMouseOverPotentiallyWalkable(Vector3 destination)
 {
     if (Input.GetMouseButton(0))
     {
         playerCharacter.SetDestination(destination);
     }
 }
Esempio n. 19
0
        IEnumerator Patrol()
        {
            state = State.patrolling;

            while (patrolPath != null)
            {
                //work out where to go next
                Vector3 nextWaypointPos = patrolPath.transform.GetChild(nextWaypointIndex).position;
                //tell character to go there
                character.SetDestination(nextWaypointPos);
                //cycle waypoints
                CycleWaypointWhenClose(nextWaypointPos);
                //wait at a waypoint
                float randWaypointDwellTime = UnityEngine.Random.Range(waypointDwellTimeMin, waypointDwellTimeMax);
                yield return(new WaitForSeconds(randWaypointDwellTime));
            }
        }
Esempio n. 20
0
        // IEnumerator ChasePlayer()
        // {
        //     state = States.chasing;
        //     while( distanceToPlayer >= currentWeaponRange )
        //     {
        //         character.SetDestination(player.transform.position);
        //         yield return new WaitForEndOfFrame();
        //     }
        // }

        public void ChasePlayer()
        {
            character.SetDestination(player.transform.position);
        }