public async Task RoomProperlyRendered_Test() { int threadID = AGSGame.UIThreadID; AGSGame.UIThreadID = Environment.CurrentManagedThreadId; try { _mocks.Room().Setup(m => m.ShowPlayer).Returns(false); AGSViewport viewport = new AGSViewport(new AGSDisplayListSettings(), new AGSCamera()); viewport.RoomProvider = new AGSSingleRoomProvider(_mocks.Room().Object); _mocks.GameState().Setup(m => m.Viewport).Returns(viewport); _areas.Clear(); _areas.Add(getArea()); _roomObjects.Clear(); _roomObjects.Add(_mocks.Object(true).Object); _uiObjects.Clear(); _uiObjects.Add(_mocks.Object(true).Object); IRendererLoop loop = getLoop(); Assert.IsTrue(loop.Tick()); //First tick just to tell the display list about our viewport, the second tick will have the objects to render await _events.OnRepeatedlyExecute.InvokeAsync(); Assert.IsTrue(loop.Tick()); _renderer.Verify(r => r.Render(It.IsAny <IObject>(), It.IsAny <IViewport>()), Times.Exactly(2)); } finally { AGSGame.UIThreadID = threadID; } }
public async void Show() { _isShowing = true; AGSDisplayListSettings settings1 = new AGSDisplayListSettings { DisplayGUIs = false }; _viewport1 = new AGSViewport(settings1, null); _viewport1.RoomProvider = new AGSSingleRoomProvider(await Rooms.DarsStreet); _viewport1.ProjectionBox = new RectangleF(0.15f, 0.07f, 0.25f, 0.25f); _viewport1.Z = -1f; _viewport1.Parent = _parent; _game.State.SecondaryViewports.Add(_viewport1); AGSDisplayListSettings settings2 = new AGSDisplayListSettings { DisplayGUIs = false }; _viewport2 = new AGSViewport(settings2, null); _viewport2.RoomProvider = new AGSSingleRoomProvider(await Rooms.BrokenCurbStreet); _viewport2.ProjectionBox = new RectangleF(0.15f, 0.37f, 0.25f, 0.25f); _viewport2.Pivot = new PointF(0.5f, 0.5f); _viewport2.X = 180f; _viewport2.Y = 100f; _viewport2.Z = -2f; _viewport2.Parent = _parent; _game.State.SecondaryViewports.Add(_viewport2); animate(); }
public void RoomProperlyRendered_Test() { int threadID = AGSGame.UIThreadID; AGSGame.UIThreadID = Environment.CurrentManagedThreadId; try { _mocks.Room().Setup(m => m.ShowPlayer).Returns(false); AGSViewport viewport = new AGSViewport(new AGSDisplayListSettings(), new AGSCamera(), Mocks.GetResolver()); viewport.RoomProvider = new AGSSingleRoomProvider(_mocks.Room().Object); _mocks.GameState().Setup(m => m.Viewport).Returns(viewport); _mocks.GameState().Setup(m => m.GetSortedViewports()).Returns(new List <IViewport> { _mocks.GameState().Object.Viewport }); _areas.Clear(); _areas.Add(getArea()); var roomObj = _mocks.Object(true); var uiObj = _mocks.Object(true); roomObj.Setup(c => c.ID).Returns("roomObj"); uiObj.Setup(c => c.ID).Returns("uiObj"); _roomObjects.Clear(); _roomObjects.Add(roomObj.Object); _uiObjects.Clear(); _uiObjects.Add(uiObj.Object); var displayList = getDisplayList(); var pipeline = getPipeline(displayList); var roomRenderer = new Mock <IRenderer>(); var uiRenderer = new Mock <IRenderer>(); var roomInsturction = new Mock <IRenderInstruction>(); var uiInstruction = new Mock <IRenderInstruction>(); roomRenderer.Setup(r => r.GetNextInstruction(_mocks.GameState().Object.Viewport)).Returns(roomInsturction.Object); uiRenderer.Setup(r => r.GetNextInstruction(_mocks.GameState().Object.Viewport)).Returns(uiInstruction.Object); pipeline.Subscribe("roomObj", roomRenderer.Object); pipeline.Subscribe("uiObj", uiRenderer.Object); IRendererLoop loop = getLoop(displayList, pipeline); Assert.IsTrue(loop.Tick()); //First tick just to tell the display list about our viewport, the second tick will have the objects to render displayList.GetDisplayList(_mocks.GameState().Object.Viewport); displayList.Update(); pipeline.Update(); Assert.IsTrue(loop.Tick()); roomInsturction.Verify(r => r.Render(), Times.Once); uiInstruction.Verify(r => r.Render(), Times.Once); } finally { AGSGame.UIThreadID = threadID; } }
public int Camera_FollowX_Test(float currentViewX, float targetPosX, int roomWidth, int screenWidth, float speedX) { AGSCamera camera = new AGSCamera(speedX, 0f); _mocks.Object().Setup(o => o.X).Returns(targetPosX); _mocks.Object().Setup(o => o.Y).Returns(0f); Func <IObject> getTarget = () => _mocks.Object().Object; camera.Target = getTarget; AGSViewport viewport = new AGSViewport(); viewport.X = currentViewX; viewport.Y = 0f; camera.Tick(viewport, new RectangleF(0f, 0f, roomWidth, 200), new Size(screenWidth, 200), false); return((int)viewport.X); }