public override float WeightedTravelDistance(Vector3 start, Vector3 end, Guest guest) { Vector3 destination = _agent.destination; float toGuest = Guest.AgentWalkDistance(_agent, transform, transform.position, start, Color.green); float withGuest = Guest.AgentWalkDistance(_agent, transform, transform.position, end, Color.green); UpdateDestination(destination); if (toGuest == Mathf.Infinity || withGuest == Mathf.Infinity) { return(Mathf.Infinity); } float distance = toGuest + withGuest; distance /= Weight; return(distance); }
public override Vector3 EndPosition(Vector3 vec, Guest guest) { float dist = Mathf.Infinity; Vector3 endPosition = Vector3.zero; foreach (GameObject go in Path) { float distTemp = Guest.AgentWalkDistance(guest._agent, guest.transform, go.transform.position, vec, Color.green); if (dist < distTemp) { continue; //if the distance is less than distance temp, then we continue to next Path } dist = distTemp; endPosition = go.transform.position; } return(endPosition); }
public override Vector3 StartPosition(Vector3 vec, Guest guest) { float dist = Mathf.Infinity; Vector3 startPosition = Vector3.zero; foreach (GameObject go in Path) { float distTemp = Guest.AgentWalkDistance(guest._agent, guest.transform, guest.transform.position, go.transform.position, Color.blue); Debug.DrawLine(guest.transform.position, go.transform.position, Color.red); if (dist < distTemp) { continue; //if the distance is less than distance temp, then we continue to next Path } dist = distTemp; startPosition = go.transform.position; } return(startPosition); }
public override Destination GetDestination(Vector3 vec, Guest guest) { float dist = Mathf.Infinity; Destination destination = null; foreach (GameObject go in Path) { float distTemp = Guest.AgentWalkDistance(guest._agent, guest.transform, guest.transform.position, go.transform.position, Color.blue); if (dist < distTemp) { continue; //if the distance is less than distance temp, then we continue to next Path } if (!go.GetComponent <Destination>()) { continue; } dist = distTemp; destination = go.GetComponent <Destination>(); } Debug.Log(destination.name); return(destination); }