本文整理汇总了C#中IFigure类的典型用法代码示例。如果您正苦于以下问题:C# IFigure类的具体用法?C# IFigure怎么用?C# IFigure使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IFigure类属于命名空间,在下文中一共展示了IFigure类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RemoveFigure
public void RemoveFigure(IFigure figure)
{
ObjectValidator.CheckIfObjectIsNull(figure, GlobalErrorMessages.NullFigureErrorMessage);
this.CheckIfFigureDoesNotExists(figure);
this.figures.Remove(figure);
}
示例2: ActionWithFigure
public ActionWithFigure(IFigure figure, ActionWithTwoParams action, double param1, double param2)
{
FigureToAction = figure;
twoParamsAction = action;
this.param1 = param1;
this.param2 = param2;
}
示例3: ResolveMoveDown
private CollisionType ResolveMoveDown(IFigure figure)
{
var collision = CollisionType.None;
figure.ForEachNonEmptyCell((i, j) =>
{
var absoluteX = figure.Placement.Left + i;
var absoluteY = figure.Placement.Top + j;
if (absoluteY > _gameField.Size.Height - 1)
{
collision = CollisionType.Ground;
return false;
}
if (absoluteY < 0)
return true;
if (_gameField.GroundView[absoluteX, absoluteY].IsEmptyCell())
return true;
collision = CollisionType.Ground;
if (figure.Placement.Top == 1) // a little bad assumpotion that figures always start at 0, and thatn moves down by 1
collision = CollisionType.Critical;
return false;
});
return collision;
}
示例4: VlidateMove
public void VlidateMove(IFigure figure, IBoard board, Move move)
{
Position from = move.From;
Position to = move.To;
if (from.Row != to.Row && from.Col != to.Col)
{
throw new InvalidOperationException("Rook cannot move this way!");
}
if (to.Col > from.Col)
{
this.RightChecker(board, from, to);
return;
}
else if (to.Col < from.Col)
{
this.LeftChecker(board, from, to);
return;
}
else if (to.Row > from.Row)
{
this.TopChecker(board, from, to);
return;
}
else if (to.Row < from.Row)
{
this.DownChecker(board, from, to);
return;
}
else
{
throw new InvalidOperationException("Rook cannot move this way!");
}
}
示例5: ModifyFillBrushIfSelected
public static Brush ModifyFillBrushIfSelected(IFigure figure, Brush brush, FigureStyle style)
{
// Below is my suggestion for the fill appearance when a shape is selected. - David
var brushAsSolidColor = brush as SolidColorBrush;
if (figure != null && figure.Selected && !(style is PointStyle) && brushAsSolidColor != null)
{
// brush.Opacity = 0.2; // The previous method of showing a figure is selected.
// The color of the stripes in the gradient is made by shifting the Fill color toward a gray value.
var b = new LinearGradientBrush();
var shapeWidth = 200; // Arbitrary value. Using the with of the figure would be better.
b.StartPoint = new Point(0.0, 0.0);
b.EndPoint = new Point(1.0, 0.0);
double gap = 6; // Actually half the gap between stripes in physical coordinates.
double s = gap / shapeWidth;
byte gray = 200; // The gray value to shift the Fill color toward.
double similarity = .65; // How similar are the Fill color and the gray value (1 = similar, 0 = not).
byte alpha = ((int)brushAsSolidColor.Color.A < 128) ? (byte)128 : brushAsSolidColor.Color.A; // We need some opacity.
for (double i = 0; i + s + s < 1; i += 2 * s)
{
b.GradientStops.Add(new GradientStop() { Color = brushAsSolidColor.Color, Offset = i + .7 * s });
b.GradientStops.Add(new GradientStop()
{
Color = Color.FromArgb(alpha, (byte)(gray + (brushAsSolidColor.Color.R - gray) * similarity),
(byte)(gray + (brushAsSolidColor.Color.G - gray) * similarity),
(byte)(gray + (brushAsSolidColor.Color.B - gray) * similarity)),
Offset = i + s
});
b.GradientStops.Add(new GradientStop() { Color = brushAsSolidColor.Color, Offset = i + s + .3 * s });
}
brush = b;
}
// End of suggestion.
return brush;
}
示例6: WriteInput
void WriteInput(IFigure input, XmlWriter writer)
{
writer.WriteStartElement("Input");
writer.WriteAttributeString("Name", input.Name);
writer.WriteAttributeString("Type", GetInputType(input));
writer.WriteEndElement();
}
示例7: AddFigure
public void AddFigure(IFigure figure, IPosition position)
{
Validator.CheckIfObjectIsNull(figure, GlobalErrorMessages.NullFigureErrorMessage);
Validator.CheckIfPositionValid(position, GlobalErrorMessages.PositionNotValidMessage);
this.board[position.Row, position.Col] = figure;
this.figurePositionsOnBoard[figure.DisplayName] = position;
}
示例8: EvaluateNextMove
public CollisionType EvaluateNextMove(MoveType move, IFigure figure)
{
var collision = CollisionType.None;
IFigure movedFigure;
switch (move)
{
case MoveType.RowAdded:
collision = ResolveRowAdded();
break;
case MoveType.MoveRight:
movedFigure = figure.MoveRight();
collision = ResolveMoveRight(movedFigure);
break;
case MoveType.MoveLeft:
movedFigure = figure.MoveLeft();
collision = ResolveMoveLeft(movedFigure);
break;
case MoveType.MoveDown:
movedFigure = figure.MoveDown();
collision = ResolveMoveDown(movedFigure);
break;
case MoveType.TossDown:
// for now do nothing
break;
case MoveType.Rotate:
var rotatedFigure = figure.RotateClockwise();
collision = ResolveRotate(rotatedFigure);
break;
default:
throw new NotImplementedException("unknown movement type: " + move);
}
return collision;
}
示例9: CanTearOff
private static bool CanTearOff(IFigure figure)
{
if (figure is ParallelLine)
{
return true;
}
foreach (var dependency in figure.Dependencies)
{
var dependencyPoint = dependency as IPoint;
if (dependencyPoint == null)
{
// for now, can't tear off a figure
// that has a non-point dependency (such as a ParallelLine)
return false;
}
if (dependencyPoint is FreePoint)
{
// no need to tear-off from an already free point
// since no one else uses this point
if (dependencyPoint.Dependents.Count == 1) continue;
if (dependencyPoint.Dependents.Count == 2 && dependencyPoint.Dependents.OfType<LabelBase>().Count() > 0) continue;
}
return true;
}
return false;
}
示例10: VlidateMove
// TODO: Castling checking
public void VlidateMove(IFigure figure, IBoard board, Move move)
{
Position from = move.From;
Position to = move.To;
bool condition = (
((from.Col + 1) == to.Col) ||
((from.Col - 1) == to.Col) ||
((from.Row + 1) == to.Row) ||
((from.Row - 1) == to.Row) ||
(((from.Row + 1) == to.Row) && ((from.Col + 1) == to.Col)) ||
(((from.Row - 1) == to.Row) && ((from.Col + 1) == to.Col)) ||
(((from.Row - 1) == to.Row) && ((from.Col - 1) == to.Col)) ||
(((from.Row + 1) == to.Row) && ((from.Col - 1) == to.Col))
);
if (condition)
{
return;
}
else
{
throw new InvalidOperationException("King cannot move this way!");
}
}
示例11: AddFoundDependency
protected override void AddFoundDependency(IFigure figure)
{
if (figure != null)
{
FoundDependencies.Add(figure);
}
}
示例12: ButtonHandle
public ButtonHandle(IFigure owner, ILocator locator, kindButton type)
: base(owner)
{
_locator = locator;
_clicked = false;
typeButton = type;
}
示例13: AddFoundDependency
protected virtual void AddFoundDependency(IFigure figure)
{
if (ExpectedDependency.IsAssignableFrom(figure.GetType()))
{
FoundDependencies.Add(figure);
}
}
示例14: ValidateMove
public virtual void ValidateMove(IFigure figure, IBoard board, Move move)
{
if (figure.IsFirstMove)
{
figure.IsFirstMove = false;
}
}
示例15: CheckIfFigureExists
private void CheckIfFigureExists(IFigure figure)
{
if (this.figures.Contains(figure))
{
throw new InvalidOperationException("This player already owns this figure!");
}
}