Exemplo n.º 1
0
        public CreatureEditorPanelVM(CreatureVM creature)
        {
            Creature         = creature;
            ToolCollectionVM = new ToolCollectionVM();
            CreatureStructureEditorCanvasVM = new CreatureStructureEditorCanvasVM(Creature, ToolCollectionVM);
            Settings = new CreatureSettings(this);
            ToolCollectionVM.InfoMessageCollection = CreatureStructureEditorCanvasVM.InfoMessageCollection;
            ToolCollectionVM.Tools.Add(new SelectAllTool());
            ToolCollectionVM.Tools.Add(new MoveTool());
            ToolCollectionVM.Tools.Add(new PanTool());
            ToolCollectionVM.Tools.Add(new PlaceJointTool());
            ToolCollectionVM.Tools.Add(new PlaceBoneTool());

            Behaviours = new ObservableCollection <BaseBehaviour>
            {
                new UndoBehaviour(CreatureStructureEditorCanvasVM.HistoryStack),
                new RedoBehaviour(CreatureStructureEditorCanvasVM.HistoryStack),
                new RotateLeftBehaviour(),
                new RotateRightBehaviour(),
                new FlipHorizontalBehaviour(),
                new FlipVeticalBehaviour(),
                new SaveBehaviour(),
                new DeleteBehaviour(),
                new ClearBehaviour()
            };

            Behaviours.CollectionChanged             += CollectionChanged;
            ToolCollectionVM.Tools.CollectionChanged += CollectionChanged;
        }
Exemplo n.º 2
0
 private void ClearCreatures(CreatureVM obj)
 {
     CreatureCollectionAccess.Clear();
     Model.Creatures.Clear();
     RemoveCreatureCommand.OnCanExecuteChanged();
     ClearCreaturesCommand.OnCanExecuteChanged();
 }
Exemplo n.º 3
0
 private void AddCreature(CreatureVM obj)
 {
     CreatureCollectionAccess.Add(obj);
     Model.Creatures.Add(obj.Model);
     RemoveCreatureCommand.OnCanExecuteChanged();
     ClearCreaturesCommand.OnCanExecuteChanged();
 }
Exemplo n.º 4
0
        public void Clone_GetCloneTest_ReturnsTrue()
        {
            var creature = new Creature {
                MovementPatterns = { new MovementPattern(null) }
            };
            var creatureVM = new CreatureVM(creature);

            var clone = creatureVM.Clone();

            Assert.AreEqual(true, clone != null);
        }
Exemplo n.º 5
0
        public void MovementPatternCollectionVM_GetValueTest_ReturnsSameCountFalse()
        {
            var creature = new Creature {
                MovementPatterns = { new MovementPattern(null) }
            };
            var creatureVM = new CreatureVM(creature);

            var movementPatternCollectionVM = creatureVM.MovementPatternCollectionVM;

            Assert.AreNotEqual(true, movementPatternCollectionVM.Count == 0);
        }
Exemplo n.º 6
0
        public void CreatureStructureVM_WithoutValueTest_ReturnsZeroCountTrue()
        {
            var creature = new Creature {
                MovementPatterns = { new MovementPattern(null) }
            };
            var creatureVM = new CreatureVM(creature);

            var creatureStructureVM = creatureVM.CreatureStructureVM;

            Assert.AreEqual(true, creatureStructureVM.BoneCollectionVM.Count == 0);
        }
Exemplo n.º 7
0
        public void Description_SetSameValue_ReturnsSameValueTrue()
        {
            var creature = new Creature {
                Name = "Dog", Description = "Can run"
            };
            var creatureVM = new CreatureVM(creature);

            creatureVM.Description = creatureVM.Description;

            string expected = creatureVM.Description;

            Assert.AreEqual(expected, "Can run");
        }
Exemplo n.º 8
0
        public void Name_SetSameValueTest_ReturnsSameValueTrue()
        {
            var creature = new Creature {
                Name = "Dog", Description = "Can run"
            };
            var creatureVM = new CreatureVM(creature);

            creatureVM.Name = creatureVM.Name;

            string expected = creatureVM.Name;

            Assert.AreEqual(expected, creature.Name);
        }
