/// <summary> /// Allows the game to run logic such as updating the world, /// checking for collisions, gathering input, and playing audio. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> public override void Update(GameTime gameTime) { if (MediaPlayer.State.Equals(MediaState.Stopped)) { MediaPlayer.Play(PoseidonGame.audio.jigsawMusics[random.Next(GameConstants.NumJigsawBackgroundMusics)]); } if (dnaAnimationVideoPlayer.State == MediaState.Stopped) dnaAnimationVideoPlayer.Play(dnaAnimation); cursor.Update(graphicsDevice, PlayGameScene.gameCamera, gameTime, null); MouseState mouseState = Mouse.GetState(); letAIHandleButtonHover = mouseOnLetAIHandle(mouseState); bool dumbValue = false; double dumbDoubleValue = 0; clicked = false; CursorManager.CheckClick(ref lastMouseState, ref currentMouseState, gameTime, ref dumbDoubleValue, ref clicked, ref dumbValue, ref dumbValue); if (!gameStarted) { if (startButtonRect.Intersects(new Rectangle(mouseState.X, mouseState.Y, 10, 10))) { mouseOnPlayButton = true; if (clicked) { gameStarted = true; shufflePieces(); clicked = false; PoseidonGame.audio.MenuScroll.Play(); } } else { mouseOnPlayButton = false; } //else if (clicked && skipButtonRect.Intersects(new Rectangle(mouseState.X, mouseState.Y, 10, 10))) //{ // letAIHandle = true; // clicked = false; // return; //} previewTime += gameTime.ElapsedGameTime.TotalSeconds; if (previewTime < 10) { videoPlayBackState = VideoPlayBackState.ExtractingDNA; videoPlayer.Play(extractDNAVid); stepText = "STEP 1: EXTRACT DNA FROM COLLECTED FRAGMENTS"; } else if (previewTime < 20) { videoPlayBackState = VideoPlayBackState.ReconstructingDNA; videoPlayer.Play(reconstructDNAVid); stepText = "STEP 2: ATTEMPTING TO RECONSTRUCT DNA SEQUENCE"; } else if (previewTime < 30) { videoPlayBackState = VideoPlayBackState.FillingGaps; videoPlayer.Play(fillGapsVid); stepText = "STEP 3: FILLING GAPS IN DNA WITH PREDICTON TECHNIQUES"; } else { videoPlayBackState = VideoPlayBackState.InjectAndGrow; videoPlayer.Play(injectAndGrowVid); stepText = "STEP 4: INJECT DNA INTO CELL AND GROW CELL"; } stepText = Poseidon.Core.IngamePresentation.wrapLine(stepText, videoRectangle.Width - (tabSpace * 2), font); timerString = "RESURRECTING " + animalName; } else { timeNow -= gameTime.ElapsedGameTime.TotalSeconds; checkInOrder(); if (GameConstants.jigsawGameMaxTime - timeNow <= 20) { videoPlayBackState = VideoPlayBackState.ExtractingDNA; videoPlayer.Play(extractDNAVid); stepText = "STEP 1: EXTRACT DNA FROM COLLECTED FRAGMENTS"; } else if (GameConstants.jigsawGameMaxTime - timeNow <= 40) { videoPlayBackState = VideoPlayBackState.ReconstructingDNA; videoPlayer.Play(reconstructDNAVid); stepText = "STEP 2: ATTEMPTING TO RECONSTRUCT DNA SEQUENCE"; } else if (GameConstants.jigsawGameMaxTime - timeNow <= 60) { videoPlayBackState = VideoPlayBackState.FillingGaps; videoPlayer.Play(fillGapsVid); stepText = "STEP 3: FILLING GAPS IN DNA WITH PREDICTON TECHNIQUES"; } else { videoPlayBackState = VideoPlayBackState.InjectAndGrow; videoPlayer.Play(injectAndGrowVid); stepText = "STEP 4: INJECT DNA INTO CELL AND GROW CELL"; } stepText = Poseidon.Core.IngamePresentation.wrapLine(stepText, videoRectangle.Width - (tabSpace * 2), font); if (timeNow <= 0) { timeUp = true; } timerString = "RESURRECTING " + animalName + "\nTIME REMAINING: " + ((int)timeNow).ToString() + " Seconds"; if (letAIHandleButtonHover && clicked) { letAIHandle = true; clicked = false; PoseidonGame.audio.MenuScroll.Play(); return; } // If not sliding, then the player can control, otherwise he has to wait until the sliding finishes if (isSliding == false) { float desiredWidthPerPiece; float desiredHeightPerPiece; getDesiredWidthAndHeightPerPiece(out desiredWidthPerPiece, out desiredHeightPerPiece); // Get the cell the mouse is targeting getRowColOfPiece(mouseState, desiredWidthPerPiece, desiredHeightPerPiece, out mouseRow, out mouseCol); // If slidable if (mouseState.LeftButton == ButtonState.Pressed && isSlidable(mouseRow, mouseCol)) { isSliding = true; moveBlocks(mouseRow, mouseCol); if (!gamePlayed) gamePlayed = true; } } // Slide otherwise else moveBlocks(mouseRow, mouseCol); } base.Update(gameTime); }
public override void Show() { MediaPlayer.Stop(); cursor.SetMenuCursorImage(); timeUp = false; timeNow = (double)GameConstants.jigsawGameMaxTime; previewTime = 0; inOrder = false; letAIHandle = false; videoPlayBackState = VideoPlayBackState.ExtractingDNA; vidIndex = 0; gameStarted = gamePlayed = false; unShufflePieces(); mouseOnPlayButton = false; base.Show(); }