• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Piece类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Piece的典型用法代码示例。如果您正苦于以下问题:C# Piece类的具体用法?C# Piece怎么用?C# Piece使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Piece类属于命名空间,在下文中一共展示了Piece类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: SanityCheck_GivenInsaneDataDueToWrongNumberOfBlackAndWhiteSquares_ReturnsFalse

        public void SanityCheck_GivenInsaneDataDueToWrongNumberOfBlackAndWhiteSquares_ReturnsFalse()
        {
            // Arrange
            var board = new Board(TestBoardSize);
            var solver = new Solver();
            var bogusPieceD = new Piece(
                new[]
                    {
                        //  B
                        //  W
                        // WW
                        new Square(0, 0, Colour.White),
                        new Square(1, 0, Colour.White),
                        new Square(1, 1, Colour.White),
                        new Square(1, 2, Colour.Black)
                    },
                'D');
            var pieceFeeder = new PieceFeeder(Piece.TestPieceA, Piece.TestPieceB, Piece.TestPieceC, bogusPieceD);

            // Act
            var actual = solver.SanityCheck(board, pieceFeeder);

            // Assert
            Assert.That(actual, Is.False);
        }
开发者ID:taylorjg,项目名称:DraughtBoardPuzzle,代码行数:25,代码来源:SolverTests.cs


示例2: TestExplosions

        public void TestExplosions()
        {
            Piece[][] board = new Piece[8][]
            {
                new Piece[8] { o, o, o, o, kb, o, o, o },
                new Piece[8] { o, o, o, o, o, o, o, o },
                new Piece[8] { o, o, o, o, o, o, o, o },
                new Piece[8] { o, o, o, pw, qb, o, o, o },
                new Piece[8] { o, o, o, bw, pb, o, o, o },
                new Piece[8] { o, o, o, o, o, o, nw, o },
                new Piece[8] { o, o, o, o, o, o, o, o },
                new Piece[8] { o, o, o, o, kw, o, o, o }
            };

            AtomicChessGame game = new AtomicChessGame(board, Player.White);
            Assert.AreEqual(game.ApplyMove(new Move("G3", "E4", Player.White), true), MoveType.Move | MoveType.Capture);

            Piece[][] expected = new Piece[8][]
            {
                new Piece[8] { o, o, o, o, kb, o, o, o },
                new Piece[8] { o, o, o, o, o, o, o, o },
                new Piece[8] { o, o, o, o, o, o, o, o },
                new Piece[8] { o, o, o, pw, o, o, o, o },
                new Piece[8] { o, o, o, o, o, o, o, o },
                new Piece[8] { o, o, o, o, o, o, o, o },
                new Piece[8] { o, o, o, o, o, o, o, o },
                new Piece[8] { o, o, o, o, kw, o, o, o }
            };
            Piece[][] actual = game.GetBoard();
            Assert.AreEqual(expected, actual);
        }
开发者ID:ProgramFOX,项目名称:Chess.NET,代码行数:31,代码来源:AtomicChessGameTests.cs


示例3: Start

 void Start()
 {
     piece = gameObject.GetComponent<Piece>();
     piece.moveDirections = directions;
     piece.isRepetitive = false;
     piece.isKing = true;
 }
开发者ID:DanteX95X,项目名称:Chess,代码行数:7,代码来源:King.cs


示例4: BoardPosition

 /// <summary>
 /// Storage class for row and column, does not restric the value of the input,
 /// expects consuming class to validate appropriate row/column value
 /// </summary>
 /// <param name="row"></param>
 /// <param name="column"></param>
 /// <param name="piece"></param>
 public BoardPosition(int row, int column, Piece piece)
 {
     this.Row = row;
     this.Column = column;
     this.Piece = piece;
     this.Piece.SetPosition(this.Row, this.Column);
 }
开发者ID:chadqueen,项目名称:QueensDuel,代码行数:14,代码来源:BoardPosition.cs


