本文整理汇总了C#中IFigure类的典型用法代码示例。如果您正苦于以下问题:C# IFigure类的具体用法?C# IFigure怎么用?C# IFigure使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IFigure类属于命名空间,在下文中一共展示了IFigure类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: RemoveFigure
public void RemoveFigure(IFigure figure)
{
ObjectValidator.CheckIfObjectIsNull(figure, GlobalErrorMessages.NullFigureErrorMessage);
this.CheckIfFigureDoesNotExists(figure);
this.figures.Remove(figure);
}
开发者ID:King-Survival-3,项目名称:HQC-Teamwork-2015,代码行数:7,代码来源:Player.cs
示例2: ActionWithFigure
public ActionWithFigure(IFigure figure, ActionWithTwoParams action, double param1, double param2)
{
FigureToAction = figure;
twoParamsAction = action;
this.param1 = param1;
this.param2 = param2;
}
开发者ID:inkaaz,项目名称:My-C-training,代码行数:7,代码来源:ActionWithFigure.cs
示例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;
}
开发者ID:MarkiyanMatsekh,项目名称:MultiplayerTetris,代码行数:29,代码来源:CollisisonDetector.cs
示例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!");
}
}
开发者ID:totkov,项目名称:ChessGameEngine,代码行数:35,代码来源:NormalRookMovement.cs
示例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;
}
开发者ID:ondrej11,项目名称:o106,代码行数:35,代码来源:ShapeStyle.cs
示例6: WriteInput
void WriteInput(IFigure input, XmlWriter writer)
{
writer.WriteStartElement("Input");
writer.WriteAttributeString("Name", input.Name);
writer.WriteAttributeString("Type", GetInputType(input));
writer.WriteEndElement();
}
开发者ID:ondrej11,项目名称:o106,代码行数:7,代码来源:MacroSerializer.cs
示例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;
}
开发者ID:Fatme,项目名称:King-Survival-4,代码行数:7,代码来源:Board.cs
示例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;
}
开发者ID:MarkiyanMatsekh,项目名称:MultiplayerTetris,代码行数:34,代码来源:CollisisonDetector.cs
示例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;
}
开发者ID:wcatykid,项目名称:GeoShader,代码行数:30,代码来源:TearOff.cs
示例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!");
}
}
开发者ID:totkov,项目名称:ChessGameEngine,代码行数:26,代码来源:NormalKingMovement.cs
示例11: AddFoundDependency
protected override void AddFoundDependency(IFigure figure)
{
if (figure != null)
{
FoundDependencies.Add(figure);
}
}
开发者ID:ondrej11,项目名称:o106,代码行数:7,代码来源:ReflectionCreator.cs
示例12: ButtonHandle
public ButtonHandle(IFigure owner, ILocator locator, kindButton type)
: base(owner)
{
_locator = locator;
_clicked = false;
typeButton = type;
}
开发者ID:xiul,项目名称:Monodevelop-Database-Modeler-Addin,代码行数:7,代码来源:ButtonHandle.cs
示例13: AddFoundDependency
protected virtual void AddFoundDependency(IFigure figure)
{
if (ExpectedDependency.IsAssignableFrom(figure.GetType()))
{
FoundDependencies.Add(figure);
}
}
开发者ID:wcatykid,项目名称:GeoShader,代码行数:7,代码来源:FigureCreator.cs
示例14: ValidateMove
public virtual void ValidateMove(IFigure figure, IBoard board, Move move)
{
if (figure.IsFirstMove)
{
figure.IsFirstMove = false;
}
}
开发者ID:zhenyaracheva,项目名称:Chess,代码行数:7,代码来源:Movement.cs
示例15: CheckIfFigureExists
private void CheckIfFigureExists(IFigure figure)
{
if (this.figures.Contains(figure))
{
throw new InvalidOperationException("This player already owns this figure!");
}
}
开发者ID:totkov,项目名称:ChessGameEngine,代码行数:7,代码来源:Player.cs
示例16: CheckIfFigureDoesNotExists
private void CheckIfFigureDoesNotExists(IFigure figure)
{
if (!this.figures.Contains(figure))
{
throw new InvalidOperationException("This player does not own this figure!");
}
}
开发者ID:totkov,项目名称:ChessGameEngine,代码行数:7,代码来源:Player.cs
示例17: DelFigure
public void DelFigure(IFigure f)
{
ACommand command = new DelFigureCommand(figures, f);
command.Execute();
HandleAddCommand(command);
}
开发者ID:SokolovMS,项目名称:DesignPatterns,代码行数:7,代码来源:User.cs
示例18: AddFigure
/// <summary>
/// Add the specific figure at the specific position on the board
/// </summary>
/// <param name="figure">Figure to be added</param>
/// <param name="position">The position on which the figure should be added</param>
public void AddFigure(IFigure figure, IPosition position)
{
Validator.CheckIfObjectIsNull(figure);
Validator.CheckIfPositionValid(position);
this.board[position.Row, position.Col] = figure;
this.figurePositionsOnBoard[figure.DisplaySign] = position;
}
开发者ID:kskondov,项目名称:King-Survival-4,代码行数:12,代码来源:Board.cs
示例19: VisitFigure
public void VisitFigure (IFigure hostFigure) {
if (_addedFigures.Contains (hostFigure) == false
&& Drawing.Includes (hostFigure) == false) {
Drawing.Add (hostFigure);
_addedFigures.Add (hostFigure);
}
}
开发者ID:jira-sarec,项目名称:ICSE-2012-TraceLab,代码行数:7,代码来源:InsertIntoDrawingVisitor.cs
示例20: DependsOn
/// <summary>
/// Determines if figure directly or indirectly depends
/// on <paramref name="possibleDependency"/>
/// </summary>
/// <param name="figure">figure to check</param>
/// <param name="possibleDependency"></param>
/// <returns></returns>
public static bool DependsOn(this IFigure figure, IFigure possibleDependency)
{
// we consider that a figure depends on itself
if (figure == possibleDependency)
{
return true;
}
// quick rejection - if it doesn't depend on anything,
// it certainly doesn't depend on possibleDependency
if (figure.Dependencies.IsEmpty())
{
return false;
}
// first do the cheap pre-test without going deep
if (figure.DirectlyDependsOn(possibleDependency))
{
return true;
}
// if that failed, go deeper using recursion
foreach (var directDependency in figure.Dependencies)
{
if (directDependency.DependsOn(possibleDependency))
{
return true;
}
}
// depth-first search didn't find anything
return false;
}
开发者ID:ondrej11,项目名称:o106,代码行数:40,代码来源:IFigureExtensions.cs
注:本文中的IFigure类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论