コード例 #1
0
ファイル: Core.cs プロジェクト: GodLesZ/svn-dump
		public Puzzle3D() {
			if( mInstance != null )
				throw new InvalidOperationException( "Only one instance of Puzzle3D may be created." );

			mInstance = this;

			graphics = new GraphicsDeviceManager( this );
			graphics.MinimumVertexShaderProfile = ShaderProfile.VS_2_0;
			graphics.MinimumPixelShaderProfile = ShaderProfile.PS_2_0;

			graphics.PreferredBackBufferWidth = 800;
			graphics.PreferredBackBufferHeight = 600;
			Window.AllowUserResizing = true;
			graphics.IsFullScreen = false;

			Content.RootDirectory = "Content";

			ScreenManager screenManager = new ScreenManager( this );
			Components.Add( screenManager );

			PictureDatabase.Initialize();
			if( PictureDatabase.Count >= 2 ) {
				screenManager.AddScreen( new MainMenuScreen() );
			} else {
				MessageBoxScreen messageBox = new MessageBoxScreen( "Unable to find enough pictures to play.", false );
				messageBox.Accepted += new EventHandler<EventArgs>( messageBox_Accepted );
				screenManager.AddScreen( messageBox );
			}
		}
コード例 #2
0
        /// <summary>
        /// When the user cancels the main menu, ask if they want to exit the sample.
        /// </summary>
        protected override void OnCancel()
        {
            const string message = "Are you sure you want to exit Puzzle3D?";

            MessageBoxScreen confirmExitMessageBox = new MessageBoxScreen(message);

            confirmExitMessageBox.Accepted += ConfirmExitMessageBoxAccepted;
            ScreenManager.AddScreen(confirmExitMessageBox);
        }
コード例 #3
0
ファイル: Core.cs プロジェクト: hakanaku2009/svn-dump
        public Puzzle3D()
        {
            if (mInstance != null)
            {
                throw new InvalidOperationException("Only one instance of Puzzle3D may be created.");
            }

            mInstance = this;

            graphics = new GraphicsDeviceManager(this);
            graphics.MinimumVertexShaderProfile = ShaderProfile.VS_2_0;
            graphics.MinimumPixelShaderProfile  = ShaderProfile.PS_2_0;

            graphics.PreferredBackBufferWidth  = 800;
            graphics.PreferredBackBufferHeight = 600;
            Window.AllowUserResizing           = true;
            graphics.IsFullScreen = false;

            Content.RootDirectory = "Content";

            ScreenManager screenManager = new ScreenManager(this);

            Components.Add(screenManager);

            PictureDatabase.Initialize();
            if (PictureDatabase.Count >= 2)
            {
                screenManager.AddScreen(new MainMenuScreen());
            }
            else
            {
                MessageBoxScreen messageBox = new MessageBoxScreen("Unable to find enough pictures to play.", false);
                messageBox.Accepted += new EventHandler <EventArgs>(messageBox_Accepted);
                screenManager.AddScreen(messageBox);
            }
        }
コード例 #4
0
ファイル: MainMenuScreen.cs プロジェクト: GodLesZ/svn-dump
		/// <summary>
		/// When the user cancels the main menu, ask if they want to exit the sample.
		/// </summary>
		protected override void OnCancel() {
			const string message = "Are you sure you want to exit Puzzle3D?";

			MessageBoxScreen confirmExitMessageBox = new MessageBoxScreen( message );
			confirmExitMessageBox.Accepted += ConfirmExitMessageBoxAccepted;
			ScreenManager.AddScreen( confirmExitMessageBox );
		}
コード例 #5
0
        public override void HandleInput(InputState input)
        {
            if (input.MenuCancel)
            {
                MessageBoxScreen messageBox = new MessageBoxScreen(
                    "Are you sure you want to quit this game?\nYour progress will be lost");

                messageBox.Accepted += QuitMessageBoxAccepted;
                ScreenManager.AddScreen(messageBox);
            }

            // Do not handle controls while the camera is flipping
            if (board.Camera.IsFlipping)
            {
                return;
            }

            // Some controls only apply when the puzzle is two sided
            if (board.TwoSided)
            {
                // Handle flipping camera to other side of board
                if (input.FlipCameraLeft)
                {
                    board.Camera.Flip(Camera.FlipDirection.Left);
                }
                else if (input.FlipCameraRight)
                {
                    board.Camera.Flip(Camera.FlipDirection.Right);
                }
                // Handle flipping the active chip
                else if (input.FlipUp)
                {
                    if (board.Camera.Side == Camera.BoardSide.Front)
                    {
                        ActiveChip.Flip(Chip.RevolveDirection.Up);
                    }
                    else
                    {
                        ActiveChip.Flip(Chip.RevolveDirection.Down);
                    }
                }
                else if (input.FlipDown)
                {
                    if (board.Camera.Side == Camera.BoardSide.Front)
                    {
                        ActiveChip.Flip(Chip.RevolveDirection.Down);
                    }
                    else
                    {
                        ActiveChip.Flip(Chip.RevolveDirection.Up);
                    }
                }
                else if (input.FlipLeft)
                {
                    ActiveChip.Flip(Chip.RevolveDirection.Left);
                }
                else if (input.FlipRight)
                {
                    ActiveChip.Flip(Chip.RevolveDirection.Right);
                }
            }

            // Handle selecting a new active chip
            HandleChipSelection(input);

            // Handle shifting
            if (input.ShiftActiveChip && !board.IsShifting)
            {
                board.Shift(activeChipX, activeChipY);
                if (board.IsShifting)
                {
                    // When a shift occurs, the active chip moves with the shift
                    SetActiveChip(activeChipX + board.ShiftX,
                                  activeChipY + board.ShiftY);
                }
            }

            // Did any moves during this update result in the puzzle being sovled?
            if (this.board.IsPuzzleComplete())
            {
                // Transition to the CompletedScreen
                ExitScreen();
                foreach (GameScreen screen in ScreenManager.GetScreens())
                {
                    if (screen is BoardScreen)
                    {
                        screen.ExitScreen();
                    }
                }
                ScreenManager.AddScreen(new CompletedScreen(board.CurrentPictureSet));
            }
        }