private void HandleInputReal(InputState input) { if (realTimeState == RealTimeState.SelectingDestionation) { if (input.GetMouseDown()) { Point? mousePoint = grid.GetGridPointFromMousePosition(input.GetMousePosition()); if(mousePoint.HasValue) { Rectangle actualPosition = grid.GetGridRectangleFromGridPoint(mousePoint.Value); actionToPoint.PlaceAction(actionToPointLocation, mousePoint.Value, new Vector2(actualPosition.X, actualPosition.Y), buckets); realTimeState = RealTimeState.Idle; --actionsRemaining; //And replensh the ui actions.Add(GameAction.CreateNewActionFromAction(actionToPoint, GetUiPosition(actionToPoint.ActionType))); //Are we done for today? if (actionsRemaining == 0) { EndDay(); } } } } }
public override void HandleInput(InputState input) { base.HandleInput(input); if (input.GetMouseDown()) { if(closeButtonPosition.Contains(input.GetMousePosition())) { this.ExitScreen(); } } }
/// <summary> /// Lets the game respond to player input. Unlike the Update method, /// this will only be called when the gameplay screen is active. /// </summary> public void HandleInput(InputState input) { if (input == null) throw new ArgumentNullException("input"); /*if (gamePadState.Buttons.Y == ButtonState.Pressed) this.missionRunning = false;*/ IEnumerable<Draggable> actions = null; if (this.gameMode == GameMode.REALTIME) { actions = GetRealDraggables(); } else { actions = GetDecisionDraggble(); } if (currentState == DragState.Idle) { if (input.GetMouseDown()) { //Check if mouse is within any of the dropoff boxes foreach (Draggable draggable in actions) { if (draggable.AttemptBeginDrag(input.GetMousePosition())) { currentState = DragState.Dragging; currentlyDragging = draggable; break; } } } } else if (currentState == DragState.Dragging) { if (input.GetMouseDown()) { //Move the one we are dragging Point? gridPoint = grid.GetGridPointFromMousePosition(input.GetMousePosition()); Rectangle? lockedRectangle = null; if (gridPoint.HasValue) { lockedRectangle = grid.GetGridRectangleFromGridPoint(gridPoint.Value); } currentlyDragging.UpdateDrag(input.GetMouseDelta(), lockedRectangle); } else { Point? gridPoint = grid.GetGridPointFromMousePosition(input.GetMousePosition()); if (gridPoint.HasValue) { //Drop the dropoff in this grid# Rectangle cellRect = grid.GetGridRectangleFromGridPoint(gridPoint.Value); currentlyDragging.EndDrag(cellRect); currentState = DragState.Idle; /*this.buckets.addWater(cellRect.X + (cellRect.Width / 2), cellRect.Y + (cellRect.Height / 2));*/ //this.buckets.addWater(cellRect.X + (cellRect.Width / 2), // cellRect.Y + (cellRect.Height / 2)); if (gameMode == GameMode.REALTIME) { ActionPlaced((Actions.GameAction)currentlyDragging, gridPoint.Value, cellRect); } else { DropoffPlaced((Dropoffs.Dropoff)currentlyDragging, cellRect, gridPoint.Value); } } else { EndDrag(); } } } if (gameMode == GameMode.REALTIME) { HandleInputReal(input); } else { HandleInputDecision(input); } }