Пример #1
0
        public virtual void RefreshContent()
        {
            string name = Data.Name;

            if (Data is IParameterData)
            {
                if (Parent != null)
                {
                    TreeViewFolder folder = Parent as TreeViewFolder;
                    if (folder != null)
                    {
                        var parameters = folder.Data.GetParameters(folder.Controls.IndexOf(this));
                        if (parameters != null)
                        {
                            parameters.Match(((IParameterData)Data).ParameterDifinition);
                            if (parameters.Count > 0)
                            {
                                name += parameters.ToString();
                            }
                        }
                    }
                }
            }
            base.Content.text = name;
        }
Пример #2
0
 private bool CheckAddCauseLoop(TreeViewFolder parent, BehaviorData newBehavior)
 {
     while (parent != null)
     {
         if (parent.Data == newBehavior)
         {
             return(true);
         }
         parent = parent.Parent as TreeViewFolder;
     }
     return(false);
 }
Пример #3
0
        private void RemoveSelectedBehavior()
        {
            if (_TreeView.SelectedItem == null)
            {
                return;
            }
            IBehaviorItem  item = _TreeView.SelectedItem as IBehaviorItem;
            TreeViewFolder tvf  = (TreeViewFolder)_TreeView.SelectedItem.Parent;

            tvf.RemoveBehavior(item);
            SelectItem(null);
        }
Пример #4
0
        private void MoveDown()
        {
            if (_TreeView.SelectedItem == null)
            {
                return;
            }
            IBehaviorItem item = _TreeView.SelectedItem as IBehaviorItem;

            if (item.CanMoveDown)
            {
                TreeViewFolder tvf = (TreeViewFolder)_TreeView.SelectedItem.Parent;
                tvf.MoveDown(item);
                SelectItem(tvf, item.Data);
            }
        }
Пример #5
0
 private void SelectItem(TreeViewFolder folder, BehaviorData behavior)
 {
     foreach (var control in folder.Controls)
     {
         IBehaviorItem item = (IBehaviorItem)control;
         if (item.Data == behavior)
         {
             _TreeView.SelectedItem = control;
             return;
         }
         if (control is TreeViewFolder)
         {
             SelectItem((TreeViewFolder)control, behavior);
         }
     }
 }
Пример #6
0
        void InsertMenuItem_Click(object sender, System.EventArgs e)
        {
            if (_TreeView.SelectedItem == null)
            {
                return;
            }
            if (!(_TreeView.SelectedItem is TreeViewFolder))
            {
                return;
            }

            Skill.Editor.UI.MenuItem item     = (Skill.Editor.UI.MenuItem)sender;
            BehaviorData             behavior = (BehaviorData)item.UserData;

            if (behavior != null)
            {
                TreeViewFolder tvf = (TreeViewFolder)_TreeView.SelectedItem;

                string msg;
                if (tvf.CanAddBehavior(behavior, out msg))
                {
                    tvf.Foldout.IsOpen = true;
                    tvf.AddBehavior(behavior);
                    if (behavior is IParameterData)
                    {
                        var parameters = tvf.Data.GetParameters(tvf.Controls.Count - 1);
                        if (parameters != null)
                        {
                            parameters.Match(((IParameterData)behavior).ParameterDifinition);
                        }
                    }

                    var addedControl = tvf.Controls[tvf.Controls.Count - 1];
                    if (addedControl is IBehaviorItem)
                    {
                        ((IBehaviorItem)addedControl).RefreshContent();
                    }
                    _Editor.AddToList(behavior);
                    _Editor.RefreshTree();
                    SelectItem(tvf, behavior);
                }
                else
                {
                    Debug.LogError(msg);
                }
            }
        }
Пример #7
0
            protected override void CreateCustomFileds()
            {
                base.CreateCustomFileds();
                TreeViewItem item = (TreeViewItem)Object;

                if (item.Data is IParameterData)
                {
                    TreeViewFolder parent = item.Parent as TreeViewFolder;
                    if (parent != null)
                    {
                        var parameters = parent.Data.GetParameters(parent.Controls.IndexOf(item));
                        var difinition = ((IParameterData)item.Data).ParameterDifinition;
                        parameters.Match(difinition);
                        _Editor = new ParameterEditor(item, difinition, parameters);
                        this.Controls.Add(_Editor);
                    }
                }
            }
