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; } }
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); } }
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); } }
private void OnDeath(float deathDelay) { enabled = false; weaponSystem.StopAttacking(); var rigidBody = GetComponent <Rigidbody>(); rigidBody.useGravity = false; rigidBody.velocity = Vector3.zero; GetComponent <UnityEngine.AI.NavMeshAgent>().enabled = false; GetComponent <CapsuleCollider>().enabled = false; }
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); // } /////////////////////////////////////////////////////// }
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()); } }
private void OnMouseOverPossiblyWalkable(Vector3 destination) { if (Input.GetMouseButton(0)) { weaponSystem.StopAttacking(); character.SetDestination(destination); } }
void OnMousePotentionallyWalkable(Vector3 destionation) { if (Input.GetMouseButton(0)) { weaponSystem.StopAttacking(); character.SetDestination(destionation); } }
private void ProcessTerrainInteraction(Vector3 destination) { if (Input.GetMouseButton(0)) { weaponSystem.StopAttacking(); character.SetDestination(destination); } }
void OnMouseOverPotWalkable(Vector3 destination) { if (Input.GetMouseButton(0) && healthSystem.healthAsPercentage >= Mathf.Epsilon) { character.SetDestination(destination); weaponSystem.StopAttacking(); } }
void OnMouseOverTerrain(Vector3 destination) { if (Input.GetMouseButton(0)) { weaponSystem.StopAttacking(); character.SetDestination(destination); } }
private void ProcessMouseOverTerrain(Vector3 destination) { if (Input.GetMouseButton(0) == true) { StopAllCoroutines(); weaponSystem.StopAttacking(); character.SetDestination(destination); } }
public void OnMouseOverPotentiallyWalkable(Vector3 destination) { if (Input.GetMouseButton(0)) { StopAllCoroutines(); weaponSystem.StopAttacking(); currentEnemy = null; character.SetDesination(destination); } }
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 } }
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); } }
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(); } }
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); } }
private void StopAttacking() { StopAllCoroutines(); weaponSystem.StopAttacking(); }