Ejemplo n.º 1
0
    void OnGUI()
    {
        if (!agent)
        {
            return;
        }

        GUI.skin = Manager().guiSkin;

        GUILayout.BeginArea(new Rect(Screen.width - 200 - 10, 10, 200, Screen.height - 10));

        GUILayout.BeginVertical("box");
        GUILayout.Label(agent.lastEventName);
        GUILayout.Label(agent.AIStateDescription());

        GUILayout.BeginHorizontal();
        Tab("Status");
        Tab("DNA");
        Tab("Food");
        Tab("Sex");
        GUILayout.EndHorizontal();


        if (TabContent("Status"))
        {
            GUILayout.Label("INFO");
            GUILayout.Label("Energy: " + FractionAndPercent(agent.energy, agent.body.MaxEnergy()));
            GUILayout.Label("Will starve in " + SimpleFloat(agent.body.TimeUntilStarvation()) + "s.");
            GUILayout.Label("Age: " + FractionAndPercent(agent.Age(), agent.body.Lifespan()));
            if (agent.reproductiveSystem.IsChild())
            {
                GUILayout.Label("Child for " + SimpleFloat(agent.reproductiveSystem.ChildLength() - agent.Age()) + "s");
            }
            else
            {
                GUILayout.Label("Adult");
            }
        }

        if (TabContent("DNA"))
        {
            GUILayout.Label("INHERITED TRAITS");
            foreach (var pair in agent.Traits())
            {
                NumericalTrait trait = pair.Value as NumericalTrait;
                if (trait != null)
                {
                    GUILayout.Label(pair.Key + ": " + SimpleFloat(trait.floatValue));
                }
            }

            GUILayout.Label("CALCULATED TRAITS");

            GUILayout.Label("Speed: " + SimpleFloat(agent.body.Speed()));
            GUILayout.Label("Strength: " + SimpleFloat(agent.body.Strength()));
            GUILayout.Label("EnergyDrainPerSecond: " + SimpleFloat(agent.body.EnergyDrainPerSecond()));
            GUILayout.Label("MaxEnergy: " + SimpleFloat(agent.body.MaxEnergy()));
            GUILayout.Label("CamouflageFactor: " + agent.body.CamouflageFactor());
        }

        if (TabContent("Food"))
        {
            GUILayout.Label("Meals eaten: " + agent.hungerCenter.timesEaten);

            GUILayout.Label("Herbivore: " + agent.hungerCenter.herbivore.boolValue);
            GUILayout.Label("Hay eaten: " + agent.hungerCenter.timesEatenVeg);

            GUILayout.Label("Carnivore: " + agent.hungerCenter.herbivore.boolValue);
            GUILayout.Label("Meat eaten: " + agent.hungerCenter.timesEatenMeat);
        }

        //DrawProgressBar(new Rect(0, 0, 200, 16), agent.energy / agent.body.MaxEnergy());

        if (TabContent("Sex"))
        {
            GUILayout.Label("Generation: " + agent.reproductiveSystem.generation);
            GUILayout.Label("Times reproduced: " + agent.reproductiveSystem.timesReproduced);

            GUILayout.Label("PARENTS");
            Agent[] parents = agent.reproductiveSystem.parents;
            if (parents != null)
            {
                int i = 1;
                foreach (Agent parent in parents)
                {
                    if (GUILayout.Button("Select Parent " + i + " (Gen " + parent.reproductiveSystem.generation + ")"))
                    {
                        Manager().SelectAgent(parent);
                    }
                    i++;
                }
            }
            if (parents == null || parents.Length < 1)
            {
                GUILayout.Label("No parents");
            }

            GUILayout.Label("CHILDREN");
            // Agent[] children = agent.reproductiveSystem.children;
            // if (children == null || children.Length < 1) {
            //   GUILayout.Label("No children");
            // }
        }

        GUILayout.EndVertical();
        GUILayout.EndArea();
    }