//All Keyboard input will be processed here public void CheckKeyBoardInput() { IDOWN = false; //End Game Case if (checKeyBoardState.IsKeyDown(Keys.Escape)) { gameObj.Exit(); } else if (checKeyBoardState.IsKeyDown(Keys.B) && ACTIVELEVEL == 6 && burstRemaining >= 0) { //gameObj.BurstSound.Play(); burstExhausted += 1; if (characterFacing == CharDirection.Right) { gameObj.PlayerClass.UpdateRight(gameTime); velocity.X = (float)(gameTime.ElapsedGameTime.TotalMilliseconds / 5) * 3; } if (characterFacing == CharDirection.Left) { gameObj.PlayerClass.UpdateLeft(gameTime); velocity.X = -(float)(gameTime.ElapsedGameTime.TotalMilliseconds / 5) * 3; } } //Right Movement Controlled By D else if (checKeyBoardState.IsKeyDown(Keys.D)) { gameObj.PlayerClass.UpdateRight(gameTime); characterFacing = CharDirection.Right; if (ACTIVELEVEL == 6 && activePlayer == ActivePlayerz.Miner) { velocity.X = (float)((gameTime.ElapsedGameTime.TotalMilliseconds / 5) * 1.25); } else { velocity.X = (float)((gameTime.ElapsedGameTime.TotalMilliseconds / 5)); } } //Left Movement Controlled by A else if (checKeyBoardState.IsKeyDown(Keys.A)) { gameObj.PlayerClass.UpdateLeft(gameTime); characterFacing = CharDirection.Left; if (ACTIVELEVEL == 6 && activePlayer == ActivePlayerz.Miner) { velocity.X = -(float)((gameTime.ElapsedGameTime.TotalMilliseconds / 5) * 1.25); } else { velocity.X = -(float)((gameTime.ElapsedGameTime.TotalMilliseconds / 5)); } } else { if (jumpState == false && ladderCollision(new Rectangle((int)(gameObj.currPlayerPositionFunc.X + velocity.X), (int)(gameObj.currPlayerPositionFunc.Y + velocity.Y - yOffset), 40, 40))) { gameObj.PlayerClass.UpdateClimb(gameTime); } else if (jumpState == false) { if (characterFacing == CharDirection.Right) { gameObj.PlayerClass.UpdateStand(1); } else { gameObj.PlayerClass.UpdateStand(-1); } } velocity.X = 0f; } if (checKeyBoardState.IsKeyDown(Keys.W)) { if (ladderCollision(new Rectangle((int)(gameObj.currPlayerPositionFunc.X + velocity.X), (int)(gameObj.currPlayerPositionFunc.Y + velocity.Y - yOffset), 40, 40))) { gameObj.PlayerClass.UpdateClimb(gameTime); characterFacing = CharDirection.Up; velocity.Y = -1; gameObj.currPlayerPositionFunc.Y += (int)velocity.Y; climbState = true; } } climbState = false; //Checks for jump keypress Jump(); if (checKeyBoardState.IsKeyDown(Keys.I) && HASBAG == true) { if (IDOWN) { IDOWN = false; } else { IDOWN = true; } } if(checKeyBoardState.IsKeyDown(Keys.S)) { switch (playerInteractionDetection()) { case 0: { break; } //Swap to Eng case 1: { if (activePlayer == ActivePlayerz.Miner) { gameObj.PlayerClassMiner.PlayerLocation = new Vector2(gameObj.PlayerClass.PlayerLocation.X, gameObj.PlayerClass.PlayerLocation.Y - 80); gameObj.PlayerClassMiner.ACTIVELVL = ACTIVELEVEL; gameObj.PlayerClassMiner.SwapAble = false; } else if (activePlayer == ActivePlayerz.Foreman) { gameObj.PlayerClassFore.PlayerLocation = new Vector2(gameObj.PlayerClass.PlayerLocation.X, gameObj.PlayerClass.PlayerLocation.Y - 80); gameObj.PlayerClassFore.ACTIVELVL = ACTIVELEVEL; gameObj.PlayerClassFore.SwapAble = false; } gameObj.PlayerClass = gameObj.PlayerClassEng; gameObj.PlayerClass.SwapAble = false; activePlayer = ActivePlayerz.Engineer; break; } //Swap to foreman case 2: { if (activePlayer == ActivePlayerz.Miner) { gameObj.PlayerClassMiner.PlayerLocation = new Vector2(gameObj.PlayerClass.PlayerLocation.X, gameObj.PlayerClass.PlayerLocation.Y - 80); gameObj.PlayerClassMiner.ACTIVELVL = ACTIVELEVEL; gameObj.PlayerClassMiner.SwapAble = false; } else if (activePlayer == ActivePlayerz.Engineer) { gameObj.PlayerClassEng.PlayerLocation = new Vector2(gameObj.PlayerClass.PlayerLocation.X, gameObj.PlayerClass.PlayerLocation.Y - 80); gameObj.PlayerClassEng.ACTIVELVL = ACTIVELEVEL; gameObj.PlayerClassEng.SwapAble = false; } gameObj.PlayerClass = gameObj.PlayerClassFore; gameObj.PlayerClass.SwapAble = false; activePlayer = ActivePlayerz.Foreman; break; } //Swap to miner case 3: { if (activePlayer == ActivePlayerz.Engineer) { gameObj.PlayerClassEng.PlayerLocation = new Vector2(gameObj.PlayerClass.PlayerLocation.X, gameObj.PlayerClass.PlayerLocation.Y - 80); gameObj.PlayerClassEng.ACTIVELVL = ACTIVELEVEL; gameObj.PlayerClassEng.SwapAble = false; } else if (activePlayer == ActivePlayerz.Foreman) { gameObj.PlayerClassFore.PlayerLocation = new Vector2(gameObj.PlayerClass.PlayerLocation.X, gameObj.PlayerClass.PlayerLocation.Y - 80); gameObj.PlayerClassFore.ACTIVELVL = ACTIVELEVEL; gameObj.PlayerClassFore.SwapAble = false; } gameObj.PlayerClass = gameObj.PlayerClassMiner; gameObj.PlayerClass.SwapAble = false; activePlayer = ActivePlayerz.Miner; break; } } } //Check if we have the mining age euipt if (checKeyBoardState.IsKeyDown(Keys.T) && gameObj.checkInventoryItem(0) && ACTIVELEVEL == 1) { if (TDOWN) { TDOWN = false; } else { TDOWN = true; } //gameObj.Pickaxe.Play(); throwItem(); } //Remove item from character and return to inventory bag if (checKeyBoardState.IsKeyDown(Keys.U)) { unequiptItem(); } if (checKeyBoardState.IsKeyDown(Keys.R)) { if (ACTIVELEVEL < 6) { restartLevel(); } } //M is for minigame interaction elements if (checKeyBoardState.IsKeyDown(Keys.M) && interactiveDetection(gameObj.PlayerBox) && ACTIVELEVEL == 2) { CraneGameSimulation(); } //Checks for item key presses, these equipt items in inventory if applicable. checkItemUse(); GUIINVUpdate(); if (ACTIVELEVEL == 6) { burstRemaining -= burstExhausted; burstExhausted = 0; } //Check if we need to load a lower level if (gameObj.currPlayerPositionFunc.X <= 0 && ACTIVELEVEL > -1 && ACTIVELEVEL < 6) { if (ACTIVELEVEL != 0) { ACTIVELEVEL -= 1; loadLevel(-1); } } if(gameObj.currPlayerPositionFunc.X <= 0) { gameObj.currPlayerPositionFunc.X = 0; } //Check if we need to load a higher level if (gameObj.currPlayerPositionFunc.X >= graphics.PreferredBackBufferWidth && ACTIVELEVEL > -1 && ACTIVELEVEL < 6) { if (ACTIVELEVEL != 4) { ACTIVELEVEL += 1; loadLevel(1); } } if (gameObj.currPlayerPositionFunc.X >= graphics.PreferredBackBufferWidth) { gameObj.currPlayerPositionFunc.X = graphics.PreferredBackBufferWidth; } //Flash light not accessible until after this stage. if (eventStates[2]) { checkFlashLight(); } }
//TODO Determine all parameters needed to spawn a physics class with functionality. public Physics(Game1 gameObj, int characterNum, SpriteBatch sprites, GraphicsDeviceManager graphics) { characterFacing = CharDirection.Right; activePlayer = ActivePlayerz.Miner; ACTIVELEVEL = 1; this.gameObj = gameObj; this.characterNum = characterNum; this.sprites = sprites; this.graphics = graphics; eventStates = new bool[5]; healthRemaining = 200; pathHighlight = Texture2D.FromStream(gameObj.GraphicsDevice, TitleContainer.OpenStream(@"Images/GUIImages/Path.png")); resList = new List<double>(); resList.Add(0.0); resList.Add(0.0); resList.Add(0.0); }