Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace BatailleNavale
- {
- class Renderer
- {
- private int _xSize, _ySize;
- private string _title;
- ConsoleColor _color;
- int[,] _plateau;
- string _padding = "";
- public Renderer(int x, int y, int[,] p ,string t, ConsoleColor c)
- {
- this._xSize = x;
- this._ySize = y;
- this._title = t;
- this._color = c;
- this._plateau = p;
- }
- public void ShowPlateau()
- {
- _padding = "";
- for (int x = 0; x < 20; x++)
- {
- _padding += ' ';
- }
- Console.Write(_padding);
- Console.ForegroundColor = _color;
- Console.WriteLine(_title);
- for (int y = -1; y < _ySize +2; y++)
- {
- if (y >= 1 && y <= _ySize )
- {
- Console.Write(_padding);
- Console.ForegroundColor = ConsoleColor.White;
- Console.Write(y);
- }
- if (y == 0)
- {
- Console.Write(_padding);
- Console.Write(" ");
- }
- for (int x = 0; x < _xSize; x++)
- {
- if (x == 0 && y != _ySize)
- {
- Console.Write(" ");
- }
- if (x == 0 && y == _ySize)
- {
- Console.Write(" ");
- }
- if (y == -1 && x == 0)
- Console.Write(_padding);
- if (y == _ySize + 1 && x == 0)
- Console.Write(_padding);
- if (y == -1 || y == _ySize + 1)
- {
- Console.ForegroundColor = ConsoleColor.White;
- Console.Write("════");
- }
- else if (x == _xSize - 1 && y == -1)
- {
- Console.WriteLine();
- }
- else if (y >= 0 && y <= _ySize)
- {
- if (y == 0)
- {
- Console.ForegroundColor = ConsoleColor.White;
- Console.Write(((char)('a' + x)));
- Console.Write(" ");
- }
- else
- {
- switch (_plateau[x, y-1])
- {
- case 0:
- Console.ForegroundColor = ConsoleColor.Cyan;
- Console.Write("▓▓▓ ");
- break;
- case 1:
- Console.ForegroundColor = ConsoleColor.Gray;
- Console.Write("▓▓▓ ");
- break;
- case 2:
- Console.ForegroundColor = ConsoleColor.DarkRed;
- Console.Write("▓▓▓ ");
- break;
- case 3:
- Console.ForegroundColor = ConsoleColor.Yellow;
- Console.Write("▓▓▓ ");
- break;
- }
- }
- }
- }
- Console.WriteLine();
- Console.WriteLine();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement