private void MouseControls() { for (int i = 0; i < buttons.Count; i++) { Rectangle buttonRect = new Rectangle( (int)buttons[i].Position.X - buttons[i].Passive.SourceRectangle.Value.Width / 2, (int)buttons[i].Position.Y - buttons[i].Passive.SourceRectangle.Value.Height / 2, buttons[i].Passive.SourceRectangle.Value.Width, buttons[i].Passive.SourceRectangle.Value.Height); if (ControlManager.IsMouseOverArea(buttonRect)) { if (ControlManager.IsMouseMoving()) { if (buttonIndex != i) { PlayHoverSound(); } buttonIndex = i; } if (ControlManager.IsLeftMouseButtonClicked()) { ButtonActions(); } } } }
protected void MouseControls() { if (baseState.IsOverlayDisplayed) { if (ControlManager.IsLeftMouseButtonClicked() && Game.IsActive) { ActiveMenuState.ButtonActions(); } } else { for (int i = 0; i < allButtons.Count; i++) { if (ControlManager.IsMouseOverArea(allButtons[i].Bounds)) { if (ControlManager.IsMouseMoving()) { activeButtonIndexY = i; } if (ControlManager.IsLeftMouseButtonClicked()) { ActiveMenuState.ButtonActions(); } } } } }
private void CheckMouseCursorLevel1() { for (int i = 0; i < cursorManager.displayList.Count; i++) { if (ControlManager.IsMouseOverArea(cursorManager.displayList[i].Bounds)) { cursorLevel1Position = i; if (ControlManager.IsLeftMouseButtonClicked()) { OnPressCursorLevel1(); } } } }
private void CheckMouseLevel1() { for (int i = 0; i < cursorManager.displayList.Count; i++) { if (ControlManager.IsMouseOverArea(cursorManager.displayList[i].Bounds)) { //if (cursorCoordLv1 != null) //{ int xCoord = cursorManager.displayList[i].Coordinate.X; int yCoord = cursorManager.displayList[i].Coordinate.Y; cursorCoordLv1.SetCursor(xCoord, yCoord); //cursorManager.CursorCoordLv1.X = cursorManager.displayList[i].Coordinate.X; //cursorManager.CursorCoordLv1.Y = cursorManager.displayList[i].Coordinate.Y; if (ControlManager.IsLeftMouseButtonClicked()) { OnPressLevel1(); } //} } } }
public override void Update(GameTime gameTime) { if (BaseState.GetBase() != null) { availableMissions = MissionManager.ReturnAvailableMissions(BaseState.GetBase().name); } if (BaseStateManager.ButtonControl.Equals(ButtonControl.Mission) || BaseStateManager.ButtonControl.Equals(ButtonControl.Response)) { missionCursor.isActive = true; missionCursor.isVisible = true; } else { missionCursor.isActive = false; missionCursor.isVisible = false; } if (BaseStateManager.ButtonControl == ButtonControl.Mission) { //Moves button cursor right when pressing up. if (ControlManager.CheckPress(RebindableKeys.Up)) { missionCursorIndex--; } //Moves button cursor left when pressing down else if (ControlManager.CheckPress(RebindableKeys.Down)) { missionCursorIndex++; } if (MissionCursorIndex > availableMissions.Count) { missionCursorIndex = 0; } else if (MissionCursorIndex < 0) { missionCursorIndex = availableMissions.Count; } for (int i = 0; i < availableMissions.Count + 1; i++) { String text = i != availableMissions.Count ? availableMissions[i].MissionName : "Back"; if (ControlManager.IsMouseOverText(FontManager.GetFontStatic(14), text, new Vector2(Game1.ScreenSize.X / 2, Game1.ScreenSize.Y / 2 - 40 + (20 * (i + (i == availableMissions.Count ? 1 : 0))) + FindTextBoxWithText(text).TextBoxRect.Height))) { if (ControlManager.IsMouseMoving()) { missionCursorIndex = i; } } } if (availableMissions.Count > 0 && missionCursorIndex != availableMissions.Count) { selectedMission = availableMissions[MissionCursorIndex]; } } else if (BaseStateManager.ButtonControl == ButtonControl.Response) { //Moves button cursor right when pressing up. if (ControlManager.CheckPress(RebindableKeys.Up)) { responseCursorIndex--; } //Moves button cursor left when pressing down else if (ControlManager.CheckPress(RebindableKeys.Down)) { responseCursorIndex++; } if (MissionManager.MissionResponseBuffer.Count <= 0) { if (ControlManager.IsMouseOverArea(new Rectangle( BaseStateManager.ResponseRectangles[0].X - (int)FontManager.GetFontStatic(14).MeasureString(selectedMission.PosResponse).X / 2, BaseStateManager.ResponseRectangles[0].Y + BaseStateManager.ResponseRectangles[0].Height / 2, (int)FontManager.GetFontStatic(14).MeasureString(selectedMission.PosResponse).X, (int)FontManager.GetFontStatic(14).MeasureString(selectedMission.PosResponse).Y))) { responseCursorIndex = 0; } else if (ControlManager.IsMouseOverArea(new Rectangle( BaseStateManager.ResponseRectangles[1].X - (int)FontManager.GetFontStatic(14).MeasureString(selectedMission.NegResponse).X / 2, BaseStateManager.ResponseRectangles[1].Y + BaseStateManager.ResponseRectangles[1].Height / 2, (int)FontManager.GetFontStatic(14).MeasureString(selectedMission.NegResponse).X, (int)FontManager.GetFontStatic(14).MeasureString(selectedMission.NegResponse).Y))) { responseCursorIndex = 1; } if (responseCursorIndex > 1) { responseCursorIndex = 0; } else if (responseCursorIndex < 0) { responseCursorIndex = 1; } } else { for (int i = 0; i < MissionManager.MissionResponseBuffer.Count; i++) { if (ControlManager.IsMouseOverArea(new Rectangle( BaseStateManager.ResponseRectangles[i].X - (int)FontManager.GetFontStatic(14).MeasureString(MissionManager.MissionResponseBuffer[i]).X / 2, BaseStateManager.ResponseRectangles[i].Y + BaseStateManager.ResponseRectangles[i].Height / 2, (int)FontManager.GetFontStatic(14).MeasureString(MissionManager.MissionResponseBuffer[i]).X, (int)FontManager.GetFontStatic(14).MeasureString(MissionManager.MissionResponseBuffer[i]).Y))) { responseCursorIndex = i; } } if (responseCursorIndex > MissionManager.MissionResponseBuffer.Count - 1) { responseCursorIndex = 0; } else if (responseCursorIndex < 0) { responseCursorIndex = MissionManager.MissionResponseBuffer.Count - 1; } } } if (BaseStateManager.ButtonControl != ButtonControl.Response && ControlManager.CheckPress(RebindableKeys.Pause)) { SkipMissionText(); } else { base.Update(gameTime); } }
private void MouseControls() { for (int i = 0; i < menuOptions.Length / 2; i++) { if (ControlManager.IsMouseOverText(menuOptionFont, menuOptions[i, 0], new Vector2((Game1.ScreenSize.X / 9) * 4 + game.fontManager.GetFont(14).MeasureString(menuOptions[i, 0]).X / 2, Game1.ScreenSize.Y / 3 + (i * 23) + yOffset) + fontOffset)) { if (cursorIndex != i) { PlayHoverSound(); } if (ControlManager.IsLeftMouseButtonClicked()) { ButtonActions(); } if (ControlManager.IsMouseMoving()) { cursorIndex = i; } continue; } if (!menuOptions[i, 1].Equals("")) { if (ControlManager.IsMouseOverText(menuOptionFont, menuOptions[i, 1], new Vector2(Game1.ScreenSize.X - 150 + game.fontManager.GetFont(14).MeasureString(menuOptions[i, 1]).X / 2, Game1.ScreenSize.Y / 3 + (i * 23) + yOffset) + fontOffset)) { if (cursorIndex != i) { PlayHoverSound(); } if (ControlManager.IsLeftMouseButtonClicked()) { ButtonActions(); } if (ControlManager.IsMouseMoving()) { cursorIndex = i; } } } } for (int i = 0; i < directionalButtons.Count; i++) { Rectangle dirButtonRect = new Rectangle( (int)directionalButtons[i].Position.X - directionalButtons[i].Passive.SourceRectangle.Value.Width / 2, (int)directionalButtons[i].Position.Y - directionalButtons[i].Passive.SourceRectangle.Value.Height / 2, directionalButtons[i].Passive.SourceRectangle.Value.Width + 10, directionalButtons[i].Passive.SourceRectangle.Value.Height); if (ControlManager.IsMouseOverArea(dirButtonRect) && ControlManager.IsLeftMouseButtonClicked()) { DirectionalButtonActions(directionalButtons[i].name); } } }