void Start() { isActive = true; currentWeapon = 0; equipmentAI = GetComponent <EquipmentAI>(); directProjectileWeapons = GetComponents <DirectProjectileWeapon>(); }
public override List <TargetRate> rateTargets(List <GameObject> detectedGameObjects) { List <TargetRate> targetRateList = new List <TargetRate> (); if (detectedGameObjects != null && detectedGameObjects.Count > 0) { //Wstępna filtracja obiektów List <GameObject> tempDetectedObjects = new List <GameObject>(); for (int i = 0; i < detectedGameObjects.Count; i++) { if (detectedGameObjects[i].GetComponent <Health>() != null && Team.isItMyAlly(gameObject, detectedGameObjects[i])) { tempDetectedObjects.Add(detectedGameObjects[i]); } } //Rating wybranych obiektów if (tempDetectedObjects.Count > 0) { float rate = 0f; float currentHealth = 0f; for (int i = 0; i < tempDetectedObjects.Count; i++) { //sprawdzenie poziomu życia currentHealth = tempDetectedObjects[i].GetComponent <Health>().getCurrentHealth() / tempDetectedObjects[i].GetComponent <Health>().MAX_HEALTH; if (currentHealth < 0.5) { rate = 8; } else { rate = 4; } //sprawdzenie czy poprzednio to był nasz cel EquipmentAI equipmentAI = GetComponent <EquipmentAI>(); if (equipmentAI != null && equipmentAI.lastTarget != null && equipmentAI.lastTarget == tempDetectedObjects[i]) { rate += 4; } //sprawdzenie odległości if (Vector3.Distance(transform.position, tempDetectedObjects[i].transform.position) < personalSpaceRadius) { rate += 5; } //normalizacja i zapisanie wyniku rate = rate / 17; targetRateList.Add(new TargetRate(tempDetectedObjects[i], rate)); } } } return(targetRateList); }
/** * Inicjalizacja po utworzeniu. * */ void Start() { rightListMovement = true; targetResolve = TargetResolveEnum.DONE; lastTargetLocation = new Vector3(0, 0, 0); lastAgentLocationOnPath = new Vector3(0, 0, 0); if (patrolPoints == null) { patrolPoints = new List <Vector3>(); } patrolPointsIndex = 0; navAgent = GetComponent <NavMeshAgent>(); health = GetComponent <Health>(); sense = GetComponent <OmniSense>(); equipmentAI = GetComponent <EquipmentAI> (); }
/** * Inicjalizacja po utworzeniu. * */ void Start() { rightListMovement = true; targetResolve = TargetResolveEnum.DONE; lastTargetLocation = new Vector3(0, 0, 0); lastAgentLocationOnPath = new Vector3(0, 0, 0); if(patrolPoints == null) { patrolPoints = new List<Vector3>(); } patrolPointsIndex = 0; navAgent = GetComponent<NavMeshAgent>(); health = GetComponent<Health>(); sense = GetComponent<OmniSense>(); equipmentAI = GetComponent<EquipmentAI> (); }
public override List <TargetRate> rateTargets(List <GameObject> detectedGameObjects) { List <TargetRate> targetRateList = new List <TargetRate> (); privateTarget = null; if (weapon != null) { if (detectedGameObjects != null && detectedGameObjects.Count > 0) { //Wstępna filtracja obiektów List <GameObject> tempDetectedObjects = new List <GameObject>(); for (int i = 0; i < detectedGameObjects.Count; i++) { if (CheckTargetValidity(detectedGameObjects[i])) { tempDetectedObjects.Add(detectedGameObjects[i]); } } //Rating wybranych obiektów if (tempDetectedObjects.Count > 0) { float rate = 0f; float rateNormalization = 1f; float currentHealth = 0f; for (int i = 0; i < tempDetectedObjects.Count; i++) { //sprawdzenie poziomu życia currentHealth = tempDetectedObjects[i].GetComponent <Health>().getCurrentHealth() / tempDetectedObjects[i].GetComponent <Health>().MAX_HEALTH; if (currentHealth < 0.5) { rate = 5; } else { rate = 0; } rateNormalization = 5; //sprawdzenie czy poprzednio to był nasz cel EquipmentAI equipmentAI = GetComponent <EquipmentAI>(); if (equipmentAI != null && equipmentAI.lastTarget != null && equipmentAI.lastTarget == tempDetectedObjects[i]) { rate += 10; rateNormalization += 10; } //sprawdzenie odległości if (Vector3.Distance(transform.position, tempDetectedObjects[i].transform.position) < personalSpaceRadius) { rate += 10; rateNormalization += 10; } //sprawdzenie czy możemy do niego strzelać if (RayTargetCheck(tempDetectedObjects[i])) { rate += 30; rateNormalization += 30; } //normalizacja i zapisanie wyniku rate = rate / rateNormalization; targetRateList.Add(new TargetRate(tempDetectedObjects[i], rate)); } } //Wybranie własnego celu TargetRate maxTargetRate = new TargetRate(null, 0); for (int i = 0; i < targetRateList.Count; i++) { if (targetRateList[i].getTargetRate() > maxTargetRate.getTargetRate()) { maxTargetRate = targetRateList[i]; } } privateTarget = maxTargetRate.getTarget(); } } return(targetRateList); }