Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace Game
- {
- class Program
- {
- static void Main(string[] args)
- {
- int[,] Field = new int[25, 25];
- Random random = new Random();
- for (int i = 0; i < 25; i++)
- {
- for (int j = 0; j < 25; j++)
- {
- Field[i, j] = 0;
- }
- }
- string player1Str = "OOO";
- string player2Str = "XXX";
- string fieldStr = "###";
- FieldOut(Field, player1Str, player2Str, fieldStr);
- int round = 2;
- do
- {
- if (round == 1)
- round++;
- else round = 1;
- int x = random.Next(1, 7), y = random.Next(1, 7);
- InterfaceMove(round, x, y, Field, player1Str, player2Str, fieldStr);
- Console.ReadKey();
- } while (true);
- }
- static void WhoWin(int[,] FieldTemp)
- {
- int player1=0, player2=0, empt = 0;
- for (int i = 0; i < 25; i++)
- {
- for (int j = 0; j < 25; j++)
- {
- if(FieldTemp[i, j] == 1)
- player1++;
- else if(FieldTemp[i, j] == 2)
- player2++;
- else empt++;
- }
- }
- if(player1 > player2)
- Console.WriteLine("Player 1 Win!! with "+(player1-player2)+" cells ahead");
- else if(player1 < player2)
- Console.WriteLine("Player 2 Win!! with "+(player2-player1)+" cells ahead");
- else
- Console.WriteLine("Draw! blue and red got " +player1+" cells marked, and field has " +empt+" empty cells");
- Console.ReadKey();
- Environment.Exit(0);
- }
- static void InterfaceMove(int move, int x, int y, int[,] FieldTemp, string player1, string player2, string emptFieldSymb)
- {
- int x1, y1;
- bool rot= false;
- do
- {
- Console.Clear();
- FieldOut(FieldTemp, player1, player2, emptFieldSymb);
- Console.WriteLine("Write 'e' to Exit or nothing to continue;");
- string exit = Console.ReadLine();
- if(exit == "e")
- WhoWin(FieldTemp);
- if(move == 1)
- Console.WriteLine("Red Turn!");
- else Console.WriteLine("Blue Turn!");
- Console.WriteLine("Dice drop: " + x + ", and " + y);
- Console.WriteLine("Rotate? (n/y):");
- string ch = Console.ReadLine();
- if (ch == "y")
- {
- int temp = x;
- x = y;
- y = temp;
- rot = true;
- }
- else rot = false;
- }
- while(rot == true);
- Console.Write("Place at: \nx(vertical): ");
- x1 = Convert.ToInt32(Console.ReadLine());
- Console.Write("y(horizontal): ");
- y1 = Convert.ToInt32(Console.ReadLine());
- Console.WriteLine();
- if (move == 1)
- for (int i = x1; i < x1 + x; i++)
- {
- for (int j = y1; j < y1 + y; j++)
- {
- FieldTemp[i, j] = move;
- }
- }
- else if (move == 2)
- for (int i = x1; i < x1 + x; i++)
- {
- for (int j = y1; j < y1 + y; j++)
- {
- FieldTemp[24 - i, 24 - j] = move;
- }
- }
- }
- static void FieldOut(int[,] FieldTemp, string player1, string player2, string emptFieldSymb)
- {
- for(int i = 0; i < 27; i++)
- {
- if (i == 0 || i == 26)
- {
- Console.Write(" ");
- for (int j = 0; j < 25; j++)
- {
- if(i == 0)
- {
- if(j<10)
- Console.Write(j+" ");
- else Console.Write(j + " ");
- }
- else
- {
- if(25-j<11)
- Console.Write(" "+(24-j));
- else Console.Write(" "+ (24-j));
- }
- }
- Console.Write(" ");
- }
- else
- {
- if (i < 10)
- Console.Write(" " + (i - 1)+" ");
- else Console.Write(i+" ");
- for (int j = 0; j < 25; j++)
- {
- if (FieldTemp[i - 1, j] == 0)
- {
- Console.ForegroundColor = ConsoleColor.White;
- Console.Write(emptFieldSymb);
- Console.ResetColor();
- }
- else if (FieldTemp[i - 1, j] == 1)
- {
- Console.ForegroundColor = ConsoleColor.Red;
- Console.Write(player1);
- Console.ResetColor();
- }
- else if (FieldTemp[i - 1, j] == 2)
- {
- Console.ForegroundColor = ConsoleColor.Blue;
- Console.Write(player2);
- Console.ResetColor();
- }
- }
- Console.Write(" "+ (25 - i));
- }
- Console.WriteLine();
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment