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); }
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); }
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); } }
public override void Update() { base.Update(); if (_input.KeyPress(Key.Delete)) { if (_vertices.Count > 0) { _vertices.RemoveAt(_vertices.Count - 1); UpdatePolygon(); } } else if (_input.MousePress(MouseButton.Right)) { Controller.SetTool(null); } else if (_input.MousePress(MouseButton.Left)) { Vector2 mousePos = Controller.GetMouseWorld(); if (mousePos != _vertices.LastOrDefault()) { if (_vertices.Count >= 3 && (mousePos - _vertices[0]).Length < 0.1f) { Vector2 average = new Vector2(_vertices.Average(item => item.X), _vertices.Average(item => item.Y)); for (int i = 0; i < _vertices.Count; i++) { _vertices[i] -= average; } _vertices = PolygonExt.SetNormals(_vertices); _vertices = (List<Vector2>)MathExt.SetWinding(_vertices, false); EditorWall editorEntity = new EditorWall(Controller.Level, _vertices); Transform2.SetPosition(editorEntity, average); Controller.SetTool(null); } else { _vertices.Add(mousePos); UpdatePolygon(); } } } }
public override IDeepClone ShallowClone() { EditorWall clone = new EditorWall(Scene, Vertices); base.ShallowClone(clone); return clone; }