public override bool checkProceduralPrecondition(GameObject agent) { // find the nearest supply pile that has spare firewood StoragePile[] storagepiles = (StoragePile[])UnityEngine.GameObject.FindObjectsOfType(typeof(StoragePile)); StoragePile closest = null; float closestDist = 0; foreach (StoragePile storage in storagepiles) { if (closest == null) { //making sure that the pile actually has sticks in it.. lets hope this method works if (storage.numSticks > 0) { // first one, so choose it for now closest = storage; closestDist = (storage.gameObject.transform.position - agent.transform.position).magnitude; } //if it doesnt return a false to path finding else { return(false); } } else { // is this one closer than the last? float dist = (storage.gameObject.transform.position - agent.transform.position).magnitude; if (dist < closestDist) { // we found a closer one, use it closest = storage; closestDist = dist; } } } if (closest == null) { return(false); } targetpile = closest; target = targetpile.gameObject; return(closest != null); }
public override bool checkProceduralPrecondition(GameObject agent) { //nearest storage StoragePile[] storages = (StoragePile[])UnityEngine.GameObject.FindObjectsOfType(typeof(StoragePile)); StoragePile closest = null; float closestDist = 0; foreach (StoragePile storage in storages) { if (closest == null) { // first one, so choose it for now if (storage.numfood > 0) { closest = storage; closestDist = (storage.gameObject.transform.position - agent.transform.position).magnitude; } else { return(false); } } else { // is this one closer than the last? float dist = (storage.gameObject.transform.position - agent.transform.position).magnitude; if (dist < closestDist) { // we found a closer one, use it closest = storage; closestDist = dist; } } } if (closest == null) { return(false); } targetstorage = closest; target = targetstorage.gameObject; return(closest != null); }
public override void reset() { hasFood = false; targetstorage = null; startTime = 0; }
public override void reset() { hasPickedUpSticks = false; targetpile = null; startTime = 0; }
public override void reset() { hasDroppedOffFood = false; targetStorage = null; startTime = 0; }