protected override void LoadContent() { spriteBatch = new SpriteBatch(GraphicsDevice); fontLoader = new FontLoader(Content); playing = new PlayingStateClass(graphics, GraphicsDevice, Content); titleScreen = new TitleScreenClass(Content, GraphicsDevice, new Vector2(graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight)); loading = new LoadingScreenClass(Content, null, false); Mouse.SetPosition(graphics.GraphicsDevice.Viewport.Width / 2, graphics.GraphicsDevice.Viewport.Height / 2); menu = new MainMenuStateClass(Content, new Vector2(graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight), true); ChangeGameState(CurrentGameState); buttonSound = Content.Load <SoundEffect>("Sounds/button"); buttonClickSound = Content.Load <SoundEffect>("Sounds/buttonClick"); backSound = Content.Load <SoundEffect>("Sounds/back"); }
public void Draw(SpriteBatch spriteBatch, GraphicsDeviceManager graphics, GameTime gameTime, FontLoader fontLoader) { if (gameTime.TotalGameTime.TotalMilliseconds <= LoadingTime + TimeBeforeUserCanContinue) loading.Draw(graphics, spriteBatch); else if (!(timePressed.TotalMilliseconds < DummyTimeSpan.TotalMilliseconds) && !isGoingToMenu) { spriteBatch.Begin(); //if (!didClick) { Game1.PlaySound("back"); didClick = true; } string output = "Press Any Key"; SpriteFont font = fontLoader.GetFont("OpenSans", false, 14); spriteBatch.DrawString(font, output, new Vector2(graphics.PreferredBackBufferWidth / 2, graphics.PreferredBackBufferHeight * 40 / 55), Color.White, 0, font.MeasureString(output) / 2, 1.2f * ((ResOffset.X + ResOffset.Y) / 2), SpriteEffects.None, 0); blackTex.SetData(new Color[] { new Color(0, 0, 0, PressAlpha) }); spriteBatch.Draw(blackTex, new Rectangle(0, 0, 1000000, 20000000), Color.Black); spriteBatch.Draw(Title, new Vector2(graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight * 9 / 10) / 2, null, Color.White, 0, new Vector2(650, 332) / 2, 1.3f * ((ResOffset.X + ResOffset.Y) / 2), SpriteEffects.None, 0); spriteBatch.End(); } if (isGoingToMenu) { spriteBatch.Begin(); if (logoAnimation.TotalMilliseconds >= timeBeforeMoving) { logoAnim.Update(gameTime.ElapsedGameTime); } spriteBatch.Draw(logo, logoAnim.GetV2(0), null, Color.White * MathHelper.Clamp((float)logoAnimation.TotalMilliseconds / logoFadeInTime, 0, 1), 0, logoOrigin, logoAnim.GetV2(1), SpriteEffects.None, 0); spriteBatch.End(); } graphics.GraphicsDevice.BlendState = BlendState.Opaque; graphics.GraphicsDevice.DepthStencilState = DepthStencilState.Default; }
public void Draw(SpriteBatch spriteBatch, GraphicsDeviceManager graphics, GameTime gameTime, FontLoader fontLoader) { if (gameTime.TotalGameTime.TotalMilliseconds <= LoadingTime + TimeBeforeUserCanContinue) { loading.Draw(graphics, spriteBatch); } else if (!(timePressed.TotalMilliseconds < DummyTimeSpan.TotalMilliseconds) && !isGoingToMenu) { spriteBatch.Begin(); //if (!didClick) { Game1.PlaySound("back"); didClick = true; } string output = "Press Any Key"; SpriteFont font = fontLoader.GetFont("OpenSans", false, 14); spriteBatch.DrawString(font, output, new Vector2(graphics.PreferredBackBufferWidth / 2, graphics.PreferredBackBufferHeight * 40 / 55), Color.White, 0, font.MeasureString(output) / 2, 1.2f * ((ResOffset.X + ResOffset.Y) / 2), SpriteEffects.None, 0); blackTex.SetData(new Color[] { new Color(0, 0, 0, PressAlpha) }); spriteBatch.Draw(blackTex, new Rectangle(0, 0, 1000000, 20000000), Color.Black); spriteBatch.Draw(Title, new Vector2(graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight * 9 / 10) / 2, null, Color.White, 0, new Vector2(650, 332) / 2, 1.3f * ((ResOffset.X + ResOffset.Y) / 2), SpriteEffects.None, 0); spriteBatch.End(); } if (isGoingToMenu) { spriteBatch.Begin(); if (logoAnimation.TotalMilliseconds >= timeBeforeMoving) { logoAnim.Update(gameTime.ElapsedGameTime); } spriteBatch.Draw(logo, logoAnim.GetV2(0), null, Color.White * MathHelper.Clamp((float)logoAnimation.TotalMilliseconds / logoFadeInTime, 0, 1), 0, logoOrigin, logoAnim.GetV2(1), SpriteEffects.None, 0); spriteBatch.End(); } graphics.GraphicsDevice.BlendState = BlendState.Opaque; graphics.GraphicsDevice.DepthStencilState = DepthStencilState.Default; }
protected override void LoadContent() { spriteBatch = new SpriteBatch(GraphicsDevice); fontLoader = new FontLoader(Content); playing = new PlayingStateClass(graphics, GraphicsDevice, Content); titleScreen = new TitleScreenClass(Content, GraphicsDevice, new Vector2(graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight)); loading = new LoadingScreenClass(Content, null, false); Mouse.SetPosition(graphics.GraphicsDevice.Viewport.Width / 2, graphics.GraphicsDevice.Viewport.Height / 2); menu = new MainMenuStateClass(Content, new Vector2(graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight), true); ChangeGameState(CurrentGameState); buttonSound = Content.Load<SoundEffect>("Sounds/button"); buttonClickSound = Content.Load<SoundEffect>("Sounds/buttonClick"); backSound = Content.Load<SoundEffect>("Sounds/back"); }
public void Draw(SpriteBatch spriteBatch, FontLoader fontLoader, GraphicsDeviceManager graphics, GameTime gametime) { #region mirror if (isOnScreen(b, camera.view * camera.projection)) { device.SetRenderTarget(rt); device.Clear(Color.Black); Vector3 camerafinalPosition = camera.GetFinalPosition(); Vector3 vectorToMirror = mirrorPos_Middle - camera.position; Vector3 mirrorReflectionVector = vectorToMirror - 2 * (Vector3.Dot(vectorToMirror, room.mirror.mirrorNormal)) * room.mirror.mirrorNormal; Matrix mirrorLookAt = Matrix.CreateLookAt(mirrorPos_Middle, mirrorReflectionVector, Vector3.Up) * Matrix.CreateScale(3, 1, 1); room.DrawRoom(mirrorLookAt, camera.projection, camera.position, camera.characterOffset, camera.isCrouched, showBoundingBox, camera.isAnimating); camera.DrawCharacter(mirrorLookAt); device.SetRenderTarget(null); } #endregion device.BlendState = BlendState.Opaque; device.RasterizerState = RasterizerState.CullCounterClockwise; room.DrawRoom(camera.view, camera.projection, camera.position, camera.characterOffset, camera.isCrouched, showBoundingBox, camera.isAnimating); room.mirror.Draw((Texture2D)rt, camera.view, camera.projection); UpdateFrameRate(gametime); teleporter.Draw(camera.view, camera.projection, device); #region blink spriteBatch.Begin(); spriteBatch.Draw(BlackTexture, new Rectangle(0, 0, graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight), Color.White * ((float)MathHelper.Clamp(blink.GetFloat(0), 0, 255) / 255f)); spriteBatch.End(); device.BlendState = BlendState.Opaque; device.DepthStencilState = DepthStencilState.Default; #endregion #region fps if (showFPS) { spriteBatch.Begin(); string output = frameRate + " FPS"; spriteBatch.DrawString(fontLoader.GetFont("OpenSans", false, 14), output, new Vector2(6, 3), Color.Black, 0, Vector2.Zero, 1.0f, SpriteEffects.None, 0); spriteBatch.End(); device.BlendState = BlendState.Opaque; device.DepthStencilState = DepthStencilState.Default; } #endregion }