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); }
/// <summary> /// Sets the plaque attribute of this node as well as all its children. /// </summary> /// <param name="plaque">The plaque to set</param> public override void SetPlaque(Plaque plaque) { Plaque = plaque; foreach (var node in ChildrenNodes) { node.SetPlaque(plaque); } }
private void Awake() { instance = this; List <SpriteRenderer> renderers = new List <SpriteRenderer>(GetComponentsInChildren <SpriteRenderer>()); for (int i = 0; i < renderers.Count; ++i) { OriginalSortOrders.Add(renderers[i], renderers[i].sortingOrder); } List <TextMeshPro> textrenderers = new List <TextMeshPro>(GetComponentsInChildren <TextMeshPro>()); for (int i = 0; i < textrenderers.Count; ++i) { OriginalSortOrdersText.Add(textrenderers[i], textrenderers[i].sortingOrder); } OriginalZ = gameObject.transform.localPosition.z; OriginPosition = gameObject.transform.position; }
public PlaqueViewModel(Plaque plaque) { this.Plaque = plaque; this.items = new ObservableCollection <MovItem>(this.Plaque.MovItems); }
// Update is called once per frame void Update() { changeColor(mood); //implement hard-coded behaviour tree if (ReachTarget(targetPostion)) { //if reach a professor if (ReachTarget(GetPosByName(assignedProf))) { //50% chance go idle if (Random.Range(0, 2) == 0) { //go idle targetPostion = ReturnRandomPosition(); } else { //talk and being assigned to a new professor Professor newAssignedProf = profs[Random.Range(0, 6)]; assignedProf = newAssignedProf.getName(); //if remember assigned prof office if (IsRememberProf(newAssignedProf.getName())) { targetPostion = newAssignedProf.getPos(); } else { //if dont remember assigned prof office targetPostion = plaqs[Random.Range(0, 6)].getPos(); } } //if reach a plaque } else if (IsReachingAnyPlaque()) { Plaque reachedPlaque = GetPlaqueByPos(); string tempProName = reachedPlaque.getProfName(); //if the professor on plaque not in memory, add if (!IsRememberProf(tempProName)) { memory.Enqueue(new KeyValuePair <string, Vector3>(reachedPlaque.getProfName(), reachedPlaque.getProfPos())); } //if memory > 4, dequeue if (memory.Count > 4) { memory.Dequeue(); } if (tempProName.CompareTo(assignedProf) == 0) { targetPostion = reachedPlaque.getProfPos(); } else { targetPostion = plaqs[Random.Range(0, 6)].getPos(); } } //reach neither plaque nor prof, random position else { //wait for 0.5 - 3 s float waitTime = Random.Range(0.5f, 3f); // timer += Time.time; // if(timer> waitTime){ // timer = 0f; // // } //assigned a new professor Professor newAssignedProf = profs[Random.Range(0, 6)]; assignedProf = newAssignedProf.getName(); //if remember assigned prof office if (IsRememberProf(newAssignedProf.getName())) { targetPostion = newAssignedProf.getPos(); } else { //if dont remember assigned prof office targetPostion = plaqs[Random.Range(0, 6)].getPos(); } } } }
public virtual void SetPlaque(Plaque plaque) { Plaque = plaque; }