public void Update(GameTime gameTime) { if (Keyboard.GetState().IsKeyDown(Keys.Left)) { runner.rotation.Z += 0.1f; } if (Keyboard.GetState().IsKeyDown(Keys.Right)) { runner.rotation.Z -= 0.1f; } if (Keyboard.GetState().IsKeyDown(Keys.Up)) { timer += 12f; runner.position.X += (float)Math.Sin(runner.rotation.Z) * runspeed; runner.position.Y -= (float)Math.Cos(runner.rotation.Z) * runspeed; } if (Keyboard.GetState().IsKeyDown(Keys.Space) && runner.position.Z <= 0) { verticalVelocity = 10; } runner.position.Z += verticalVelocity; if (Keyboard.GetState().IsKeyDown(Keys.Escape)) { globals.currentState = gamestates.menu; } if (timer < 100) { // lift left leg float movement = timer / 100; runner.SetBoneRotationTo("ThighL", new Vector3(0, 0, movement)); runner.SetBoneRotationTo("ShinL", new Vector3(movement * 2, 0, 0)); runner.SetBoneRotationTo("ThighR", new Vector3(0, 0, movement)); runner.SetBoneRotationTo("ShinR", new Vector3(movement, 0, 0)); runner.SetBoneRotationTo("UpperArmR", new Vector3(0, 0, movement)); runner.SetBoneRotationTo("UpperArmL", new Vector3(0, 0, movement)); } else if (timer < 200) { // lower left leg float movement = 2 - timer / 100; runner.SetBoneRotationTo("ThighL", new Vector3(0, 0, movement)); runner.SetBoneRotationTo("ShinL", new Vector3(movement * 2, 0, 0)); runner.SetBoneRotationTo("ThighR", new Vector3(0, 0, movement)); runner.SetBoneRotationTo("ShinR", new Vector3(movement, 0, 0)); runner.SetBoneRotationTo("UpperArmR", new Vector3(0, 0, movement)); runner.SetBoneRotationTo("UpperArmL", new Vector3(0, 0, movement)); } else if (timer < 300) { // lift right leg float movement = 2 - timer / 100; runner.SetBoneRotationTo("ThighL", new Vector3(0, 0, movement)); runner.SetBoneRotationTo("ShinL", new Vector3(-movement, 0, 0)); runner.SetBoneRotationTo("ThighR", new Vector3(0, 0, movement)); runner.SetBoneRotationTo("ShinR", new Vector3(-movement * 2, 0, 0)); runner.SetBoneRotationTo("UpperArmR", new Vector3(0, 0, movement)); runner.SetBoneRotationTo("UpperArmL", new Vector3(0, 0, movement)); } else if (timer < 400) { // lift left leg float movement = -4 + timer / 100; runner.SetBoneRotationTo("ThighL", new Vector3(0, 0, movement)); runner.SetBoneRotationTo("ShinL", new Vector3(-movement, 0, 0)); runner.SetBoneRotationTo("ThighR", new Vector3(0, 0, movement)); runner.SetBoneRotationTo("ShinR", new Vector3(-movement * 2, 0, 0)); runner.SetBoneRotationTo("UpperArmR", new Vector3(0, 0, movement)); runner.SetBoneRotationTo("UpperArmL", new Vector3(0, 0, movement)); //runner.SetBoneRotationTo("ArmUpperLMesh", new Vector3(0, 0, movement)); } else { timer = 0; } if (runner.position.Z > 0) { verticalVelocity -= 1f; // jump bone settings runner.SetBoneRotationTo("ThighL", new Vector3(0, 0, 2.0f)); runner.SetBoneRotationTo("ShinL", new Vector3(0.8f, 0, 0)); runner.SetBoneRotationTo("ThighR", new Vector3(0, 0, -2.0f)); runner.SetBoneRotationTo("ShinR", new Vector3(0.8f, 0, 0)); runner.SetBoneRotationTo("UpperArmR", new Vector3(0, 0, 1.4f)); runner.SetBoneRotationTo("UpperArmL", new Vector3(0, 0, -1.4f)); runner.SetBoneRotationTo("LowerArmR", new Vector3(-1.1f, 0, 0)); runner.SetBoneRotationTo("LowerArmL", new Vector3(-1.1f, 0, 0)); } else { verticalVelocity = 0; } if (Keyboard.GetState().IsKeyDown(Keys.Z)) { // taunt runner.SetBoneRotationTo("Spine", new Vector3(-0.25f, 0f, 0f)); runner.SetBoneRotationTo("ThighL", new Vector3(0, 0, -0.05f)); runner.SetBoneRotationTo("ShinL", new Vector3(0.0f, 0, 0)); runner.SetBoneRotationTo("ThighR", new Vector3(0, 0, -0.05f)); runner.SetBoneRotationTo("ShinR", new Vector3(0.0f, 0, 0)); runner.SetBoneRotationTo("UpperArmR", new Vector3(0f, 0f, 0.5f)); runner.SetBoneRotationTo("UpperArmL", new Vector3(0f, 0f, -0.5f)); runner.SetBoneRotationTo("LowerArmR", new Vector3(0.3f, 0, 0)); runner.SetBoneRotationTo("LowerArmL", new Vector3(0.3f, 0, 0)); } else { runner.SetBoneRotationTo("Spine", new Vector3(0f, 0f, 0f)); } }
public void Update(GameTime gameTime) { if (Keyboard.GetState().IsKeyDown(Keys.Escape)) { globals.currentState = gamestates.menu; } if (runner.position.X > judge.position.X && runner.position.Z <= 0) { } else { if (Keyboard.GetState().IsKeyDown(Keys.Z) && previousState.IsKeyUp(Keys.Z) || Keyboard.GetState().IsKeyDown(Keys.X) && previousState.IsKeyUp(Keys.X)) { runspeed += 0.05f; } runspeed *= 0.99f; timer += (gameTime.ElapsedGameTime.Milliseconds * runspeed); float distanceTravelled = runspeed * 8; runner.position.X += distanceTravelled; cam.position.X += distanceTravelled; cam.lookAt.X += distanceTravelled; previousState = Keyboard.GetState(); if (Keyboard.GetState().IsKeyDown(Keys.Space) && runner.position.Z <= 0) { verticalVelocity = jumpStrength; } runner.position.Z += verticalVelocity; if (timer < 100) { // lift left leg float movement = timer / 100; runner.SetBoneRotationTo("ThighL", new Vector3(0, 0, movement)); runner.SetBoneRotationTo("ShinL", new Vector3(movement * 2, 0, 0)); runner.SetBoneRotationTo("ThighR", new Vector3(0, 0, movement)); runner.SetBoneRotationTo("ShinR", new Vector3(movement, 0, 0)); runner.SetBoneRotationTo("UpperArmR", new Vector3(0, 0, movement)); runner.SetBoneRotationTo("UpperArmL", new Vector3(0, 0, movement)); } else if (timer < 200) { // lower left leg float movement = 2 - timer / 100; runner.SetBoneRotationTo("ThighL", new Vector3(0, 0, movement)); runner.SetBoneRotationTo("ShinL", new Vector3(movement * 2, 0, 0)); runner.SetBoneRotationTo("ThighR", new Vector3(0, 0, movement)); runner.SetBoneRotationTo("ShinR", new Vector3(movement, 0, 0)); runner.SetBoneRotationTo("UpperArmR", new Vector3(0, 0, movement)); runner.SetBoneRotationTo("UpperArmL", new Vector3(0, 0, movement)); } else if (timer < 300) { // lift right leg float movement = 2 - timer / 100; runner.SetBoneRotationTo("ThighL", new Vector3(0, 0, movement)); runner.SetBoneRotationTo("ShinL", new Vector3(-movement, 0, 0)); runner.SetBoneRotationTo("ThighR", new Vector3(0, 0, movement)); runner.SetBoneRotationTo("ShinR", new Vector3(-movement * 2, 0, 0)); runner.SetBoneRotationTo("UpperArmR", new Vector3(0, 0, movement)); runner.SetBoneRotationTo("UpperArmL", new Vector3(0, 0, movement)); } else if (timer < 400) { // lift left leg float movement = -4 + timer / 100; runner.SetBoneRotationTo("ThighL", new Vector3(0, 0, movement)); runner.SetBoneRotationTo("ShinL", new Vector3(-movement, 0, 0)); runner.SetBoneRotationTo("ThighR", new Vector3(0, 0, movement)); runner.SetBoneRotationTo("ShinR", new Vector3(-movement * 2, 0, 0)); runner.SetBoneRotationTo("UpperArmR", new Vector3(0, 0, movement)); runner.SetBoneRotationTo("UpperArmL", new Vector3(0, 0, movement)); //runner.SetBoneRotationTo("ArmUpperLMesh", new Vector3(0, 0, movement)); } else { timer = 0; } if (runner.position.Z > 0) { verticalVelocity -= gravity; // jump bone settings runner.SetBoneRotationTo("ThighL", new Vector3(0, 0, 2.0f)); runner.SetBoneRotationTo("ShinL", new Vector3(0.8f, 0, 0)); runner.SetBoneRotationTo("ThighR", new Vector3(0, 0, -2.0f)); runner.SetBoneRotationTo("ShinR", new Vector3(0.8f, 0, 0)); runner.SetBoneRotationTo("UpperArmR", new Vector3(0, 0, 1.4f)); runner.SetBoneRotationTo("UpperArmL", new Vector3(0, 0, -1.4f)); runner.SetBoneRotationTo("LowerArmR", new Vector3(-1.1f, 0, 0)); runner.SetBoneRotationTo("LowerArmL", new Vector3(-1.1f, 0, 0)); } else { verticalVelocity = 0; } } }