public HuntedTarget Scan() { int highestPriority = -1; HuntedTarget bestTarget = null; //print("Scanning"); foreach (HuntedTarget t in GameObject.FindObjectsOfType <HuntedTarget>()) { //print(t.IsValidTarget()); if (!t.IsValidTarget()) { continue; } if (Vector3.Distance(t.transform.position, transform.position) > sightRange) { continue; } RaycastHit hit; if (Physics.Raycast(t.transform.position, transform.position - t.transform.position, out hit, sightRange)) { if (hit.collider.gameObject == gameObject) { if (t.GetPriority() > highestPriority) { highestPriority = t.GetPriority(); bestTarget = t; } } } } return(bestTarget); }
//------------------------------------------------------------ // determines if there is a transmitter to attack //------------------------------------------------------------ bool AssessHostile() { if (killConfirmTimer > 0f) { return(true); } target = eyes.Scan(); return(target != null && target.IsValidTarget()); }
//------------------------------------------------------------ // responds to the hunted script as to whether this has already been broken //------------------------------------------------------------ public void IsHuntable(HuntedTarget ht) { //print("Broken: " + broken + " / Start: " + isStartTransmitter); ht.SetValidTarget(!broken && !isStartTransmitter); }