Beispiel #1
0
 public override void Enable()
 {
     base.Enable();
     isSecondPortal = false;
     portalPrevious = null;
     unsnapAngle = 0;
     _mouseFollow = new Doodad(Controller.Level);
     _mouseFollow.Models.Add(ModelFactory.CreatePortal());
 }
Beispiel #2
0
        public Tuple<EditorScene, EditorWall> CreateTestScene()
        {
            EditorPortal portal0, portal1;
            EditorScene scene = new EditorScene();
            EditorWall polygon = new EditorWall(scene, PolygonFactory.CreateRectangle(2, 2));

            portal0 = new EditorPortal(scene);
            portal1 = new EditorPortal(scene);
            portal0.SetTransform(polygon, new PolygonCoord(0, 0.5f));
            portal1.SetTransform(polygon, new PolygonCoord(1, 0.5f));

            return new Tuple<EditorScene, EditorWall>(scene, polygon);
        }
Beispiel #3
0
        public void FloatPortal()
        {
            EditorPortal portal0, portal1;
            EditorScene scene = new EditorScene();
            EditorWall polygon = new EditorWall(scene, PolygonFactory.CreateRectangle(2, 2));

            portal0 = new EditorPortal(scene);
            portal1 = new EditorPortal(scene);
            portal0.SetTransform(new Transform2(new Vector2(-0.8f, 0)));
            portal1.SetTransform(new Transform2(new Vector2(0.8f, 0)));
            portal0.Linked = portal1;
            portal1.Linked = portal0;

            List<Clip.ClipModel> clipmodels = Clip.GetClipModels(polygon, scene.GetPortalList(), 2);
            Assert.IsTrue(clipmodels.Count == polygon.GetModels().Count + 2);
        }
Beispiel #4
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;
                }
            }
        }
Beispiel #5
0
        public void FixturePortal()
        {
            EditorPortal portal0, portal1;
            EditorScene scene = new EditorScene();
            EditorWall polygon = new EditorWall(scene, PolygonFactory.CreateRectangle(2, 2));

            portal0 = new EditorPortal(scene);
            portal1 = new EditorPortal(scene);
            portal0.SetTransform(polygon, new PolygonCoord(0, 0.5f));
            portal1.SetTransform(polygon, new PolygonCoord(1, 0.5f));
            portal0.Linked = portal1;
            portal1.Linked = portal0;

            for (float i = 0; i < MathExt.TAU; i += 0.01f)
            {
                polygon.SetTransform(new Transform2(new Vector2(100000, -123), 1, i));
                List<Clip.ClipModel> clipmodels = Clip.GetClipModels(polygon, scene.GetPortalList(), 2);
                Assert.IsTrue(clipmodels.Count == polygon.GetModels().Count);
            }
        }
Beispiel #6
0
 public override IDeepClone ShallowClone()
 {
     EditorPortal clone = new EditorPortal(Scene);
     ShallowClone(clone);
     return clone;
 }