Пример #8
0
        private bool CheckAddCauseLoop(BehaviorData newBehavior)
        {
            TreeViewFolder parent = this;

            if (CheckAddCauseLoop(parent, newBehavior))
            {
                return(true);
            }

            foreach (var item in newBehavior)
            {
                if (CheckAddCauseLoop(item))
                {
                    return(true);
                }
            }
            return(false);
        }
Пример #9
0
 private string AppendParameters(string name)
 {
     if (Data is IParameterData)
     {
         if (Parent != null)
         {
             TreeViewFolder folder = Parent as TreeViewFolder;
             if (folder != null)
             {
                 var parameters = folder.Data.GetParameters(folder.Controls.IndexOf(this));
                 if (parameters != null)
                 {
                     parameters.Match(((IParameterData)Data).ParameterDifinition);
                     if (parameters.Count > 0)
                     {
                         name += parameters.ToString();
                     }
                 }
             }
         }
     }
     return(name);
 }
Пример #10
0
        void AddMenuItem_Click(object sender, System.EventArgs e)
        {
            if (_TreeView.SelectedItem == null)
            {
                return;
            }
            if (!(_TreeView.SelectedItem is TreeViewFolder))
            {
                return;
            }


            Skill.Editor.UI.MenuItem item     = (Skill.Editor.UI.MenuItem)sender;
            BehaviorData             behavior = null;

            if (string.IsNullOrEmpty(item.Tag))
            {
                Skill.Framework.AI.BehaviorType type = (Framework.AI.BehaviorType)item.UserData;
                switch (type)
                {
                case Skill.Framework.AI.BehaviorType.Action:
                    behavior = new ActionData()
                    {
                        Name = _Editor.GetUniqueName("NewAction")
                    };
                    break;

                case Skill.Framework.AI.BehaviorType.Condition:
                    behavior = new ConditionData()
                    {
                        Name = _Editor.GetUniqueName("NewCondition")
                    };
                    break;

                default:
                    behavior = null;
                    break;
                }
            }
            else if (item.Tag == "Decorator")
            {
                Skill.Framework.AI.DecoratorType type = (Framework.AI.DecoratorType)item.UserData;
                switch (type)
                {
                case Skill.Framework.AI.DecoratorType.Default:
                    behavior = new DecoratorData()
                    {
                        Name = _Editor.GetUniqueName("NewDecorator")
                    };
                    break;

                case Skill.Framework.AI.DecoratorType.AccessLimit:
                    behavior = new AccessLimitDecoratorData()
                    {
                        Name = _Editor.GetUniqueName("NewAccessDecorator")
                    };
                    break;

                default:
                    behavior = null;
                    break;
                }
            }
            else if (item.Tag == "Composite")
            {
                Skill.Framework.AI.CompositeType type = (Framework.AI.CompositeType)item.UserData;
                switch (type)
                {
                case Skill.Framework.AI.CompositeType.Sequence:
                    behavior = new SequenceSelectorData()
                    {
                        Name = _Editor.GetUniqueName("NewSequence")
                    };
                    break;

                case Skill.Framework.AI.CompositeType.Concurrent:
                    behavior = new ConcurrentSelectorData()
                    {
                        Name = _Editor.GetUniqueName("NewConcurrent")
                    };
                    break;

                case Skill.Framework.AI.CompositeType.Random:
                    behavior = new RandomSelectorData()
                    {
                        Name = _Editor.GetUniqueName("NewRandom")
                    };
                    break;

                case Skill.Framework.AI.CompositeType.Priority:
                    behavior = new PrioritySelectorData()
                    {
                        Name = _Editor.GetUniqueName("NewPriority")
                    };
                    break;

                case Skill.Framework.AI.CompositeType.Loop:
                    behavior = new LoopSelectorData()
                    {
                        Name = _Editor.GetUniqueName("NewLoop")
                    };
                    break;

                default:
                    behavior = null;
                    break;
                }
            }

            if (behavior != null)
            {
                TreeViewFolder tvf = (TreeViewFolder)_TreeView.SelectedItem;
                tvf.Foldout.IsOpen = true;
                tvf.AddBehavior(behavior);
                _Editor.AddToList(behavior);
                _Editor.RefreshTree();
                SelectItem(tvf, behavior);
            }
        }
Пример #11
0
 public ItemProperties(TreeViewFolder item)
     : base(item)
 {
     _Item = item;
 }