예제 #1
0
		public static void Main (string[] args)
		{
			Grid grid = new Grid ();

			Player player1 = new Player ("Tim", Colors.White);
			Player player2 = new Player ("Vasya", Colors.Black);

			Game game = new Game (grid, player1, player2);

			int x, y, newX, newY, enemyX, enemyY;
			bool forSelect, forMove, move, compare, attack, forAttack;

			while (!game.IsOver) 
			{
				forSelect = forMove = move = compare = attack = forAttack = false;
				x = y = newX = newY = enemyX = enemyY = -1;

				while(!move && !attack)
				{
					while(!forSelect)
						forSelect = ReadCoordinate (out x, out y);

					while(!forMove)
						forMove = ReadCoordinate (out newX, out newY);

					compare = game.CompareCoordinateVSPlayer (x, y, newX, newY);

					if (compare) 
					{
						move = game.ParseMove (x, y, newX, newY);

						attack = game.ParseAttack (x, y, newX, newY, out enemyX, out enemyY);

						if (attack) 
						{
							while (attack) 
							{
								grid.Attack (x, y, newX, newY, enemyX, enemyY);

								while (!forAttack)
									forAttack = ReadCoordinate (out newX, out newY);

								attack = game.ParseAttack (x, y, newX, newY, out enemyX, out enemyY);
							}
						}

						else if (move) 
							grid.Move(x, y, newX, newY);
					}
				}

				game.IfFinished();

				if (!game.IsOver && compare)
					game.MakeTurn ();
			}

			Console.ReadKey ();
		}
예제 #2
0
		public Game (Grid grid, Player player1, Player player2)
		{
			_grid = grid;
			_player1 = player1;
			_player2 = player2;

			CurrentPlayer = _player1;
			CurrentEnemy = _player2;

			IsOver = false;
		}