本文整理汇总了C#中Storage.AddScore方法的典型用法代码示例。如果您正苦于以下问题:C# Storage.AddScore方法的具体用法?C# Storage.AddScore怎么用?C# Storage.AddScore使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Storage
的用法示例。
在下文中一共展示了Storage.AddScore方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RunGameIteration
private static void RunGameIteration(int testTypeNum, Storage storage)
{
Game game = new Game(4);
int?[,] startingBoard = new int?[game.size, game.size];
for (int i = 0; i < game.size; i++) {
for (int j = 0; j < game.size; j++) {
startingBoard[i, j] = game.Board[i, j];
}
}
//game.DisplayBoard();
int move = 0;
int temp = 0; // Means different things dependent on algorithm
while (game.Running) {
switch (testTypeNum) {
case 0: // Random Simple
move = Rand.Next(0, 4);
break;
case 1: // Random no doubles
move = Rand.Next(0, 4);
while (move == temp) {
move = Rand.Next(0, 4); // Never do the same move twice in a row
}
temp = move;
break;
case 2: // Rotate Counter-Clockwise
move = (move + 1) % 4;
break;
case 3: // Rotate Clockwise
if (move == 0) move = 4;
move = (move - 1) % 4;
break;
case 4: // Rotate both ways, switching at a constant interval
if (temp >= 20)
temp = 0;
if (temp >= 10)
move = (move - 1) % 4;
else
move = (move + 1) % 4;
temp++;
break;
case 5: // Rotate both ways, switching at a random interval
temp = Rand.Next(0, 20);
if (temp >= 10) {
if (move == 0) move = 4;
move = (move - 1) % 4;
} else {
move = (move + 1) % 4;
}
break;
}
game.MakeMove(move);
}
//game.DisplayBoard();
if (game.Loss) {
//Console.WriteLine("You lost!");
} else {
Console.WriteLine("Something else happened..");
}
storage.AddScore(new Score { BestTile = game.CurrentMax, Moves = game.NumberOfMoves, TotalScore = game.TotalScore, Board = game.Board, StartingBoard = startingBoard });
}