本文整理汇总了C#中Square类的典型用法代码示例。如果您正苦于以下问题:C# Square类的具体用法?C# Square怎么用?C# Square使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Square类属于命名空间,在下文中一共展示了Square类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: moveToDest
/**
* Set piece to move to specified square
* TODO: make it an arc instead of teleport
*/
public override void moveToDest(Square s)
{
tile.Occupant = null;
s.Occupant = this;
this.tile = s;
((Transform)this.GetComponent (typeof(Transform))).localPosition = s.Position;
}
开发者ID:pcbennion,项目名称:unity-chess,代码行数:11,代码来源:King.cs
示例2: Render
/// <summary>
/// Renders a single square on the given graphics context on the specified
/// rectangle.
///
/// <param name="square">The square to render.</param>
/// <param name="g">The graphics context to draw on.</param>
/// <param name="r">The position and dimension for rendering the square.</param>
// tag::render[]
private void Render(Square square, Graphics g, Rectangle r) {
Point position = r.Position;
square.Sprite.Draw(g, r);
foreach (Unit unit in square.Occupants) {
unit.Sprite.Draw(g, r);
}
}
开发者ID:ishara,项目名称:building_maintainable_software,代码行数:15,代码来源:BoardPanel.cs
示例3: MovePiece
public void MovePiece(Square startingSquare, Square destinationSquare)
{
if (IsOutOfBounds(startingSquare, destinationSquare))
{
PlayerMessage = "Illegal Move";
return;
}
var piece = _pieceLocations[startingSquare];
var otherPiece = _pieceLocations[destinationSquare];
if (otherPiece != null && !IsCapture(piece,otherPiece))
{
PlayerMessage = "Illegal Move";
return;
}
if (piece.IsValidMove(startingSquare, destinationSquare, IsCapture(piece, otherPiece)))
{
_pieceLocations[startingSquare] = null;
this.PlayerMessage = string.Format("{0} to {1}", piece.Name, destinationSquare);
if(IsCapture(piece, otherPiece))
this.PlayerMessage += string.Format(". {0} takes {1}", piece.Name, otherPiece.Name);
_pieceLocations[destinationSquare] = piece;
}
else
PlayerMessage = "Illegal Move";
}
开发者ID:Kirschstein,项目名称:-JohnnoNolan-s-Chess-Kata,代码行数:31,代码来源:ChessBoard.cs
示例4: MainForm
public MainForm()
{
InitializeComponent();
controller = new Controller(this);
int panelWidth = this.MainBoard.Width;
int squareMargin = 10;
int width = panelWidth / 4;
int size = 150;
blocks = new Square[4, 4];
for (int i = 0; i < 4; i++)
{
for (int j = 0; j < 4; j++)
{
Square block = new Square();
blocks[i, j] = block;
block.Left = j * size;
block.Top = i * size;
block.Width = size;
block.Height = size;
block.Visible = true;
block.BackColor = Color.FromArgb(0, 100, 100, 100);
block.Margin = new Padding(squareMargin);
MainBoard.Controls.Add(block);
}
}
}
开发者ID:huzi96,项目名称:Game0,代码行数:27,代码来源:Form.cs
示例5: GetAvailableMove
/// <summary>
/// <paramref name="srcSquare"/>の駒を<paramref name="dstSquare"/>
/// に動かすことが可能な指し手をすべて列挙します。
/// </summary>
private IEnumerable<BoardMove> GetAvailableMove(BWType bwType,
Square srcSquare,
Square dstSquare)
{
var piece = this[srcSquare];
if (piece == null || piece.BWType != bwType)
{
yield break;
}
var move = new BoardMove()
{
DstSquare = dstSquare,
SrcSquare = srcSquare,
MovePiece = piece.Piece,
BWType = bwType,
};
// 成り駒でなければ、成る可能性があります。
if (!piece.IsPromoted)
{
move.IsPromote = true;
if (CanMove(move, MoveFlags.CheckOnly))
{
// yield returnなのでCloneしないとまずい。
yield return move.Clone();
}
}
move.IsPromote = false;
if (CanMove(move, MoveFlags.CheckOnly))
{
yield return move;
}
}
开发者ID:JuroGandalf,项目名称:Ragnarok,代码行数:39,代码来源:Board.mate.cs
示例6: OnUpdate
public override void OnUpdate(long msec)
{
var tanks = from node in World.Downwards
where node.Name == "MyTank" || node.Name == "EnemyTank"
select node;
foreach (var cmp in points.Components) {
points.Detach (cmp);
}
foreach (var tank in tanks) {
var spr = new Sprite (2, 2);
spr.Color = Color.Black;
spr.Offset = new Vector2 (tank.Translation.X / 10f,
tank.Translation.Y / 10f);
points.Attach (spr);
}
var cam = World.ActiveCamera;
var frame = new Square (80, 60, 2);
frame.Offset = new Vector3 (cam.Position.X / 10f,
cam.Position.Y / 10f,
cam.Position.Z / 10f);
points.Attach (frame);
}
开发者ID:weimingtom,项目名称:erica,代码行数:26,代码来源:MyRader.cs
示例7: Main
public static void Main()
{
Square square = new Square(0, 0, 10);
Rectangle rect = new Rectangle(0, 0, 10, 12);
Circle circle = new Circle(0, 0, 5);
if (square is IShape)
{
Console.WriteLine("{0} is IShape", square.GetType());
}
if (rect is IResizable)
{
Console.WriteLine("{0} is IResizable", rect.GetType());
}
if (circle is IResizable)
{
Console.WriteLine("{0} is IResizable", circle.GetType());
}
IShape[] shapes = { square, rect, circle };
foreach (IShape shape in shapes)
{
shape.SetPosition(5, 5);
Console.WriteLine(
"Type: {0}; surface: {1}",
shape.GetType(),
shape.CalculateSurface());
}
}
开发者ID:SivaCse,项目名称:Object-Oriented-Programming,代码行数:32,代码来源:PlayWithInterfaces.cs
示例8: TriangulateSquare
void TriangulateSquare(Square square) {
switch (square.configuration) {
case 0:
break;
// 1 points:
case 1:
MeshFromPoints(square.centreBottom, square.bottomLeft, square.centreLeft);
break;
case 2:
MeshFromPoints(square.centreRight, square.bottomRight, square.centreBottom);
break;
case 4:
MeshFromPoints(square.centreTop, square.topRight, square.centreRight);
break;
case 8:
MeshFromPoints(square.topLeft, square.centreTop, square.centreLeft);
break;
// 2 points:
case 3:
MeshFromPoints(square.centreRight, square.bottomRight, square.bottomLeft, square.centreLeft);
break;
case 6:
MeshFromPoints(square.centreTop, square.topRight, square.bottomRight, square.centreBottom);
break;
case 9:
MeshFromPoints(square.topLeft, square.centreTop, square.centreBottom, square.bottomLeft);
break;
case 12:
MeshFromPoints(square.topLeft, square.topRight, square.centreRight, square.centreLeft);
break;
case 5:
MeshFromPoints(square.centreTop, square.topRight, square.centreRight, square.centreBottom, square.bottomLeft, square.centreLeft);
break;
case 10:
MeshFromPoints(square.topLeft, square.centreTop, square.centreRight, square.bottomRight, square.centreBottom, square.centreLeft);
break;
// 3 point:
case 7:
MeshFromPoints(square.centreTop, square.topRight, square.bottomRight, square.bottomLeft, square.centreLeft);
break;
case 11:
MeshFromPoints(square.topLeft, square.centreTop, square.centreRight, square.bottomRight, square.bottomLeft);
break;
case 13:
MeshFromPoints(square.topLeft, square.topRight, square.centreRight, square.centreBottom, square.bottomLeft);
break;
case 14:
MeshFromPoints(square.topLeft, square.topRight, square.bottomRight, square.centreBottom, square.centreLeft);
break;
// 4 point:
case 15:
MeshFromPoints(square.topLeft, square.topRight, square.bottomRight, square.bottomLeft);
break;
}
}
开发者ID:UIKit0,项目名称:Procedural-Cave-Generation,代码行数:60,代码来源:MeshGenerator.cs
示例9: Move
public override void Move(Square origin, Square destination)
{
base.Move(origin, destination);
HandleKingsideCastling(origin, destination);
HandleQueensideCastling(origin, destination);
}
开发者ID:sgtStark,项目名称:ChessEngine,代码行数:7,代码来源:KingMovingStrategy.cs
示例10: DestinationIsAttacked
private bool DestinationIsAttacked(Square destination)
{
var currentPosition = Board.GetPosition();
return currentPosition.SquaresOccupiedByPiecesWith(Color.GetOppositeColor())
.Any(opponentSquare => opponentSquare.Occupier.Attacks(opponentSquare, destination));
}
开发者ID:sgtStark,项目名称:ChessEngine,代码行数:7,代码来源:King.cs
示例11: getChild
private Tuple<MoveNode, double> getChild(Square square)
{
instances++;
MoveNode node = new MoveNode(board, square, evaluator);
if (square.number == 2) return Tuple.Create(node, 0.9);
else return Tuple.Create(node, 0.1);
}
开发者ID:Temnov999,项目名称:2048bot,代码行数:7,代码来源:AppearNode.cs
示例12: setupBoard
void setupBoard() {
colors[0] = Color.Green;
colors[1] = Color.Pink;
colors[2] = Color.Purple;
colors[3] = Color.SpringGreen;
colors[4] = Color.Red;
colors[5] = Color.Yellow;
Random rnd = new Random();
for (int x = 0; x < 14; ++x) {
for (int y = 0; y < 14; ++y) {
Square s = new Square();
s.c = colors[rnd.Next(0,6)];
s.x = x;
s.y = y;
s.xPos = x * GridSize + GridPosX;
s.yPos = y * GridSize + GridPosY;
board[x, y] = s;
}
}
root = board[0, 0];
root.root = true;
root.rank = 99;
for (int x = 0; x < 14; ++x) {
for (int y = 0; y < 14; ++y) {
Square s = board[x, y];
if (x > 0) s.left = board[x - 1, y];
if (x < 13) s.right = board[x + 1, y];
if (y > 0) s.up = board[x, y - 1];
if (y < 13) s.down = board[x, y + 1];
}
}
}
开发者ID:DocSohl,项目名称:DrenchAI,代码行数:32,代码来源:VisualDisplay.cs
示例13: SquareAt
public Square SquareAt(int x, int y)
{
switch (Orientation)
{
case Orientation.North:
return Piece.SquareAt(x, y);
case Orientation.South:
{
var square = Piece.SquareAt(Width - x - 1, Height - y - 1);
if (square != null)
square = new Square(x, y, square.Colour);
return square;
}
case Orientation.East:
{
var square = Piece.SquareAt(Height - y - 1, x);
if (square != null)
square = new Square(x, y, square.Colour);
return square;
}
case Orientation.West:
{
var square = Piece.SquareAt(y, Width - x - 1);
if (square != null)
square = new Square(x, y, square.Colour);
return square;
}
default:
return null;
}
}
开发者ID:taylorjg,项目名称:DraughtBoardPuzzle,代码行数:35,代码来源:RotatedPiece.cs
示例14: moveTo
public override bool moveTo(Square s)
{
if (s != null)
{
if (s.isWalkable())
{
if (s.mayContainBarricade())
{
if (s.isOccupied())
{
return false;
}
else
{
s.Piece = this;
Square = s;
Player.Baricade = null;
Player = null;
return true;
}
}
}
}
return false;
}
开发者ID:spboom,项目名称:Baricade,代码行数:25,代码来源:BaricadePiece.cs
示例15: Attacking
private bool Attacking(Square origin, Square destination)
{
return (origin.Color != destination.Color
&& destination.Color != PieceColor.Empty
&& origin.DistanceOfRanksIsOneTo(destination)
&& origin.DiagonallyForwardTo(destination));
}
开发者ID:sgtStark,项目名称:ChessEngine,代码行数:7,代码来源:Pawn.cs
示例16: calculateIndexOfNeighbor
public int calculateIndexOfNeighbor(Square square, String orientation)
{
int index = square.getIndex();
Dictionary<string, bool> neighboorBools = square.getNeighborInformation();
if (orientation == "north")
{
return (index - width);
}
else if (orientation == "south")
{
return (index + width);
}
else if (orientation == "east")
{
return (index + 1);
}
else if (orientation == "west")
{
return (index - 1);
}
return index;
}
开发者ID:atadjiki,项目名称:Underworld2171,代码行数:25,代码来源:GameBoard.cs
示例17: createSquareList
public static SquareList createSquareList(SquareList simpleList)
{
SquareList newList = new SquareList();
for (int i = simpleList.Count() - 1; i >= 0; i--)
{
Square cat = simpleList.Get(i);
Square square = new Square(SurfaceWindow1.treeArea * cat.Ratio, cat.Name);
square.setBackGround(cat.BackGroundColor);
if (cat.TextColor == null)
square.setTextColor(Colors.Black);
else
square.setTextColor(cat.TextColor);
square.Ratio = cat.Ratio;
if (cat.SubFile != null && !cat.SubFile.Equals(""))
{
square.SubFile = cat.SubFile;
}
if (cat.Explanation != null && !cat.Explanation.Equals(""))
{
square.Explanation = cat.Explanation;
}
if (cat.VideoString != null && !cat.VideoString.Equals(""))
{
square.VideoString = cat.VideoString;
}
if(cat.ImageString !=null && !cat.ImageString.Equals("")){
square.ImageString = cat.ImageString;
}
newList.Add(square);
}
return newList;
}
开发者ID:RiedigerD2,项目名称:OpenHouse,代码行数:34,代码来源:SquareList.cs
示例18: calculateIndexOfNeighbors
//nsew
public Dictionary<string, int> calculateIndexOfNeighbors(Square square)
{
int index = square.getIndex();
Dictionary<string, int> neighborIndexes = new Dictionary<string,int>();
Dictionary<string, bool> neighboorBools = square.getNeighborInformation();
if(neighboorBools["north"] == true)
{
neighborIndexes.Add("n", index - width);
}
if (neighboorBools["south"] == true)
{
neighborIndexes.Add("s", index + width);
}
if (neighboorBools["east"] == true)
{
neighborIndexes.Add("e", index + 1);
}
if (neighboorBools["west"] == true)
{
neighborIndexes.Add("w", index - 1);
}
return neighborIndexes;
}
开发者ID:atadjiki,项目名称:Underworld2171,代码行数:26,代码来源:GameBoard.cs
示例19: SquareGrid
public SquareGrid(int[,] map, float squareSize)
{
int nodeCountX = map.GetLength(0);
int nodeCountY = map.GetLength(1);
float mapWidth = nodeCountX * squareSize;
float mapHeight = nodeCountY * squareSize;
ControlNode[,] controlNodes = new ControlNode[nodeCountX, nodeCountY];
for (int x = 0; x < nodeCountX; x++)
{
for (int y = 0; y < nodeCountY; y++)
{
Vector3 pos = new Vector3(-mapWidth / 2 + x * squareSize + squareSize / 2, 0, -mapHeight / 2 + y * squareSize + squareSize / 2);
controlNodes[x, y] = new ControlNode(pos, map[x, y] == 1, squareSize);
}
}
Squares = new Square[nodeCountX - 1, nodeCountY - 1];
for (int x = 0; x < nodeCountX - 1; x++)
{
for (int y = 0; y < nodeCountY - 1; y++)
{
Squares[x, y] = new Square(controlNodes[x, y + 1], controlNodes[x + 1, y + 1], controlNodes[x + 1, y], controlNodes[x, y]);
}
}
}
开发者ID:sasoh,项目名称:JanusRacer,代码行数:27,代码来源:MeshGeneratorScript.cs
示例20: IsLegalMove
public override bool IsLegalMove(Square origin, Square destination)
{
if (origin.Color == destination.Color) return false;
if (origin.AlongFileOrRank(destination)) return true;
return origin.DiagonallyTo(destination);
}
开发者ID:sgtStark,项目名称:ChessEngine,代码行数:7,代码来源:Queen.cs
注:本文中的Square类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论