public Navigator(Rotator rotator, MoveActions moveActions, Grid grid) { _rotator = rotator; _moveActions = moveActions; _grid = grid; CurrentPosition = new Position(0, 0); }
void OnMouseDown() { if (!GameObject.Find(Constants.PieceNames.ChessBoard).GetComponent <GameKeeper>().isSideControlledByAI(this.movingPiece.side)) { MoveActions.standardMoveActions(new Move(this.movingPiece, this.movePosition)); GameObject.Find(Constants.PieceNames.ChessBoard).GetComponent <GameKeeper>().ClearTiles(); } }
public PathNode(Int3 point, int pathLenghtFromStart, int heuristicEstimatePathLenght, MoveActions moveAction, PathNode cameFrom = null) { this.Position = point; this.GCost = pathLenghtFromStart; this.HCost = heuristicEstimatePathLenght; this.moveAction = moveAction; this.cameFromNode = cameFrom; }
public void PostAIComputation() { // Make sure this is done on the main thread // Since we've duplicated the chessboard, the piece associate with the move needs to be set to the actual game chessboard's instance this.isComputationDone = false; Move moveToMake = new Move(GameObject.Find(Constants.PieceNames.ChessBoard).GetComponent <GameKeeper>().chessBoard.GetPieceAtPosition(bestMove.getPiece().GetCurrentPosition()), bestMove.getPosition()); MoveActions.standardMoveActions(moveToMake); }
/// <summary> /// Handles the mouse movement. /// </summary> /// <param name="point">The point.</param> /// <param name="modifier">The modifier.</param> /// <returns></returns> public bool HandleMouseMotion( PointD point, ModifierType modifier) { // Mark ourselves as inside an action. InAction = true; try { // If we are in a text select, update the selection. if (inTextSelect && point.X >= displayContext.TextX) { // Figure out text-relative coordinates. var textPoint = new PointD(point.X - displayContext.TextX, point.Y); // Get the previous selection. TextRange previousSelection = displayContext.Caret.Selection; // Set the tail of the anchor to the current mouse position. displayContext.Caret.Selection = new TextRange( displayContext.Caret.Selection.FirstTextPosition, MoveActions.GetTextPosition(textPoint, this)); // Update the display. displayContext.Renderer.UpdateSelection(displayContext, previousSelection); displayContext.RequestRedraw(); // We processed this motion. return(true); } // We didn't process it, so return false. return(false); } finally { // Remove the action flag. InAction = false; } }
public void AdjustCurrentChoicesOrder(StandardFields field, MoveActions action) { UIUtil.DefaultProvider.WaitForDisplayAndClick(string.Format("//*[text()='{0}']", StringEnum.GetStringValue(field)), LocateBy.XPath); switch(action) { case MoveActions.Up: UIUtil.DefaultProvider.WaitForDisplayAndClick("moveItemUp", LocateBy.Id); break; case MoveActions.Down: UIUtil.DefaultProvider.WaitForDisplayAndClick("moveItemDown", LocateBy.Id); break; default: break; } }
/// <summary> /// Handles the mouse press and the associated code. /// </summary> /// <param name="point">The point.</param> /// <param name="button">The button.</param> /// <param name="modifier">The state.</param> /// <param name="eventType">The event type that triggered the press.</param> /// <returns>If handled, <see langword="true"/>. Otherwise, /// <see langword="false"/>.</returns> public bool HandleMousePress( PointD point, uint button, ModifierType modifier, EventType eventType) { // If we don't have a buffer, we don't do anything. if (displayContext.Renderer == null) { return(false); } // If we are pressing the left button (button 1) then we move the caret // over. If we are pressing the right button, we only change the position // if we don't already have a selection. if (button == 1 || (button == 3 && displayContext.Caret.Selection.IsEmpty)) { // Figure out if we are clicking inside the text area. if (point.X >= displayContext.TextX) { // Figure out text-relative coordinates. var textPoint = new PointD(point.X - displayContext.TextX, point.Y); // Grab the anchor position of the selection since that will // remain the same after the command. Caret caret = displayContext.Caret; TextRange previousSelection = caret.Selection; // Keep track of the selection so we can drag-select. if (button == 1) { inTextSelect = true; previousTextSelection = previousSelection; } // Mark that we are starting a new action and fire events so // other listeners and handle it. InAction = true; // Perform the appropriate action. try { switch (eventType) { case EventType.TwoButtonPress: MoveActions.SelectWord(this); break; case EventType.ThreeButtonPress: MoveActions.SelectLine(this); break; default: MoveActions.Point(this, textPoint); break; } } finally { InAction = false; } // If we are holding down the shift-key, then we want to // restore the previous selection anchor. if ((modifier & ModifierType.ShiftMask) == ModifierType.ShiftMask) { // Restore the anchor position which will extend the selection back. displayContext.Caret.Selection = new TextRange( previousSelection.FirstTextPosition, displayContext.Caret.Selection.LastTextPosition); // Check to see if the selection changed. if (previousSelection != displayContext.Caret.Selection) { displayContext.Renderer.UpdateSelection( displayContext, previousSelection); } } else if (!previousSelection.IsEmpty) { displayContext.Renderer.UpdateSelection(displayContext, previousSelection); } // Redraw the widget. displayContext.RequestRedraw(displayContext.Caret.GetDrawRegion()); } } // If we are pressing the right mouse, then show the context menu. if (button == 3) { // Create the context menu for this position. Menu contextMenu = CreateContextMenu(); // Attach the menu and show it to the user. if (contextMenu != null) { contextMenu.AttachToWidget((EditorView)displayContext, null); contextMenu.Popup(); contextMenu.ShowAll(); } } // We haven't handled it, so return false so the rest of Gtk can // decide what to do with the input. return(false); }