示例#1
0
    //Display properties of the GAgent in the Inspector
    public override void OnInspectorGUI()
    {
        //Draw the default items in the Inspector as Unity would without
        //this script
        DrawDefaultInspector();

        //syncronise values from the running of the code eith the script properties
        serializedObject.Update();

        //get the agent game object so the GAgent and associated properties can
        //be displayed
        GAgentVisual agent = (GAgentVisual)target;

        GUILayout.Label("Name           : " + agent.name);
        GUILayout.Label("Current Action : " + agent.gameObject.GetComponent <GAgent>().currentAction);
        GUILayout.Label("Actions        : ");
        foreach (GAction a in agent.gameObject.GetComponent <GAgent>().actions)
        {
            string pre = "";
            string eff = "";

            foreach (KeyValuePair <string, int> p in a.preconditions)
            {
                pre += p.Key + ", ";
            }
            foreach (KeyValuePair <string, int> e in a.effects)
            {
                eff += e.Key + ", ";
            }

            GUILayout.Label("====  " + a.actionName + "(" + pre + ")(" + eff + ")");
        }
        GUILayout.Label("Goals: ");
        foreach (KeyValuePair <SubGoal, int> g in agent.gameObject.GetComponent <GAgent>().goals)
        {
            //GUILayout.Label("---: ");
            foreach (KeyValuePair <string, int> sg in g.Key.sGoals)
            {
                GUILayout.Label("=====  " + sg.Key);
            }
        }
        GUILayout.Label("Beliefs: ");
        foreach (KeyValuePair <string, int> sg in agent.gameObject.GetComponent <GAgent>().beliefs.GetStates())
        {
            GUILayout.Label("=====  " + sg.Key);
        }

        GUILayout.Label("Inventory: ");
        foreach (GameObject g in agent.gameObject.GetComponent <GAgent>().inventory.items)
        {
            GUILayout.Label("====  " + g.tag);
        }


        serializedObject.ApplyModifiedProperties();
    }
示例#2
0
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();
        serializedObject.Update();
        GAgentVisual agent = (GAgentVisual)target;

        GUILayout.Label("Name: " + agent.name);
        GUILayout.Label("Current Action: " + agent.gameObject.GetComponent <GAgent>().currentAction);
        GUILayout.Label("Actions: ");
        foreach (GAction a in agent.gameObject.GetComponent <GAgent>().actions)
        {
            string pre = "";
            string eff = "";

            foreach (KeyValuePair <string, int> p in a.preConditions)
            {
                pre += p.Key + ", ";
            }
            foreach (KeyValuePair <string, int> e in a.effects)
            {
                eff += e.Key + ", ";
            }

            GUILayout.Label("====  " + a.actionName + "(" + pre + ")(" + eff + ")");
        }
        GUILayout.Label("Goals: ");
        foreach (KeyValuePair <SubGoal, int> g in agent.gameObject.GetComponent <GAgent>().goals)
        {
            GUILayout.Label("---: ");
            foreach (KeyValuePair <string, int> sg in g.Key.sgoals)
            {
                GUILayout.Label("=====  " + sg.Key);
            }
        }
        GUILayout.Label("Beliefs: ");
        Dictionary <string, int> beliefs = agent.gameObject.GetComponent <GAgent>().beliefs.GetStates();

        GUILayout.Label("---: ");
        foreach (KeyValuePair <string, int> b in beliefs)
        {
            GUILayout.Label("=====  " + b.Key);
        }
        GUILayout.Label("Inventory: ");
        List <GameObject> inventory = agent.gameObject.GetComponent <GAgent>().inventory.GetItems();

        GUILayout.Label("---: ");
        foreach (GameObject i in inventory)
        {
            GUILayout.Label("=====  " + i);
        }
        serializedObject.ApplyModifiedProperties();
    }
示例#3
0
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();
        serializedObject.Update();
        GAgentVisual agent = (GAgentVisual)target;

        GUILayout.Label("Name: " + agent.name);
        GUILayout.Label("Current Action: " + agent.gameObject.GetComponent <GAgent>().currentAction);
        GUILayout.Label("Actions: ");

        for (int i = 0; i < agent.gameObject.GetComponent <GAgent>().actions.Count; i++)
        {
            GAction a   = agent.gameObject.GetComponent <GAgent>().actions[i];
            string  pre = "";
            string  eff = "";

            foreach (KeyValuePair <AgentStates, int> p in a.preconditions)
            {
                pre += p.Key + ", ";
            }
            foreach (KeyValuePair <AgentStates, int> e in a.effects)
            {
                eff += e.Key + ", ";
            }

            GUILayout.Label(i + "===  " + a.actionName + "(" + pre + ")(" + eff + ")");
        }

        GUILayout.Label("Goals: ");
        foreach (KeyValuePair <SubGoal, int> g in agent.gameObject.GetComponent <GAgent>().goals)
        {
            GUILayout.Label("---: ");
            foreach (KeyValuePair <AgentStates, int> sg in g.Key.sgoal)
            {
                GUILayout.Label("=====  " + sg.Key);
            }
        }
        serializedObject.ApplyModifiedProperties();
    }