Exemplo n.º 9
0
        public void Description_SetDifferentValue_ReturnsFirstValueFalse()
        {
            var creature = new Creature {
                Name = "Dog", Description = "Can run"
            };
            var creatureVM = new CreatureVM(creature)
            {
                Description = "Can Bark"
            };

            string expected = creatureVM.Description;

            Assert.AreNotEqual(expected, "Can run");
        }
Exemplo n.º 10
0
        public void Name_SetDifferentValueTest_ReturnsFirstValueFalse()
        {
            var creature = new Creature {
                Name = "Dog", Description = "Can run"
            };
            var creatureVM = new CreatureVM(creature)
            {
                Name = "Cat"
            };

            string expected = creatureVM.Name;

            Assert.AreNotEqual(expected, "Dog");
        }
Exemplo n.º 11
0
        public void SelectedCreature_SetSameValue_ReturnsSameValueTrue()
        {
            var creatureVm = new CreatureVM(new Creature()
            {
                Name = "Cat"
            });
            var creatureTabVM = new CreatureTabVM(null, null)
            {
                SelectedCreature = creatureVm
            };

            creatureTabVM.SelectedCreature = creatureVm;
            Assert.AreEqual(creatureTabVM.SelectedCreature.Name, "Cat");
        }
Exemplo n.º 12
0
        public void SelectedCreature_SetSameValue_ReturnsSameValueTrue()
        {
            var creatureVM = new CreatureVM(new Creature()
            {
                Name = "Cat"
            });
            var trainingTabVM = new TrainingTabVM(null, new EntityStorageVM(null))
            {
                SelectedCreature = creatureVM
            };

            trainingTabVM.SelectedCreature = creatureVM;
            Assert.AreEqual(trainingTabVM.SelectedCreature.Name, "Cat");
        }
Exemplo n.º 13
0
        public void SaveCreature(CreatureVM creatureVM)
        {
            var original = OriginalCreature;

            original.CreatureStructureVM.BoneCollectionVM.Clear();
            foreach (var boneVM in creatureVM.CreatureStructureVM.BoneCollectionVM)
            {
                original.CreatureStructureVM.BoneCollectionVM.Add(boneVM);
            }
            original.CreatureStructureVM.JointCollectionVM.Clear();
            foreach (var jointVM in creatureVM.CreatureStructureVM.JointCollectionVM)
            {
                original.CreatureStructureVM.JointCollectionVM.Add(jointVM);
            }
        }
        public CreatureStructureEditorCanvasVM(CreatureVM creature, ToolCollectionVM toolCollectionVM)
        {
            HistoryStack = new HistoryStackVM <CreatureStructureEditorCanvasVM>(this);
            HistoryStack.PropertyChanged += (o, e) => Reset();
            Creature = creature;
            CameraVM = new CameraVM {
                OffsetX = -CanvasWidth / 2, OffsetY = -CanvasHeight / 2
            };
            ToolCollectionVM = toolCollectionVM;

            CanvasSizeChangedCommand = new DelegateHandleCommand <SizeChange>(CanvasSizeChanged, o => true);
            CanvasMouseDownCommand   =
                new DelegateHandleCommand <MouseInfo>(mouseInfo =>
                                                      ToolCollectionVM.SelectedTool?.OnCanvasMouseDown(mouseInfo,
                                                                                                       this,
                                                                                                       Keyboard.Modifiers) ==
                                                      true,
                                                      o => true);
            CanvasMouseUpCommand =
                new DelegateHandleCommand <MouseInfo>(mouseInfo =>
                                                      ToolCollectionVM.SelectedTool?.OnCanvasMouseUp(mouseInfo,
                                                                                                     this,
                                                                                                     Keyboard.Modifiers) ==
                                                      true,
                                                      o => true);
            CanvasMouseMoveCommand =
                new DelegateHandleCommand <MouseInfo>(mouseInfo =>
                                                      ToolCollectionVM.SelectedTool?.OnCanvasMouseMove(mouseInfo,
                                                                                                       this,
                                                                                                       Keyboard.Modifiers) ==
                                                      true,
                                                      o => true);
            CanvasMouseWheelCommand = new DelegateHandleCommand <MouseWheelInfo>(mouseWheelInfo =>
                                                                                 ToolCollectionVM
                                                                                 .SelectedTool?.OnCanvasMouseWheel(mouseWheelInfo,
                                                                                                                   this,
                                                                                                                   Keyboard
                                                                                                                   .Modifiers) ==
                                                                                 true,
                                                                                 o => true);
            CanvasMouseEnterCommand =
                new DelegateCommand(o => ToolCollectionVM.SelectedTool?.OnCanvasMouseEnter(this, Keyboard.Modifiers), o => true);
            CanvasMouseLeaveCommand =
                new DelegateCommand(o => ToolCollectionVM.SelectedTool?.OnCanvasMouseLeave(this, Keyboard.Modifiers), o => true);
        }
