public int setTargetPlaque(BehaviourNode.callReturn finished)//ugly, fix { Plaque[] plaques = GameObject.FindObjectsOfType <Plaque>(); if (plaque == null) { Debug.Log(iD + " setting new random plaque"); int random = Random.Range(0, plaques.Length); this.setTarget(silver.Map[(int)plaques[random].transform.position.x, (int)plaques[random].transform.position.z]); plaque = plaques[random]; } else { Debug.Log(iD + " setting new plaque"); for (int i = 0; i < plaques.Length; i++) { if (plaques[i].transform.position.x == target.pos.x && plaques[i].transform.position.z == target.pos.z) { if (i < plaques.Length - 1) { this.setTarget(silver.Map[(int)plaques[i + 1].transform.position.x, (int)plaques[i + 1].transform.position.z]); plaque = plaques[i + 1]; break; } else { this.setTarget(silver.Map[(int)plaques[0].transform.position.x, (int)plaques[0].transform.position.z]); plaque = plaques[0]; break; } } } } finished(1); return(1); }
public IEnumerator moving(BehaviourNode.callReturn finished)//call from function above, instantiate in leafnode with LeafNode.DoSomething = student.beginJourney; { Debug.Log("Beginning Journey" + target.pos.x + " " + target.pos.z); yield return(new WaitUntil(() => this.transform.position.x == target.pos.x && this.transform.position.z == target.pos.z)); Debug.Log(iD + " Finished Moving"); finished(1); }
public int setRandom(BehaviourNode.callReturn finished) { Debug.Log(iD + " Going to Random Location"); this.setTarget(silver.Map[Random.Range(0, silver.Map.GetLength(0)), Random.Range(0, silver.Map.GetLength(1))]); while (!target.getPassable()) { this.setTarget(silver.Map[Random.Range(0, silver.Map.GetLength(0)), Random.Range(0, silver.Map.GetLength(1))]); } finished(1); return(1); }
public int isAdvisor(BehaviourNode.callReturn finished)//implement angular sweep here { if (ReferenceEquals(assigned, this.plaque.getProf())) { Debug.Log("Found Professor"); this.setTarget(plaque.getProf().getLocation()); finished(1); return(1); } else { Debug.Log("Not this professor"); finished(-1); return(-1); } }
public int profSaved(BehaviourNode.callReturn finished) { Tile t; if (last4Profs.TryGetValue(assigned, out t)) { Debug.Log("Saved Prof"); this.setTarget(t); finished(1); return(1); } else { Debug.Log("Not Saved Prof"); finished(-1); return(-1); } }
//find path is now done in pathfinder constantly, should always have a path to move along public int beginJourney(BehaviourNode.callReturn finished)//call this from a leafnode { StartCoroutine(moving(finished)); return(0); }