Пример #1
0
        public static void AddPointToDrawing(ref PCad.Model model, Action saveToHistory)
        {
            CoordinateCreation.BakePosition(model.InteractionState.focusPosition);
            model.Sketch.coordinateSystem.SetAnchorPosition(MouseInput.RaycastPosition);

            switch (model.Tool.CurrentGeometryType)
            {
            case GeometryType.Point:
                model.Sketch.geometries.Add(PointCreation.NewPoint(model.InteractionState.focusPosition));
                saveToHistory();
                break;

            case GeometryType.Line:
                if (!(model.InteractionState.incompleteGeometry is LineModel))
                {
                    model.InteractionState.incompleteGeometry =
                        LineCreation.StartNewLine(model.InteractionState.focusPosition);
                    model.Sketch.geometries.Add(model.InteractionState.incompleteGeometry);
                }
                else
                {
                    LineCreation.CompleteLine(model.InteractionState.incompleteGeometry as LineModel,
                                              model.InteractionState.focusPosition);
                    model.InteractionState.incompleteGeometry = null;
                    saveToHistory();
                }

                break;

            case GeometryType.Rectangle:
                if (!(model.InteractionState.incompleteGeometry is RectangleModel))
                {
                    model.InteractionState.incompleteGeometry =
                        RectangleCreation.StartNewRectangle(model.InteractionState.focusPosition,
                                                            model.Tool.CurrentGeometryColor);
                    model.Sketch.geometries.Add(model.InteractionState.incompleteGeometry);
                }
                else
                {
                    RectangleCreation.CompleteRectangle(model.InteractionState.incompleteGeometry as RectangleModel,
                                                        model.InteractionState.focusPosition);
                    model.InteractionState.incompleteGeometry = null;
                    saveToHistory();
                }

                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            // reset input
            model.InteractionState.keyboardInputModel = new NumpadInput.Model();
        }
Пример #2
0
 // Use this for initialization
 void Start()
 {
     //try to make a dict with scripts inheriting from same base
     createLine      = GetComponent <CreateLine> ();
     pointCreation   = GetComponent <PointCreation> ();
     shipControl     = GetComponent <ShipControl> ();
     squadronControl = GetComponent <SquadronControl> ();
     //shipControl.enabled = false;
     //createLine.Disable ();
     //pointCreation.Disable ();
     SetState("Main");
 }