Exemplo n.º 15
0
        public void SelectedCreature_SetDifferentValue_ReturnsFirstValueFalse()
        {
            var creatureVM = new CreatureVM(new Creature()
            {
                Name = "Cat"
            });
            var creatureVM2 = new CreatureVM(new Creature()
            {
                Name = "Dog"
            });
            var trainingTabVM = new TrainingTabVM(null, new EntityStorageVM(null))
            {
                SelectedCreature = creatureVM
            };

            trainingTabVM.SelectedCreature = creatureVM2;
            Assert.AreNotEqual(trainingTabVM.SelectedCreature.Name, "Cat");
        }
Exemplo n.º 16
0
        public void OnSelect_SetDifferentValue_ReturnsSecondValueTrue()
        {
            var creatureVM = new CreatureVM(new Creature()
            {
                Name = "Cat"
            });
            var creatureVM2 = new CreatureVM(new Creature()
            {
                Name = "Dog"
            });
            var trainingTabVM = new TrainingTabVM(null, new EntityStorageVM(null))
            {
                SelectedCreature = creatureVM
            };

            trainingTabVM.OnSelect(creatureVM2);
            Assert.AreEqual(trainingTabVM.SelectedCreature.Name, "Dog");
        }
Exemplo n.º 17
0
        public void SelectedCreature_SetDifferentValue_ReturnsSecondValueTrue()
        {
            var creatureVM = new CreatureVM(new Creature()
            {
                Name = "Cat"
            });
            var creatureVM2 = new CreatureVM(new Creature()
            {
                Name = "Dog"
            });
            var simulationTabVM = new SimulationTabVM(null, new EntityStorageVM(null))
            {
                SelectedCreature = creatureVM
            };

            simulationTabVM.SelectedCreature = creatureVM2;
            Assert.AreEqual(simulationTabVM.SelectedCreature.Name, "Dog");
        }
Exemplo n.º 18
0
        public void SelectedCreature_SetDifferentValue_ReturnsFirstValueFalse()
        {
            var creatureVm = new CreatureVM(new Creature()
            {
                Name = "Cat"
            });
            var creatureVm2 = new CreatureVM(new Creature()
            {
                Name = "Dog"
            });
            var creatureTabVM = new CreatureTabVM(null, null)
            {
                SelectedCreature = creatureVm
            };

            creatureTabVM.SelectedCreature = creatureVm2;
            Assert.AreNotEqual(creatureTabVM.SelectedCreature.Name, "Cat");
        }
Exemplo n.º 19
0
        public void CreatureStructureVM_WithValueTest_ReturnsZeroCountFalse()
        {
            var creature = new Creature {
                MovementPatterns = { new MovementPattern(null) }
            };
            var creatureVM = new CreatureVM(creature);

            var creatureStructureVM = creatureVM.CreatureStructureVM;

            creatureStructureVM.BoneCollectionVM.Add(new BoneVM(new Bone(null, null)
            {
                Density     = 2,
                SecondJoint = new Joint()
                {
                    Position = new Vector2(5, 10)
                }
            }));

            Assert.AreNotEqual(true, creatureStructureVM.BoneCollectionVM.Count == 0);
        }
Exemplo n.º 20
0
 public CreatureEditorVM(CreatureVM creatureVM)
 {
     OriginalCreature      = creatureVM;
     CreatureEditorPanelVM = new CreatureEditorPanelVM(OriginalCreature.Clone());
     CreatureEditorPanelVM.SaveRequested += (o, c) => SaveCreature(c);
 }
Exemplo n.º 21
0
 public CreaturePropertiesVM(CreatureVM creatureVM)
 {
     CreatureVM = creatureVM;
     CreatureVM.PropertyChanged += CreatureUpdated;
 }