void SetDestination() { this.NotifyObservers(currentDestination.destination, nextDestination.destination); currentDestination = nextDestination; if (agent.isOnNavMesh) { agent.SetDestination(currentDestination.destination.transform.position); } if (currentDestination.Equals(sheldule[sheldule.Count - 1])) { nextDestination = sheldule[0]; waitForNextDay = true; } else { nextDestination = sheldule[sheldule.FindIndex(isCurrent) + 1]; } //go.GetComponent<Renderer>().material = currentDestination.destination.GetComponent<DestinationInfo>().destinationMaterial; }
void SetDestination(float _timeOfDay) {//TODO: rewrite logic for the next destiantion //TODO: combine this and other SetDestianion method ShelduleInfo last = sheldule[0]; foreach (ShelduleInfo info in sheldule) { if (info.time > _timeOfDay) { if (agent.isOnNavMesh) { agent.SetDestination(last.destination.transform.position); } currentDestination = last; nextDestination = info; break; } else { last = info; } } if (currentDestination.Equals(sheldule[sheldule.Count - 1])) { nextDestination = sheldule[0]; waitForNextDay = true; } if (currentDestination.destination == null) { currentDestination = sheldule[0]; nextDestination = sheldule[1]; } //go.GetComponent<Renderer>().material = currentDestination.destination.GetComponent<DestinationInfo>().destinationMaterial; }
private bool isCurrent(ShelduleInfo name) { return(name.Equals(currentDestination)); }