示例5: HordeChessGame

 public HordeChessGame() : base()
 {
     WhoseTurn = Player.White;
     Moves = new ReadOnlyCollection<DetailedMove>(new List<DetailedMove>());
     Board = new Piece[8][];
     Piece kb = FenMappings['k'];
     Piece qb = FenMappings['q'];
     Piece rb = FenMappings['r'];
     Piece nb = FenMappings['n'];
     Piece bb = FenMappings['b'];
     Piece pw = FenMappings['P'];
     Piece pb = FenMappings['p'];
     Piece o = null;
     Board = new Piece[8][]
     {
         new[] { rb, nb, bb, qb, kb, bb, nb, rb },
         new[] { pb, pb, pb, pb, pb, pb, pb, pb },
         new[] { o, o, o, o, o, o, o, o },
         new[] { o, pw, pw, o, o, pw, pw, o },
         new[] { pw, pw, pw, pw, pw, pw, pw, pw },
         new[] { pw, pw, pw, pw, pw, pw, pw, pw },
         new[] { pw, pw, pw, pw, pw, pw, pw, pw },
         new[] { pw, pw, pw, pw, pw, pw, pw, pw }
     };
     CanBlackCastleKingSide = CanBlackCastleQueenSide = CastlingCanBeLegal;
     CanWhiteCastleKingSide = CanWhiteCastleQueenSide = false;
 }
开发者ID:ProgramFOX,项目名称:Chess.NET,代码行数:27,代码来源:HordeChessGame.cs


示例6: CreateRandomPieceAtStartPoint

 private void CreateRandomPieceAtStartPoint()
 {
     int randomType = UnityEngine.Random.Range(0, PieceTypes.Count);
     switch (randomType)
     {
         case 0:
             PlayerControlledPiece = Piece.Create<Bar>();
             break;
         case 1:
             PlayerControlledPiece = Piece.Create<InverseL>();
             break;
         case 2:
             PlayerControlledPiece = Piece.Create<L>();
             break;
         case 3:
             PlayerControlledPiece = Piece.Create<S>();
             break;
         case 4:
             PlayerControlledPiece = Piece.Create<Square>();
             break;
         case 5:
             PlayerControlledPiece = Piece.Create<Tri>();
             break;
         case 6:
             PlayerControlledPiece = Piece.Create<Z>();
             break;
     }
 }
开发者ID:AleClo,项目名称:Tetreski,代码行数:28,代码来源:GameManager.cs


示例7: Move

 public Move(Position originalPosition, Position newPosition, Player player, Piece promotion)
 {
     OriginalPosition = originalPosition;
     NewPosition = newPosition;
     Player = player;
     Promotion = promotion;
 }
开发者ID:gunr2171,项目名称:Chess.NET,代码行数:7,代码来源:Move.cs


示例8: addPiece

 public static void addPiece(Piece [] pieces)
 {
     foreach (Piece p in pieces)
     {
         positions.Add(p);
     }
 }
开发者ID:schafer14,项目名称:ChessC,代码行数:7,代码来源:State.cs


示例9: CheckTileHeightDiffFromOutsidePlayerZone

    public bool CheckTileHeightDiffFromOutsidePlayerZone(Piece selectedPiece,int numPlayers)
    {
        if(numPlayers <=2 ){
            if(selectedPiece.tile.posOnBoard == 2 || selectedPiece.tile.posOnBoard == 7)
            {
                diff1 = Math.Abs(selectedPiece.tile.tileHeight - (this.tiles[0].tileHeight));
                return (diff1 < 3);
            }

            else if(selectedPiece.tile.posOnBoard == 1)
            {
                diff1 = Math.Abs(selectedPiece.tile.tileHeight - (this.tiles[1].tileHeight));
                diff2 = Math.Abs(selectedPiece.tile.tileHeight - this.tiles[6].tileHeight);
                diff3 = Math.Abs(selectedPiece.tile.tileHeight - this.tiles[36].tileHeight);
                return (diff1 < 3 && diff2 < 3 && diff3 < 3);
            }
            else if(selectedPiece.tile.posOnBoard == 37){
                diff1 = Math.Abs(selectedPiece.tile.tileHeight - (this.tiles[0].tileHeight));
                return (diff1 < 3);
            }
            else{
                return true;
            }

        }
        return true;
    }
