/// <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) { inputState.Update(); ticking = (countdown > 0); inputState.hoveringElement = ui.GetMouseHover(inputState.MousePos); UpdateZoneChanges(); ui.Update(inputState); while (uiActions.Count > 0) { UIButton.OnPressDelegate action = uiActions[0]; uiActions.RemoveAt(0); action(); } if (ticking) { countdown--; if (countdown == 0) { EndTurn_timerExpired(); } } base.Update(gameTime); }
public override UIMouseResponder GetOverlayMouseHover(Vector2 localMousePos) { if (selected) { return(ui.GetMouseHover(localMousePos)); } return(null); }
public override UIMouseResponder GetMouseHover(Vector2 localMousePos) { if (frame.Contains(localMousePos)) { return(this); } if (isOpen) { return(dropDown.GetMouseHover(localMousePos)); } return(null); }
public UIMouseResponder GetMouseHover(Vector2 mousePos) { UIMouseResponder result = ui.GetMouseHover(mousePos); if (result != null) { return(result); } for (int Idx = objects.Count - 1; Idx >= 0; --Idx) { result = objects[Idx].GetOverlayMouseHover(mousePos); if (result != null) { return(result); } } for (int Idx = objects.Count - 1; Idx >= 0; --Idx) { result = objects[Idx].GetPipeMouseHover(mousePos); if (result != null) { return(result); } } for (int Idx = objects.Count - 1; Idx >= 0; --Idx) { result = objects[Idx].GetMouseHover(mousePos); if (result != null) { return(result); } } return(this); }
/// <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) { inputState.Update(); inputState.hoveringElement = ui.GetMouseHover(inputState.MousePos); ui.Update(inputState); if (inputState.WasKeyJustReleased(Keys.F11)) { if (inputState.IsKeyDown(Keys.LeftShift) || inputState.IsKeyDown(Keys.RightShift)) { DoStepOut(); } else { DoStepIn(); } } if (inputState.WasKeyJustReleased(Keys.F10)) { DoStepOver(); } if (inputState.WasKeyJustReleased(Keys.F5)) { DoRun(); } if (inputState.WasMouseLeftJustReleased()) { Vector2 mousePos = inputState.MousePos; Vector2 pixelPos = (mousePos - cubeScreenPos) / blockSize; if (pixelPos.X >= 0 && pixelPos.X < 16) { if (pixelPos.Y >= 0 && pixelPos.Y < 16) { // toggle breakpoint ColorRGB breakpointPos = new ColorRGB((byte)((int)pixelPos.X * 17), (byte)((int)pixelPos.Y * 17), showingPosition.B); bool removed = false; for (int Idx = 0; Idx < breakpoints.Count; ++Idx) { Breakpoint currentBreakpoint = breakpoints[Idx]; if (currentBreakpoint.cube == showingCube && currentBreakpoint.position == breakpointPos) { breakpoints.RemoveAt(Idx); removed = true; break; } } if (!removed) { Breakpoint newBreakpoint = new Breakpoint(); newBreakpoint.cube = showingCube; newBreakpoint.position = breakpointPos; breakpoints.Add(newBreakpoint); } } else if (((int)pixelPos.Y) == 16) { showingPosition = new ColorRGB(showingPosition.R, showingPosition.G, (byte)((int)pixelPos.X * 17)); } } else { Vector2 registerPos = (mousePos - registersScreenPos); registerPos.Y /= registersScreenSpacing; if (registerPos.X > 0) { int registerIndex = (int)registerPos.Y; if (registerIndex >= 0 && registerIndex < interestingRegisters.Count) { ShowRegister(interestingRegisters[registerIndex]); } } } } base.Update(gameTime); }
public void Update(InputState inputState) { inputState.hoveringElement = ui.GetMouseHover(inputState.MousePos); /*if (paused) * { * if (inputState.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.A) || inputState.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.D) || inputState.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Space) || inputState.WasMouseRightJustPressed() || (inputState.WasMouseLeftJustPressed() && inputState.MousePos.X < 500 )) || { || paused = false; || } ||}*/ if (paused || pausedThisFrame) { pausedThisFrame = false; Game1.instance.inventory.UpdateWeapons(inputState, player, objects, projectiles); } else { if (timerRunning) { currentTime++; } if (currentTime >= 60 * ChemicalFactory.TIME_PER_CORE * factory.numCores) { Game1.instance.splashes.Add(new Splash("OUT OF TIME", TextAlignment.CENTER, Game1.font, Color.Cyan, new Vector2(200, 200), new Vector2(0, 0), 0, 0, 3)); InitObjects(); } bool needsDestroy = false; Game1.instance.inventory.UpdateWeapons(inputState, player, objects, projectiles); foreach (PlatformObject obj in objects) { obj.Update(inputState, objects, projectiles); if (obj.destroyed) { needsDestroy = true; } } if (needsDestroy) { for (int oIdx = objects.Count - 1; oIdx >= 0; --oIdx) { if (objects[oIdx].destroyed) { objects[oIdx] = objects[objects.Count - 1]; objects.RemoveAt(objects.Count - 1); } } } for (int pIdx = projectiles.Count - 1; pIdx >= 0; --pIdx) { projectiles[pIdx].Update(objects); if (projectiles[pIdx].destroyed) { projectiles[pIdx] = projectiles[projectiles.Count - 1]; projectiles.RemoveAt(projectiles.Count - 1); } } foreach (Command triggerable in triggerables) { triggerable.Update(objects); } } ui.Update(inputState); }