コード例 #1
0
    // Use this for initialization
    void Start()
    {
        TreeBrains = GetComponent <UAI_Agent> ();
        TreeBrains.SetVoidActionDelegate("Heal", Heal);
        TreeBrains.SetVoidActionDelegate("InfluencePlants", InfluencePlants);
        TreeBrains.SetVoidActionDelegate("SpawnCritters", SpawnCritters);

        LandScript = GameObject.Find("Terrain_0_0-20181102-101609").GetComponent <Land> ();
    }
コード例 #2
0
    void Start()
    {
        _UAIagent = GetComponent <UAI_Agent> ();
        _navAgent = GetComponent <NavMeshAgent> ();

        _UAIagent.SetVoidActionDelegate("Eating", Eating);
        _UAIagent.SetVoidActionDelegate("Urinate", Urinate);
        _UAIagent.SetVoidActionDelegate("Playing", Playing);
    }
コード例 #3
0
    void Start()
    {
        agent          = GetComponent <UAI_Agent> ();
        preDestination = transform.position;

        //add function delegate to action
        agent.SetVoidActionDelegate("Sleep", Sleep);
        agent.SetVoidActionDelegate("Shower", Shower);
        agent.SetVoidActionDelegate("Eat at Restaurant", EatAtRestaurant);
        agent.SetVoidActionDelegate("Eat at Home", EatAtHome);
        agent.SetVoidActionDelegate("Watch Movie", WatchMovie);
        agent.SetVoidActionDelegate("Get Groceries", GetGroceries);
        agent.SetVoidActionDelegate("Drink Coffee", DrinkCoffee);
        agent.SetVoidActionDelegate("Work", Work);
        agent.SetVoidActionDelegate("Work at Home", WorkAtHome);
    }
コード例 #4
0
 public void SetAgent(UAI_Agent p_agent)
 {
     agent = p_agent;
     SetAgentUI();
 }
コード例 #5
0
ファイル: OverlayUI.cs プロジェクト: fachryip/UtilityAI
    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;
        }
    }