Example #1
0
        public override void Update()
        {
            base.Update();
            _mouseFollow.SetTransform(GetPortalTransform());

            if (_input.MouseDown(MouseButton.Right) || _input.KeyPress(Key.Delete) || _input.KeyPress(Key.Escape))
            {
                Controller.SetTool(null);
            }
            else
            {
                if (_input.MousePress(MouseButton.Left))
                {
                    EditorPortal portal = new EditorPortal(Controller.Level);
                    var coord = GetEdgeCoord();
                    if (coord != null)
                    {
                        //portal.SetParent((EditorObject)coord.Actor);
                        portal.SetTransform(coord.Wall, coord);
                    }
                    else
                    {
                        portal.SetTransform(_mouseFollow.GetTransform());
                    }

                    AddPortal command;
                    if (isSecondPortal)
                    {
                        Debug.Assert(portalPrevious != null);
                        command = new AddPortal(Controller, portal, portalPrevious);
                    }
                    else
                    {
                        command = new AddPortal(Controller, portal);
                    }
                    Controller.StateList.Add(command, true);

                    if (!_input.KeyDown(KeyBoth.Shift))
                    {
                        Controller.SetTool(null);
                    }
                    portalPrevious = portal;
                    isSecondPortal = !isSecondPortal;
                }
            }
        }
Example #2
0
 public override ICommand ShallowClone()
 {
     AddPortal clone = new AddPortal(_controller, (EditorPortal)_editorObject, _linked);
     return clone;
 }