示例#1
0
        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);
        }
示例#2
0
        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);
        }
示例#3
0
		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;
		}