Beispiel #1
0
		public ShufflingScreen( Board board ) {
			this.board = board;

			// Calculate how many shifts to perform for the shuffle
			shiftsRemaining = board.Width * board.Height * 2;

			// Determine the interval of time between flips
			// This interval is based on the max portion of the board which will be
			// allowed to flip simultaneously
			timeBetweenFlips = TimeSpan.FromSeconds( Chip.FlipDuration /
					( board.Width * board.Height * MaxFlippingPortion ) );

			// Show the board on the screen under this
			IsPopup = true;
		}
Beispiel #2
0
		/// <summary>
		/// Starts a new game with specific parameters.
		/// </summary>
		/// <param name="boardSize">The size of the (square) board.</param>
		/// <param name="twoSided">
		/// If true, there is a different image on each side of the board.
		/// </param>
		void StartGame( int boardSize, bool twoSided ) {
			if( boardSize <= 0 ) {
				throw new ArgumentOutOfRangeException( "boardSize" );
			}
			Board board = new Board( boardSize, boardSize, twoSided );
			ScreenManager.AddScreen( new BoardScreen( board ) );
			ScreenManager.AddScreen( new ShufflingScreen( board ) );
		}
Beispiel #3
0
		static bool SetTexture( Board board, int textureIndex ) {
			LightingEffect lightingEffect = board.LightingEffect;
			Texture2D texture = null;

			if( board.CurrentPictureSet != null )
				texture = board.CurrentPictureSet.GetTexture( textureIndex );

			if( ( texture == null ) && ( board.NextPictureSet != null ) )
				texture = board.NextPictureSet.GetTexture( textureIndex );

			lightingEffect.DiffuseTexture.SetValue( texture );

			return ( texture != null );
		}
Beispiel #4
0
		public BoardScreen( Board board ) {
			this.board = board;

			TransitionOnTime = Puzzle3D.TransitionTime;
			TransitionOffTime = TimeSpan.FromSeconds( 0.75f );
		}
Beispiel #5
0
		public void Draw( Board board, Model chipModel, Matrix baseTransform, Matrix[] chipTransforms ) {
			Matrix world = OrientationMatrix * baseTransform;
			LightingEffect lightingEffect = board.LightingEffect;

			lightingEffect.GlowScale.SetValue( GlowScale );
			lightingEffect.ColorOverride.SetValue( ColorOverride );
			lightingEffect.TexCoordScale.SetValue( TexCoordScale );

			foreach( ModelMesh mesh in chipModel.Meshes ) {
				Matrix modelWorld = chipTransforms[ mesh.ParentBone.Index ] * world;
				Matrix modelWorldView = modelWorld * board.Camera.ViewMatrix;
				Matrix modelWorldViewProjection = modelWorldView * board.Camera.ProjectionMatrix;

				lightingEffect.World.SetValue( modelWorld );
				lightingEffect.WorldView.SetValue( modelWorldView );
				lightingEffect.WorldViewProjection.SetValue( modelWorldViewProjection );

				foreach( ModelMeshPart meshPart in mesh.MeshParts ) {
					bool textureSet = false;
					string materialIdentifier = meshPart.Tag as string;
					if( materialIdentifier != null ) {
						switch( materialIdentifier ) {
							case "Front":
								lightingEffect.TexCoordTranslation.SetValue( this.TexCoordTranslationFront );
								textureSet = SetTexture( board, 0 );
								break;
							case "Back":
								lightingEffect.TexCoordTranslation.SetValue( this.TexCoordTranslationBack );
								if( board.TwoSided )
									textureSet = SetTexture( board, 1 );
								else
									textureSet = SetTexture( board, 0 );
								break;
							default:
								lightingEffect.DiffuseTexture.SetValue( (Texture2D)null );
								break;
						}
					}

					if( textureSet ) {
						lightingEffect.Effect.CurrentTechnique = lightingEffect.SingleTextureTechnique;
					} else {
						lightingEffect.Effect.CurrentTechnique = lightingEffect.NoTextureTechnique;
					}

					lightingEffect.Effect.Begin();
					DrawHelper.DrawMeshPart( mesh, meshPart, lightingEffect.Effect );
					lightingEffect.Effect.End();
				}
			}
		}