开发者ID:jmoraltu,项目名称:KatoizApp,代码行数:27,代码来源:GameBoard.cs


示例10: DetachPiece

	public void DetachPiece(){
		if (attachedPiece!=null){
			attachedPiece.transform.parent = null;
			attachedPiece = null;
			state = TileState.empty;
		}
	}
开发者ID:spladityapramanta,项目名称:spladityapramanta.github.io,代码行数:7,代码来源:Tile.cs


示例11: startTurn

  public bool startTurn()
  {
    iteration++;
    int count = 0;
    count = Client.getMoveCount(connection);
    moves = new Move[count];
    for(int i = 0; i < count; i++)
    {
      moves[i] = new Move(Client.getMove(connection, i));
    }
    count = Client.getPieceCount(connection);
    pieces = new Piece[count];
    for(int i = 0; i < count; i++)
    {
      pieces[i] = new Piece(Client.getPiece(connection, i));
    }
    count = Client.getPlayerCount(connection);
    players = new Player[count];
    for(int i = 0; i < count; i++)
    {
      players[i] = new Player(Client.getPlayer(connection, i));
    }

    if(!initialized)
    {
      initialized = true;
      init();
    }
    return run();
  }
开发者ID:siggame,项目名称:chess,代码行数:30,代码来源:BaseAI.CS


示例12: Reset

	public void Reset(){
		state = TileState.empty;
		if(attachedPiece!=null){
			attachedPiece.Fall(attachedPiece.transform.position.normalized * 4 + new Vector3(0,8,0));
			attachedPiece=null;
		}
	}
开发者ID:spladityapramanta,项目名称:spladityapramanta.github.io,代码行数:7,代码来源:Tile.cs


示例13: GetPieces

        //returns a list of pieces on the current opening
        public static Pieces GetPieces(int pageNumber)
        {
            var pieces = new Pieces();
            try
            {
                //gets the xelements representing the two pages of the opening (e.g. 1r, 2v)
                XElement root = SurfaceWindow1.xOldFr.Root;
                string verso = "#" + (pageNumber-2).ToString() + "v";
                string recto = "#" + (pageNumber-1).ToString() + "r";
                IEnumerable<XElement> pages =
                    from el in root.Descendants("pb")
                    where ((string)el.Attribute("facs") ==  verso || el.Attribute("facs").Value == recto)
                    select el;
                //adds the pieces on each page to the pieceList
                foreach (XElement page in pages)
                {
                    //var foo = page.Attribute("facs");
                    IEnumerable<XElement> pieceElements =
                    from el in page.Elements("p")
                    select el; //.Attribute("id").Value;

                    foreach (XElement p in pieceElements)
                    {
                        var piece = new Piece(p);
                        pieces.Add(piece.ID,piece);
                    }
                }

            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }
            return pieces;
        }
开发者ID:straboulsi,项目名称:fauvel,代码行数:36,代码来源:Study.cs


示例14: Board

    public Board(int d)
    {
        PossibleMovesNum = 1;
        needsRefreshModel = false;
        AlphaBetaMaxDepth = Constants.MAXDEPTH;
        pieceMatrix = new List<List<Piece>>();
        CurrentTurn = 0;
        for (int i = 0; i < d; i++)
        {
            List<Piece> temp = new List<Piece>();
            for (int j = 0; j < d; j++)
            {
                Piece tempPiece = new Piece(new Vector2(i, j));
                temp.Add(tempPiece);
            }
            pieceMatrix.Add(temp);
        }

        StartingMoves = new List<Vector2>();
        StartingMoves.Add(new Vector2(1, 1));
        StartingMoves.Add(new Vector2(1, boardSize - 2));
        StartingMoves.Add(new Vector2(boardSize - 2, 1));
        StartingMoves.Add(new Vector2(boardSize - 2, boardSize - 2));
        StartingMoves.Add(new Vector2((boardSize - 1) / 2, (boardSize - 1) / 2));
    }
开发者ID:stuartsoft,项目名称:TinyGo,代码行数:25,代码来源:Board.cs


