#pragma warning disable SA1313 // Parameter names should begin with lower-case letter private static void Postfix(ObstacleController __instance, Quaternion ____worldRotation, ObstacleData obstacleData, Vector3 ____startPos, Vector3 ____midPos, Vector3 ____endPos, ref Bounds ____bounds) #pragma warning restore SA1313 // Parameter names should begin with lower-case letter { if (obstacleData is CustomObstacleData customData) { dynamic dynData = customData.customData; IEnumerable <float> localrot = ((List <object>)Trees.at(dynData, LOCALROTATION))?.Select(n => Convert.ToSingle(n)); Transform transform = __instance.transform; Quaternion localRotation = _quaternionIdentity; if (localrot != null) { localRotation = Quaternion.Euler(localrot.ElementAt(0), localrot.ElementAt(1), localrot.ElementAt(2)); transform.localRotation = ____worldRotation * localRotation; } transform.localScale = Vector3.one; // This is a fix for animation due to obstacles being recycled Track track = AnimationHelper.GetTrack(dynData); if (track != null && ParentObject.Controller != null) { ParentObject parentObject = ParentObject.Controller.GetParentObjectTrack(track); if (parentObject != null) { parentObject.ParentToObject(transform); } else { ParentObject.ResetTransformParent(transform); } } else { ParentObject.ResetTransformParent(transform); } bool?cuttable = Trees.at(dynData, CUTTABLE); if (cuttable.HasValue && !cuttable.Value) { ____bounds.size = _vectorZero; } dynData.startPos = ____startPos; dynData.midPos = ____midPos; dynData.endPos = ____endPos; dynData.localRotation = localRotation; dynData.boundsSize = ____bounds.size; } __instance.Update(); }
public override void Update(GameTime gameTime) { bool hasMusicChanged = false; /* * musicLoopCounter = musicLoopCounter - gameTime.ElapsedGameTime.Milliseconds; * if (musicLoopCounter < 0) * { * mainMusic.Resume(); * } */ /* * if (musicLoopCounter < 0) * { * gameSound.Dispose(); * gameSound.Play(); * musicLoopCounter = 2000;// gameSound.Duration.Milliseconds; * } * else * { * musicLoopCounter = musicLoopCounter - gameTime.ElapsedGameTime.Milliseconds; * } */ if (HideOutGame.LEVEL_DESIGN_MODE) { playerController.Update(gameTime, mobile); entityGenerationController.Update(gameTime); xmlController.Update(); return; } pauseState = Keyboard.GetState(); if (isPaused) { if (((pauseState.IsKeyDown(Keys.Left) && !oldState.IsKeyDown(Keys.Left)) || (pauseState.IsKeyDown(Keys.Right) && !oldState.IsKeyDown(Keys.Right)) || (pauseState.IsKeyDown(Keys.Up) && !oldState.IsKeyDown(Keys.Up)) || (pauseState.IsKeyDown(Keys.Down) && !oldState.IsKeyDown(Keys.Down))) && !displayController.hasLost && !displayController.hasWon) { isPaused = false; displayController.displayLevel = false; } else if (pauseState.IsKeyDown(Keys.Enter)) { if (displayController.hasLost == true) { isPaused = false; displayController.displayLevel = false; displayController.hasLost = false; displayController.hasWon = false; HideOutGame.LEVEL_INITIALIZED = false; Type = "TitleScreen"; //gameSoundOn = true; //gameSound.Dispose(); //gameSound.Play(); return; } else if (displayController.hasWon == true) { isPaused = false; displayController.displayLevel = false; displayController.hasLost = false; displayController.hasWon = false; HideOutGame.LEVEL_INITIALIZED = false; EndScreen.oldState = pauseState; Type = "EndScreen"; } } else { oldState = pauseState; return; } } oldState = pauseState; //musicLoopCounter -= gameTime.ElapsedGameTime.Milliseconds; //musicLoopCounter = musicLoopCounter - gameTime.ElapsedGameTime.Milliseconds; if (gameSoundOn && ((musicLoopCounter == 0) || (gameSound.IsDisposed))) { gameSound.Dispose(); //gameSound.Play(); musicLoopCounter = 2000; // +gameSound.Duration.Milliseconds; } //Console.WriteLine("Time: " + gameTime.ElapsedGameTime.TotalMilliseconds); if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape)) { // TODO: quit game } // TODO: Add your update logic here if (npcController.Update(playerController.thePlayer, obstacleController.obstacles, gameTime) && !CHEAT_MODE) { isPaused = true; //TODO: show losing screen Console.WriteLine("You lose! Good day!"); // gameSound.Dispose //failureSound.Player(); //gameSoundOn = false; //gameSound.Dispose(); //failureSound.Play(); //musicLoopCounter = failureSound.Duration.Milliseconds; //Console.WriteLine("Duration: " + failureSound.Duration.Milliseconds musicSelection = 1; hasMusicChanged = true; //mainMusic.Pause(); //failureSound.Play(); //musicLoopCounter = failureSound.Duration.Milliseconds; //failureSound.Duration displayController.hasLost = true;//Exit(); } displayController.level = levelController.currentLevel; switch (levelController.Update()) { case 0: //isPaused = true; displayController.displayLevel = true; /* * if (pauseState.IsKeyDown(Keys.Enter)) * { * isPaused = false; * } * else * { * isPaused = true; * } */ break; case 1: isPaused = true; displayController.displayLevel = true; displayController.level = levelController.currentLevel; break; case 2: isPaused = true; //TODO: show winning screen gameSoundOn = false; Console.WriteLine("You win! Good day!"); //mainMusic.Pause(); //victorySound.Play(); musicSelection = 2; //musicLoopCounter = victorySound.Duration.Milliseconds; //musicLoopCounter = victorySound.Duration.Milliseconds; try { File.Delete("Content\\Levels\\savestate.txt"); } catch { } displayController.hasWon = true; // GetHashCode//Exit(); break; } if (playerController.Update(gameTime, mobile)) { isPaused = true; gameSoundOn = false; Console.WriteLine("You lose! Good day!"); //gameSound.Dispose(); //failureSound.Play(); musicSelection = 1; hasMusicChanged = true; //mainMusic.Pause(); //failureSound.Play(); //musicLoopCounter = failureSound.Duration.Milliseconds; displayController.hasLost = true; } if (!hasMusicChanged) { musicSelection = 0; } itemController.Update(gameTime); obstacleController.Update(gameTime); displayController.Update(gameTime); xmlController.Update(); }