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); } }
private void onMouseOverWalkable(Vector3 destination) { if (Input.GetMouseButton(0)) { character.SetDestination(destination); } }
void OnMouseOverPotWalkable(Vector3 destination) { if (Input.GetMouseButton(0) && healthSystem.healthAsPercentage >= Mathf.Epsilon) { character.SetDestination(destination); weaponSystem.StopAttacking(); } }
void OnMousePotentionallyWalkable(Vector3 destionation) { if (Input.GetMouseButton(0)) { weaponSystem.StopAttacking(); character.SetDestination(destionation); } }
void OnMouseOverTerrain(Vector3 destination) { if (Input.GetMouseButton(0)) { weaponSystem.StopAttacking(); character.SetDestination(destination); } }
private void OnMouseOverPossiblyWalkable(Vector3 destination) { if (Input.GetMouseButton(0)) { weaponSystem.StopAttacking(); character.SetDestination(destination); } }
void Update() { ScanForAbilityKeyDown(); if (isAttacking && updatedTarget && updatedTarget.transform.hasChanged) { character.SetDestination(updatedTarget.transform.position); } }
IEnumerator MoveToTarget(GameObject target) { character.SetDestination(target.transform.position); while (!IsTargetInRange(target)) { yield return(new WaitForEndOfFrame()); } yield return(new WaitForEndOfFrame()); }
private void ProcessMouseOverTerrain(Vector3 destination) { if (Input.GetMouseButton(0) == true) { StopAllCoroutines(); weaponSystem.StopAttacking(); character.SetDestination(destination); } }
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()); }
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)); } }
IEnumerator Patrol() { state = State.patrolling; while (true) { Vector3 nextWaypointPos = patrolPath.transform.GetChild(nextWaypointIndex).position; character.SetDestination(nextWaypointPos); CycleWaypointWhenClose(nextWaypointPos); yield return(new WaitForSeconds(waypointDwellTime)); } }
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); } }
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); }
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)); } }
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)); } }
void OnMouseOverPotentiallyWalkable(Vector3 destination) { if (Input.GetMouseButton(0)) { playerCharacter.SetDestination(destination); } }
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)); } }
// 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); }