public IViewport ToItem(AGSSerializationContext context) { AGSViewport viewport = new AGSViewport(DisplayListSettings.ToItem(context), Camera.ToItem(context), context.Resolver); viewport.X = X; viewport.Y = Y; viewport.ScaleX = ScaleX; viewport.ScaleY = ScaleY; viewport.ProjectionBox = ProjectionBox.ToItem(context); context.Rewire(state => { if (IsRoomProviderGameState) { viewport.RoomProvider = state; } else { var room = state.Rooms.FirstOrDefault(r => r.ID == RoomProviderRoomID); if (room != null) { viewport.RoomProvider = new AGSSingleRoomProvider(room); } } }); return(viewport); }
public IViewport ToItem(AGSSerializationContext context) { AGSViewport viewport = new AGSViewport(); viewport.X = X; viewport.Y = Y; viewport.ScaleX = ScaleX; viewport.ScaleY = ScaleY; viewport.Camera = Camera.ToItem(context); return(viewport); }
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 AGS.API.Size (roomWidth, 200), new AGS.API.Size (screenWidth, 200), false); return (int)viewport.X; }