private void RebuildTree(Skill.Framework.AI.Behavior behavior, Skill.Framework.AI.BehaviorContainer container, Panel parent) { if (behavior == null) { return; } BaseControl control = CreateNode(behavior, container); parent.Controls.Add(control); switch (behavior.Type) { case Skill.Framework.AI.BehaviorType.Composite: Skill.Framework.AI.Composite composite = (Skill.Framework.AI.Composite)behavior; foreach (var b in composite) { RebuildTree(b.Behavior, b, (Panel)control); } break; case Skill.Framework.AI.BehaviorType.Decorator: Skill.Framework.AI.Decorator decorator = (Skill.Framework.AI.Decorator)behavior; if (decorator.Child != null) { RebuildTree(decorator.Child.Behavior, decorator.Child, (Panel)control); } break; default: break; } }
private GUIStyle GetStyle(Skill.Framework.AI.Behavior behavior, Skill.Framework.AI.BehaviorContainer container) { if (container != null) { return(GetStyle(container.Result)); } else { return(GetStyle(behavior.Result)); } }
private BaseControl CreateNode(Skill.Framework.AI.Behavior behavior, Skill.Framework.AI.BehaviorContainer container) { BaseControl control = null; switch (behavior.Type) { case Skill.Framework.AI.BehaviorType.Action: case Skill.Framework.AI.BehaviorType.Condition: case Skill.Framework.AI.BehaviorType.ChangeState: Label lbl = new Label(); lbl.Style = _FailurStyle; lbl.Content.text = behavior.Name; BehaviorTag bt = new BehaviorTag(behavior, container, lbl); _Behaviors.Add(bt); control = lbl; if (behavior.Type == Framework.AI.BehaviorType.Action) { lbl.Content.image = Resources.UITextures.BTree.Action; } else if (behavior.Type == Framework.AI.BehaviorType.ChangeState) { lbl.Content.image = Resources.UITextures.BTree.ChangeState; } else if (behavior.Type == Framework.AI.BehaviorType.Condition) { lbl.Content.image = Resources.UITextures.BTree.Condition; } break; case Skill.Framework.AI.BehaviorType.Decorator: case Skill.Framework.AI.BehaviorType.Composite: Skill.Editor.UI.FolderView fw = new UI.FolderView(); fw.Foldout.Style = _FailurStyle; fw.Foldout.Content.text = behavior.Name; fw.Foldout.IsOpen = true; CompositeTag ct = new CompositeTag(behavior, container, fw); _Composites.Add(ct); control = fw; if (behavior.Type == Framework.AI.BehaviorType.Composite) { Skill.Framework.AI.Composite composite = (Skill.Framework.AI.Composite)behavior; switch (composite.CompositeType) { case Skill.Framework.AI.CompositeType.Sequence: fw.Foldout.Content.image = Resources.UITextures.BTree.Sequence; break; case Skill.Framework.AI.CompositeType.Concurrent: fw.Foldout.Content.image = Resources.UITextures.BTree.Concurrent; break; case Skill.Framework.AI.CompositeType.Random: fw.Foldout.Content.image = Resources.UITextures.BTree.Random; break; case Skill.Framework.AI.CompositeType.Priority: case Skill.Framework.AI.CompositeType.State: fw.Foldout.Content.image = Resources.UITextures.BTree.Priority; break; case Skill.Framework.AI.CompositeType.Loop: fw.Foldout.Content.image = Resources.UITextures.BTree.Loop; break; } } else if (behavior.Type == Framework.AI.BehaviorType.Decorator) { Skill.Framework.AI.Decorator decorator = (Skill.Framework.AI.Decorator)behavior; switch (decorator.DecoratorType) { case Skill.Framework.AI.DecoratorType.Default: fw.Foldout.Content.image = Resources.UITextures.BTree.Decorator; break; case Skill.Framework.AI.DecoratorType.AccessLimit: fw.Foldout.Content.image = Resources.UITextures.BTree.AccessLimitDecorator; break; } } break; } return(control); }
public CompositeTag(Skill.Framework.AI.Behavior behavior, Skill.Framework.AI.BehaviorContainer container, Skill.Editor.UI.FolderView folder) { this.Container = container; this.Behavior = behavior; this.Folder = folder; }
public BehaviorTag(Skill.Framework.AI.Behavior behavior, Skill.Framework.AI.BehaviorContainer container, Label label) { this.Container = container; this.Behavior = behavior; this.Label = label; }