/// <summary>Updates the specified input.</summary> public void Update(DistortionType distortion) { this.Distortion = distortion; if (this.input.IsKeyPressed(Keys.H) || this.input.IsKeyPressed(Keys.Help)) { HelpViewTypes help; switch (this.HelpView) { case HelpViewTypes.Header: help = HelpViewTypes.Full; break; case HelpViewTypes.Full: help = HelpViewTypes.Hidden; break; default: help = HelpViewTypes.Header; break; } this.HelpView = help; } }
public void SetDistortion(string distortion) { foreach (string s in Enum.GetNames(typeof(DistortionType))) { if (s.ToLower() == distortion.ToLower()) { Distortion = (DistortionType)Enum.Parse(typeof(DistortionType), distortion, true); return; } } if (distortion.ToLower() == "piss off") { return; } // "piss off" is stainless' version of "none" Console.WriteLine("Unknown distortion: " + distortion); }
/// <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> protected override void Update(GameTime gameTime) { if (!this.IsActive) { return; } // Get current input state this.input.Update(); // Press Escape to exit if (this.input.KeyboardState.IsKeyDown(Keys.Escape)) { this.Exit(); } // Switch distortion type if (this.input.IsMouseWheelUp) { DistortionType result; switch (this.Distortion) { case DistortionType.Image: result = DistortionType.Shockwave; break; case DistortionType.Shockwave: result = DistortionType.SineWave; break; default: result = DistortionType.Image; break; } this.Distortion = result; } else if (this.input.IsMouseWheelDown) { DistortionType result; switch (this.Distortion) { case DistortionType.Image: result = DistortionType.SineWave; break; case DistortionType.Shockwave: result = DistortionType.Image; break; default: result = DistortionType.Shockwave; break; } this.Distortion = result; } // Press H for Help this.help.Update(this.Distortion); // Hold left mouse button to see image ripples under your mouse pointer. //if (this.input.IsMouseLeftButtonPressed) if (this.input.MouseState.LeftButton == ButtonState.Pressed) { switch (this.Distortion) { case DistortionType.Shockwave: this.shockwave.AddRipplesUnderMouseCursor(gameTime); break; case DistortionType.SineWave: this.sineWaveDistortion.AddRipplesUnderMouseCursor(gameTime); break; default: this.imageDistortion.AddRipplesUnderMouseCursor(gameTime); break; } } // Hold right mouse button to see moving water if (this.input.MouseState.RightButton == ButtonState.Pressed) { switch (this.Distortion) { case DistortionType.Shockwave: this.shockwave.AnimateWater(); break; case DistortionType.SineWave: this.sineWaveDistortion.AnimateWater(); break; default: this.imageDistortion.AnimateWater(); break; } } switch (this.Distortion) { case DistortionType.Shockwave: this.shockwave.Update(gameTime); break; case DistortionType.SineWave: this.sineWaveDistortion.Update(gameTime); break; default: this.imageDistortion.Update(gameTime); break; } }