示例15: AnimateMovement

 private void AnimateMovement(Piece toMove,  float time)
 {
     //animate it
     //Lerp could also be used, but I prefer the MoveTowards approach :)
     toMove.GameObject.transform.position = Vector2.MoveTowards(toMove.GameObject.transform.position,
       screenPositionToAnimate , time * AnimSpeed);
 }
开发者ID:Fyrewell,项目名称:SlidePuzzleUnity,代码行数:7,代码来源:Game.cs


示例16: Print_GivenBoardContainingASinglePiece_PrintsRowDataCorrectly

        public void Print_GivenBoardContainingASinglePiece_PrintsRowDataCorrectly()
        {
            // Arrange
            var squares =
                new[]
                    {
                        // WBW
                        new Square(0, 0, Colour.White),
                        new Square(1, 0, Colour.Black),
                        new Square(2, 0, Colour.White)
                    };
            var piece = new Piece(squares, 'A');
            _board.PlacePieceAt(piece, 0, 0);

            var expectedLineForEmptyRow = CreateExpectedLineForEmptyRow();

            var expectedLastLine = "| Aw | Ab | Aw ";
            for (int i = 3; i < _board.BoardSize; i++) {
                expectedLastLine += "|";
                expectedLastLine += new string(' ', 4);
            }
            expectedLastLine += "|";

            // Act
            _boardPrinter.Print(_board);

            // Assert
            Assert.That(_mockPrintTarget.Lines, Has.Length.EqualTo(_expectedNumberOfOutputLines));

            Assert.That(_mockPrintTarget.Lines[1], Is.EqualTo(expectedLineForEmptyRow));
            Assert.That(_mockPrintTarget.Lines[3], Is.EqualTo(expectedLineForEmptyRow));
            Assert.That(_mockPrintTarget.Lines[5], Is.EqualTo(expectedLineForEmptyRow));
            Assert.That(_mockPrintTarget.Lines[7], Is.EqualTo(expectedLastLine));
        }
开发者ID:taylorjg,项目名称:DraughtBoardPuzzle,代码行数:34,代码来源:BoardPrinterTests.cs


示例17: Occupy

    public void Occupy(Piece piece)
    {
        occupied = true;
        currentPiece = piece;

        // TODO: set sprite based on type
    }
开发者ID:Spierek,项目名称:SpyChess,代码行数:7,代码来源:FieldScript.cs


示例18: Move

 public Move(Piece promoteTo, Coordinate from, Coordinate to)
 {
     m_moveType = MoveType.Promotion;
     m_promoteTo = promoteTo;
     m_from = from;
     m_to = to;
 }
开发者ID:Kashll,项目名称:Chess,代码行数:7,代码来源:Move.cs


示例19: Add

    public void Add(Piece piece, List<Piece> same)
    {
        //Debug.LogWarning ("History Add");
        //string kanji = piece.Kanji;
        //Vector2 pos = piece.Tile;

        if (max > 0)
            return;

        bool isFirst = piece.Owner.IsFirst;

        string addition = "";

        if (same != null) {
            if(same.Count == 1) {
                if(same[0].Tile.x < piece.Tile.x) {
                    addition += isFirst ? "左" : "右";
                }
                if(same[0].Tile.x > piece.Tile.x) {
                    addition += !isFirst ? "左" : "右";
                }
            }
        }

        HistoryInfo info = new HistoryInfo (index++, piece, addition);
        //HistoryInfo info = new HistoryInfo (index++, kanji, pos, isFirst, addition);
        moves.Add (info);
    }
开发者ID:clear10,项目名称:OnlineShogi,代码行数:28,代码来源:History.cs


示例20: DetailedMove

 public DetailedMove(Position originalPosition, Position newPosition, Player player, char? promotion, Piece piece, bool isCapture, CastlingType castling) : 
     base(originalPosition, newPosition, player, promotion)
 {
     Piece = piece;
     IsCapture = isCapture;
     Castling = castling;
 }
开发者ID:ProgramFOX,项目名称:Chess.NET,代码行数:7,代码来源:DetailedMove.cs



注:本文中的Piece类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# PieceColor类代码示例发布时间:2022-05-24
下一篇:
C# PictureType类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap