public override void Act() { int currentHealth = mover.gameObject.GetComponent <Health>().HealthPoints; if (currentHealth <= 30 && campingMedkit != null) { AimTowardsTarget(campingMedkit); mover.Move(Mover.Foward); } else if (currentHealth >= 30 && campingMedkit != null) { if (ennemyController.CalculateDistanceWithTarget(campingMedkit) > 15) { AimTowardsTarget(campingMedkit); mover.Move(Mover.Foward); } else { if (target == null) { mover.Rotate(Mover.Clockwise); } else { if (target.GetComponentInChildren <EnnemyController>().CalculateDistanceWithTarget(campingMedkit) <= 50) { AimTowardsTarget(campingMedkit); mover.Move(Mover.Foward); } else { AimTowardsTarget(target); handController.Use(); } } } } else if (campingMedkit == null) { if (target != null && !target.transform.root.CompareTag(Tags.Ennemy)) { AimTowardsTarget(target); } RotateFromBorders(mover); mover.Move(Mover.Foward); } }
private void TrackEnnemy(GameObject targetedObject) { float distance = ennemyController.CalculateDistanceWithTarget(targetedObject); if (distance > 30) { mover.Move(Mover.Foward); } else { if (!(mover.gameObject.transform.position.x * mover.gameObject.transform.position.x >= Screen.width / 2 || mover.gameObject.transform.position.y * mover.gameObject.transform.position.y >= Screen.height / 2)) { mover.Move(Mover.Backward); } } }
private bool IsFarFromTarget() { return(ennemyController.CalculateDistanceWithTarget(currentEnnemyTarget.gameObject) > minimumDistanceBetweenEnnemies); }