public void DisplayConsiderations(UAI_Property property, bool selected) { for (int i = 0; i < considerationElements.Count; i++) { Destroy(considerationElements[i]); } considerationElements.Clear(); if (!selected) { if (selectedProperty != null) { for (int i = 0; i < propertyElements.Count; i++) { UAI_Property tempProperty = propertyElements[i].GetComponent <OverlayUIPropertyElement>().GetProperty(); if (selectedProperty == tempProperty) { propertyElements[i].GetComponent <OverlayUIPropertyElement> ().Select(); break; } } } for (int i = 0; i < displayedAgent.linkedActions.Count; i++) { for (int j = 0; j < displayedAgent.linkedActions[i].action.considerations.Count; j++) { if (displayedAgent.linkedActions [i].action.considerations [j].property == property) { GameObject tempCon = Instantiate(considerationElement, new Vector3(considerationContent.transform.position.x, considerationContent.transform.position.y + considerationElements.Count * -27, considerationContent.transform.position.z), Quaternion.identity) as GameObject; tempCon.transform.SetParent(considerationContent.transform); tempCon.GetComponent <OverlayUIConsiderationElement> ().SetConsideration( displayedAgent.linkedActions [i].action.considerations [j], false, displayedAgent.linkedActions[i].action.name); considerationElements.Add(tempCon); } } } considerationContent.GetComponent <RectTransform>().sizeDelta = new Vector2(200, considerationElements.Count * 27); utilityCurve.SetActive(false); displayingCurve = false; propertyConsiderationsPanel.SetActive(true); selectedProperty = property; } else { utilityCurve.SetActive(false); displayingCurve = false; propertyConsiderationsPanel.SetActive(false); selectedProperty = null; selectedPropertyConsideration = null; } }
public void SetProperty(UAI_Property p_property) { property = p_property; nameText.text = property.transform.name; }
public void DisplayAgent(UAI_Agent agent, bool selected) { for (int i = 0; i < actionElements.Count; i++) { Destroy(actionElements[i]); } for (int i = 0; i < considerationElements.Count; i++) { Destroy(considerationElements[i]); } for (int i = 0; i < propertyElements.Count; i++) { Destroy(propertyElements[i]); } actionElements.Clear(); considerationElements.Clear(); agentProperties.Clear(); propertyElements.Clear(); propertyConsiderationsPanel.SetActive(false); actionConsiderationsPanel.SetActive(false); selectedAction = null; selectedProperty = null; selectedActionConsideration = null; selectedPropertyConsideration = null; //deselect other agents if (!selected) { if (displayedAgent != null) { for (int i = 0; i < agentElements.Count; i++) { if (agentElements [i].GetComponent <OverlayUIAgentElement> ().GetAgent() == displayedAgent) { agentElements [i].GetComponent <OverlayUIAgentElement> ().Select(); break; } } } displayedAgent = agent; displayingAgent = true; for (int i = 0; i < agent.GetComponentsInChildren <UAI_Property>().Length; i++) { agentProperties.Add(agent.GetComponentsInChildren <UAI_Property> () [i]); } for (int i = 0; i < agentProperties.Count; i++) { GameObject tempProp; if (agentProperties [i].modifiable) { tempProp = Instantiate(ModifiablePropertyElement, new Vector3(propertyContent.transform.position.x, considerationContent.transform.position.y + propertyElements.Count * -27, considerationContent.transform.position.z), Quaternion.identity) as GameObject; } else { tempProp = Instantiate(PropertyElement, new Vector3(propertyContent.transform.position.x, considerationContent.transform.position.y + propertyElements.Count * -27, considerationContent.transform.position.z), Quaternion.identity) as GameObject; } tempProp.transform.SetParent(propertyContent.transform); tempProp.GetComponent <OverlayUIPropertyElement> ().SetProperty(agentProperties [i]); propertyElements.Add(tempProp); } propertyContent.GetComponent <RectTransform>().sizeDelta = new Vector2(200, propertyElements.Count * 27); for (int i = 0; i < agent.linkedActions.Count; i++) { //populate UI actions GameObject tempAct = Instantiate(actionElement, new Vector3(actionContent.transform.position.x + 100, actionContent.transform.position.y + actionElements.Count * -27, actionContent.transform.position.z), Quaternion.identity) as GameObject; tempAct.transform.SetParent(actionContent.transform); tempAct.GetComponent <OverlayUIActionElement> ().SetAction(agent.linkedActions[i].action); actionElements.Add(tempAct); } actionContent.GetComponent <RectTransform>().sizeDelta = new Vector2(200, actionElements.Count * 27); } else { displayingAgent = false; displayedAgent = null; } }