/// <summary> /// Constructor for rod action to be performed /// </summary> /// <param name="type">Current Rod Type</param> /// <param name="rotation">Rotational move to be performed (default is undefined)</param> /// <param name="linear">Linear move to be performed (default is undefined)</param> public RodAction(eRod type, eRotationalMove rotation = eRotationalMove.NA, eLinearMove linear = eLinearMove.NA) { _dcPosition = 0; RodType = type; Rotation = rotation; Linear = linear; }
/// <summary> /// Calculate actual linear movement (Y Axe) for current rod to perform /// Is based on desired linear move type /// </summary> /// <param name="rod">Current rod</param> /// <param name="respondingPlayer">Responding player in current rod (1 based index)</param> /// <param name="bfc">Ball Future coordinates</param> /// <param name="desiredLinearMove">Desired Linear Move Type</param> /// <returns>New rod coordinate to move to (Axe Y)</returns> protected int CalculateNewRodCoordinate(IRod rod, int respondingPlayer, BallCoordinates bfc, eLinearMove desiredLinearMove) { int pos; //Define actual desired rod coordinate to move to //NOTE: responding player might be undefined will be -1 switch (desiredLinearMove) { case eLinearMove.BALL_Y: return _helper.LocateRespondingPlayer(rod, bfc.Y, respondingPlayer); // return bfc.Y - _helper.CalculateCurrentPlayerYCoordinate(rod, _currentRodYCoordinate[rod.RodType], respondingPlayer); case eLinearMove.LEFT_BALL_DIAMETER: pos = rod.NearestPossibleDcPosition(_helper.LocateRespondingPlayer(rod, bfc.Y, respondingPlayer)); return pos + (-1) * 2 * BALL_RADIUS; case eLinearMove.RIGHT_BALL_DIAMETER: pos = rod.NearestPossibleDcPosition(_helper.LocateRespondingPlayer(rod, bfc.Y, respondingPlayer)); return pos + 2 * BALL_RADIUS; case eLinearMove.VECTOR_BASED: if (rod.Intersection.IsDefined) { int stopperPosition = _helper.LocateRespondingPlayer(rod, rod.Intersection.Y, respondingPlayer); return (IsBallNearTheRod(bfc, rod, stopperPosition)) ? stopperPosition : rod.State.DcPosition; } //return rod.IntersectionY - _helper.CalculateCurrentPlayerYCoordinate(rod, _currentRodYCoordinate[rod.RodType], respondingPlayer); return rod.State.DcPosition; //case eLinearMove.BEST_EFFORT: // return rod.BestEffort; default: return rod.State.DcPosition; } }
public RodAction(eRod type, eRotationalMove rotation, eLinearMove linear) { Type = type; Rotation = rotation; Linear = linear; }
/// <summary> /// Calculate actual linear movement (Y Axe) for current rod to perform /// Is based on desired linear move type /// </summary> /// <param name="rod">Current rod</param> /// <param name="respondingPlayer">Responding player in current rod (1 based index)</param> /// <param name="bfc">Ball Future coordinates</param> /// <param name="desiredLinearMove">Desired Linear Move Type</param> /// <returns>New rod coordinate to move to (Axe Y)</returns> protected int CalculateNewRodCoordinate(IRod rod, int respondingPlayer, BallCoordinates bfc, eLinearMove desiredLinearMove) { //Define actual desired rod coordinate to move to //NOTE: responding player might be undefined will be -1 switch (desiredLinearMove) { case eLinearMove.BALL_Y: return(_helper.LocateRespondingPlayer(rod, bfc.Y, respondingPlayer)); // return bfc.Y - _helper.CalculateCurrentPlayerYCoordinate(rod, _currentRodYCoordinate[rod.RodType], respondingPlayer); //case eLinearMove.LEFT_BALL_DIAMETER: // return (-1) * 2 * BALL_RADIUS; //case eLinearMove.RIGHT_BALL_DIAMETER: // return 2 * BALL_RADIUS; case eLinearMove.VECTOR_BASED: if (rod.Intersection.IsDefined) { int stopperPosition = _helper.LocateRespondingPlayer(rod, rod.Intersection.Y, respondingPlayer); return((IsBallNearTheRod(bfc, rod, stopperPosition)) ? stopperPosition : rod.State.DcPosition); } //return rod.IntersectionY - _helper.CalculateCurrentPlayerYCoordinate(rod, _currentRodYCoordinate[rod.RodType], respondingPlayer); return(rod.State.DcPosition); //case eLinearMove.BEST_EFFORT: // return rod.BestEffort; default: return(rod.State.DcPosition); } }