コード例 #1
0
ファイル: PlanTree.cs プロジェクト: ming81/TotalAI
        private void DrawAgent(Rect position, Agent agent, AgentType agentType, bool resetPlans, TotalAIManager totalAIManager)
        {
            if (agent == null)
            {
                return;
            }

            allCurrentPlans = agent.decider.AllCurrentPlans;

            Plans selectedPlans = null;

            if (allCurrentPlans != null && allCurrentPlans.TryGetValue(selectedDrive, out selectedPlans) &&
                selectedPlans.rootMappings != null && selectedPlans.rootMappings.Count > 0)
            {
                if (selectedPlan == -1 && agent != null)
                {
                    selectedPlan = agent.decider.CurrentPlanIndex;
                }
                else if (selectedPlan == -1)
                {
                    selectedPlan = 0;
                }

                List <Mapping> rootMappings = selectedPlans.rootMappings;
                if (onlyComplete)
                {
                    rootMappings = selectedPlans.GetCompletePlans();
                }

                string title = (agent != null ? agent.name : agentType.name) + " : " + (selectedPlan + 1) + "/" +
                               rootMappings.Count + "\n" + selectedPlans.driveType.name;

                GUI.Box(new Rect(position.width / 2 - 175 / 2, 10, 175, 35), title, "Button");
                if (agent != null)
                {
                    onlyComplete = GUI.Toggle(new Rect(position.width / 2 + 175 / 2 + 10, 10, 175, 25), onlyComplete, "Complete Plans");
                }

                if (GUI.Button(new Rect(position.width / 2 - 175 / 2, 45, 50, 25), "Down"))
                {
                    --selectedPlan;
                }
                if (agent != null && GUI.Button(new Rect(position.width / 2 - 175 / 2 + 50, 45, 75, 25), "Current"))
                {
                    selectedPlan  = agent.decider.CurrentPlanIndex;
                    selectedDrive = agent.decider.CurrentDriveType;
                }
                if (GUI.Button(new Rect(position.width / 2 - 175 / 2 + 125, 45, 50, 25), "Up"))
                {
                    ++selectedPlan;
                }

                //DrawICTCheckBoxes(agentType, totalAIManager);

                if (selectedPlan >= rootMappings.Count)
                {
                    selectedPlan = 0;
                }
                else if (selectedPlan < 0)
                {
                    selectedPlan = rootMappings.Count - 1;
                }

                if (selectedPlan < rootMappings.Count)
                {
                    if (agent != null)
                    {
                        rootMappings[selectedPlan].Draw(position.width / 2 - 175 / 2, 80, 175, 75, 120, 100, agent.decider.CurrentMapping, agent);
                        DrawPlanStats(position, selectedPlans);
                    }
                    else
                    {
                        rootMappings[selectedPlan].Draw(position.width / 2 - 175 / 2, 80, 175, 75, 120, 100, null, null);
                    }
                }
            }
            else if (selectedPlans != null)
            {
                selectedPlan = -1;
                GUI.Box(new Rect(position.width / 2 - 200 / 2, 10, 200, 35), "Planned - No Plans Found",
                        new GUIStyle("largeLabel")
                {
                    alignment = TextAnchor.MiddleCenter
                });
            }
            else
            {
                selectedPlan = -1;
                GUI.Box(new Rect(position.width / 2 - 175 / 2, 10, 175, 35), "Did Not Plan",
                        new GUIStyle("largeLabel")
                {
                    alignment = TextAnchor.MiddleCenter
                });
            }
        }