예제 #1
0
        public void ChangeBest(AISController ctrl)
        {
            if (!controllers.Contains(ctrl))
            {
                return;
            }

            if (children.Count != 0)
            {
                AISAction best = BestAction(ctrl);
                if (best != bestChild[ctrl])
                {
                    bestChild[ctrl].OnActionExit(ctrl);
                    bestChild[ctrl] = best;
                    bestChild[ctrl].OnActionEnter(ctrl);
                }
            }
        }
예제 #2
0
        private void CreateChildOptions()
        {
            GUILayout.BeginHorizontal();
            newChildType = AISEditorUtil.allActions[EditorGUILayout.Popup("New Child Type:", AISEditorUtil.allActions.IndexOf(newChildType), AISEditorUtil.allActions.Select(x => x.Name).ToArray())];

            if (GUILayout.Button("Create new child"))
            {
                AISAction child = CreateInstance(newChildType) as AISAction;
                if (child != null)
                {
                    child.name   = "New";
                    child.order  = order + 1;
                    child.parent = this;
                    child.ai     = ai;
                    SODatabase.Add(this, child, children);
                }
            }
            GUILayout.EndHorizontal();
        }
예제 #3
0
        void EliminateAction(AISAction root)
        {
            for (int d = 0; d < root.children.Count; d++)
            {
                AISAction a = root.children[d];
                root.children.Remove(a);
                EliminateAction(a);
            }

            for (int i = 0; i < root.scorers.Count; i++)
            {
                AISScorer s = root.scorers[i];
                root.scorers.Remove(s);
                DestroyImmediate(s, true);
            }

            root.parent.children.Remove(root);
            DestroyImmediate(root, true);
        }
예제 #4
0
        void ShowActions(AISAction root)
        {
            GUILayout.BeginVertical();
            GUILayout.BeginHorizontal();

            string n = root.name + ": " + root.GetMinScore() + " - " + root.GetMaxScore();

            if (root.children.Count == 0)
            {
                EditorGUILayout.LabelField(n);
            }
            else
            {
                root.showChildren = EditorGUILayout.Foldout(root.showChildren, n);
            }

            if (GUILayout.Button("Select"))
            {
                selectedAction = root;
            }

            if (root.order != 0)
            {
                if (GUILayout.Button("Eliminate"))
                {
                    EliminateAction(root);
                }
            }

            GUILayout.EndHorizontal();

            if (root.showChildren)
            {
                for (int d = 0; d < root.children.Count; d++)
                {
                    ++EditorGUI.indentLevel;
                    ShowActions(root.children[d]);
                    --EditorGUI.indentLevel;
                }
            }
            GUILayout.EndVertical();
        }