コード例 #1
0
        public void Stop(bool clearData)
        {
            if (clearData)
            {
                Blackboard data = Blackboards.GetBlackboard(Behavior);
                data.Clear();
            }

            Behavior = null;
        }
コード例 #2
0
 public void EmptyTable()
 {
     foreach (Blackboard board in Blackboards)
     {
         Blackboards.Remove(board);
     }
     foreach (Team team in Teams)
     {
         Teams.Remove(team);
     }
     foreach (User user in Users)
     {
         Users.Remove(user);
     }
     foreach (Administrator admin in Administrators)
     {
         Administrators.Remove(admin);
     }
     foreach (Colaborator colab in Colaborators)
     {
         Colaborators.Remove(colab);
     }
     foreach (Comment comment in Comments)
     {
         Comments.Remove(comment);
     }
     foreach (TextBox textbox in TextBoxes)
     {
         TextBoxes.Remove(textbox);
     }
     foreach (Image image in Images)
     {
         Images.Remove(image);
     }
     SaveChanges();
 }
コード例 #3
0
        public BehaviortreesEditorViewModel(World model)
        {
            Model = model;

            Behaviortrees = new ObservableCollection <BehaviortreeViewModel>();
            Model.Behaviortrees.CollectionChanged += Behaviortrees_CollectionChanged;


            Blackboard.Instances.CollectionChanged += Blackboards_CollectionChanged;
            foreach (var bb in Blackboard.Instances)
            {
                Blackboards.Add(new BlackboardViewModel(bb));
            }


            foreach (var type in Assembly.GetExecutingAssembly().GetTypes())
            {
                var na = type.GetCustomAttribute <NodeAttribute>();
                if (na != null)
                {
                    na.Type = type;
                    DraggableNodes.Add(na);
                }
            }

            timer.Interval = new TimeSpan(0, 0, 0, 0, 100);
            timer.Tick    += OnTimerTick;
            timer.Start();

            AddBehaviortree = new RelayCommand(arg => {
                Model.Behaviortrees.Add(new Behaviortree.Behaviortree {
                    Name = "Untitled", Root = new Behaviortree.Decorator()
                });
            });
            RemoveBehaviortree = new RelayCommand(arg => {
                if (Current != null)
                {
                    Model.Behaviortrees.Remove(Current.Model);
                }
            });

            ofDialog.DefaultExt = ".behaviors";
            ofDialog.FileName   = "untitled";
            ofDialog.Filter     = "Behaviors (*.behaviors)|All(*.*)";
            sfDialog.DefaultExt = ".behaviors";
            sfDialog.FileName   = "untitled";
            sfDialog.Filter     = "Behaviors (*.behaviors)|All(*.*)";

            New = new RelayCommand(arg => {
                Model.Units.Clear();
                Model.Behaviortrees.Clear();
            });
            Load = new RelayCommand(arg => {
                if (ofDialog.ShowDialog().Value)
                {
                    load(ofDialog.FileName);
                }
            });
            Save = new RelayCommand(arg => {
                save(sfDialog.FileName);
            });
            SaveAs = new RelayCommand(arg => {
                if (sfDialog.ShowDialog().Value)
                {
                    save(sfDialog.FileName);
                }
            });
        }