Esempio n. 1
0
        public override EditorActor clone()
        {
            XElement data = this.data;

            data.SetAttributeValue("id", _level.controller.getUnusedActorID());
            EditorBoxActor copy = new EditorBoxActor(_level, data);

            _level.addActor(copy);
            return(copy);
        }
Esempio n. 2
0
 public override bool handleUnselectedClick(System.Windows.Forms.MouseButtons button)
 {
     if (button == System.Windows.Forms.MouseButtons.Left)
     {
         return(hitTest(_level.controller.worldMouse, (results) =>
         {
             if (results.Count == 1 && results[0] == this)
             {
                 if (_level.controller.isKeyHeld(Keys.LeftShift))
                 {
                     EditorBoxActor copy = (EditorBoxActor)clone();
                     copy.select();
                 }
                 else
                 {
                     Console.WriteLine(layerDepth);
                     select();
                 }
                 return true;
             }
             return false;
         }));
     }
     else if (button == System.Windows.Forms.MouseButtons.Right)
     {
         return(hitTest(_level.controller.worldMouse, (results) =>
         {
             if (results.Count == 1)
             {
                 _level.controller.openActorProperties(results[0]);
                 return true;
             }
             return false;
         }));
     }
     return(false);
 }
Esempio n. 3
0
 public override EditorActor clone()
 {
     XElement data = this.data;
     data.SetAttributeValue("id", _level.controller.getUnusedActorID());
     EditorBoxActor copy = new EditorBoxActor(_level, data);
     _level.addActor(copy);
     return copy;
 }
Esempio n. 4
0
        // Create actor from toolbar
        public void createActorFromToolbar(string buttonName)
        {
            // Create actor controller based on button name
            EditorActor actor = null;
            switch (buttonName)
            {
                case "boxButton":
                    actor = new EditorBoxActor(_level);
                    break;

                case "circleButton":
                    actor = new EditorCircleActor(_level);
                    break;

                case "terrainButton":
                    actor = new EditorTerrainActor(_level);
                    break;

                case "ropeButton":
                    actor = new EditorRopeActor(_level);
                    break;

                case "fluidButton":
                    actor = new EditorFluidActor(_level);
                    break;

                case "playerSpawnButton":
                    // Remove existing player spawns before adding a new one
                    List<EditorPlayerSpawnActor> results = _level.getActors<EditorPlayerSpawnActor>(ActorType.PlayerSpawn);
                    if (results.Count > 0)
                    {
                        _level.removeActor(results[0]);
                    }
                    actor = new EditorPlayerSpawnActor(_level);
                    break;

                case "plantsButton":
                    PlantSelectBox plantSelectBox = new PlantSelectBox();
                    if (plantSelectBox.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                    {
                        // Adjust mouse position since movement isn't tracked when a form is open
                        _mouse = _levelView.PointToClient(System.Windows.Forms.Cursor.Position);
                        _oldMouse = _mouse;

                        PlantType selectedPlantType = plantSelectBox.selectedPlantType;
                        switch (selectedPlantType)
                        {
                            case PlantType.Tree:
                                actor = new EditorTreeActor(_level);
                                break;
                        }
                    }
                    break;

                case "itemsButton":
                    SelectItem selectItemForm = new SelectItem(_editorController);
                    if (selectItemForm.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                    {
                        actor = new EditorItemActor(_level, selectItemForm.uid);
                    }
                    break;

                case "circuitsButton":
                    SelectCircuit selectCircuitForm = new SelectCircuit(_editorController.circuitController);
                    if (selectCircuitForm.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                    {
                        actor = new EditorCircuitActor(_level, selectCircuitForm.circuitUID);
                    }
                    break;

                case "revoluteButton":
                    actor = new EditorRevoluteActor(_level);
                    break;

                case "prismaticButton":
                    actor = new EditorPrismaticActor(_level);
                    break;

                case "collisionFilterButton":
                    actor = new EditorCollisionFilterActor(_level);
                    break;

                case "regionButton":
                    actor = new EditorRegionActor(_level);
                    break;

                case "decalsButton":
                    actor = new EditorDecalActor(_level);
                    break;

                case "levelTransitionButton":
                    actor = new EditorLevelTransitionActor(_level);
                    break;

                case "tooltipButton":
                    actor = new EditorTooltipActor(_level);
                    break;

                case "waypointButton":
                    actor = new EditorWaypointActor(_level);
                    break;

                case "edgeBoundaryButton":
                    actor = new EditorEdgeBoundaryActor(_level);
                    break;
            }

            if (actor != null)
            {
                _editorController.view.selectLevelTab();
                _level.addActor(actor);
                _selectedActor = actor;
            }
        }