4x4 Squares as the chessboard
16 cards are scrambled and put on a checkerboard.
The cards are divided into black and black two teams
Rules are like eating lions eat tiger eat leopard wolf eat Dog eat cat eat rat last mouse eat like a sibling eat two disappeared
The person who turns the first turn a card, turn to what color to use what color. The flip one can only use another color
The first one to open the first card to determine what color each side of the card
And then the second one, and then the first one starts taking the second step.
He could choose to continue the flop or hit the 4 cards around him with the cards he had opened.
Hit the end of which Zhang, if it is their own cards, complete this turn, if it is the other side of the card, according to the rules, who small who was killed. When you get a little hit, eat it, and then occupy his lattice.
Play to the end of the time, the chessboard has a space, then you can choose to go up or down one step or continue to hit the card
In the absence of other children in the middle of the case, the leopard can be free lateral vertical movement, the other pieces can only go up, down, left, right to move a lattice
According to the instructions he provided, a small software was made using WPF, in which the flop effect applied the effect provided by the Http://code.google.com/p/hackerzhou/downloads/detail?name=WPF_3D_Rotate.rar. The interface style uses the expert animation effect http://bbs.silverlightchina.net/forum.php?mod=viewthread&tid=14403
The main game screen is as follows:
Main code implementation:
1. Initialize the pawn:
Chesspiece relephant = new Chesspiece ("like", colors.red,7);
Listchess.add (relephant);
Chesspiece rlion = new Chesspiece ("Lion", colors.red,6);
Listchess.add (rlion);
Chesspiece Rtiger = new Chesspiece ("Tiger", colors.red,5);
Listchess.add (Rtiger);
2. Eating sub-rules:
<summary>
///pieces
///</summary>
///<param name= "Movepiece" ></param>
///<param name= "targetpiece" ></param>
///<returns></returns>
private bool Caneat (chesspiece movepiece,chesspiece targetpiece)
{
//each other eat the child must be different color
if (Movepiece.color!= Targetpiece.color)
{
if (movepiece.name = = "Mouse" && targetpiece.name = = "like")
{return
true;< c14/>}
Else if (movepiece.name = = "like" && targetpiece.name = = "Mouse")
{return
false;
}
else if (movepiece.index >= targetpiece.index)
{return
true;
}
return false;
}
return false;
}
3.
More Highlights: http://www.bianceng.cnhttp://www.bianceng.cn/Programming/net/
<summary>///to determine whether mobile///</summary>///<param name= "Chesspiece" ></param >///<param name= "Row" ></param>///<param name= "col" ></param>/// ;returns></returns> private bool Canmove (chesspiece chesspiece, int row, int col) {i
F (chesspiece.piecerow!= row && chesspiece.piececol!= col) {return false; else {if (Chesspiece.name = "Leopard") {for Each (chesspiece C in listchess) {//Move up the IF (selecte Dpiece.piecerow = row && selectedpiece.piececol > col && c.piecerow = = row
&& c.piececol > Col && c.piececol < Selectedpiece.piececol) { return FALSe ///Move Down else if (Selectedpiece.piecerow = = Row && selectedpiece. Piececol < col && c.piecerow = row && C.piececol < col && C.pie
Cecol > Selectedpiece.piececol) {return false; //Left else if (Selectedpiece.piececol = Col && selected Piece.piecerow > Row && c.piececol = col && c.piecerow > Row &&
C.piecerow < Selectedpiece.piecerow) {return false; //move to the right else if (Selectedpiece.piececol = col && se Lectedpiece.piecerow < row && C.piececol = col && C.piecerow < row &Amp;& c.piecerow > Selectedpiece.piecerow) {return false;
} return true; else {if (Math.Abs (col-selectedpiece.piececol) = = 1 && r ow = = Selectedpiece.piecerow) | |
(Math.Abs (row-selectedpiece.piecerow) = = 1 && col = = Selectedpiece.piececol))
{return true;
return false; }
}
}
4. Randomly arranging pieces:
<summary>
///Random array elements
///</summary>
///<param name= "Listchess" ></param>
///<returns></returns>
private list<chesspiece> listrandom (list<chesspiece> listchess)
{
Random ran = new Random ();
List newlist = new list ();
int k = 0;
Chesspiece C = new chesspiece ();
for (int i = 0; i < Listchess.count i++)
{
k = ran. Next (0,);
if (k!= i)
{
c = listchess[i];
Listchess[i] = listchess[k];
LISTCHESS[K] = c;
}
}
return listchess;
}
Because the level is limited, there are many deficiencies in the code, the code is a bit messy, object-oriented encapsulation, inheritance, polymorphism characteristics are not reflected, welcome to explore Progress
Source:
Http://files.cnblogs.com/infly123/%E6%BA%90%E4%BB%A3%E7%A0%81.rar