private void processGoTarget() { INeed currentNeed = queue[0].need; var gos = GameObject.FindObjectsOfType(currentNeed.satisfyType) as Objects.IObject[]; Debug.Log("Found " + gos.Length + " object that can satisfy need"); var target = gos .Where(e => e.canBeUsed()) .OrderBy(e => Vector3.Distance(e.transform.position, transform.position)) .FirstOrDefault(); if (!target) { Debug.Log("Could not find target to satisfy " + currentNeed.GetAction()); return; } objToInteract = target; traveler.SetTarget(target); }
public void processCurrent() { if (currentStep == queue[0].need.GetSteps().Count) { finishedOne(); objToInteract = null; currentStep = 0; if (queue.Count != 0 && !queue[0].need.GetSteps().Any(e => e == MemberSteps.ACT)) { Debug.LogError("No ACT on current need: " + queue[0].need.GetAction() + ", useless action ?"); } Debug.Log("New current target: " + queue[0].need.GetAction()); } if (queue.Count == 0) { return; } List <MemberSteps> steps = queue[0].need.GetSteps(); switch (steps[currentStep]) { case MemberSteps.ACT: processAct(); break; case MemberSteps.GO_HERE: processGoHere(); break; case MemberSteps.GO_HOME: processGoHome(); break; case MemberSteps.GO_TARGET: processGoTarget(); break; } }
public void SetTarget(Objects.IObject obj) { Debug.Log("Travelling to " + obj.name); currentTarget = obj.transform; }
public void RegisterNewObject(Objects.IObject obj) { ownedObjects.Add(obj); }
public void UnregisterObject(Objects.IObject oldObj) { ownedObjects.Remove(oldObj); }