Advertisement
Guest User

Untitled

a guest
May 6th, 2016
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.31 KB | None | 0 0
  1.     class Formation
  2.     {
  3.         static public Dictionary<string, char[,]> formationDB;
  4.         static ConsoleColor[] colorPool;
  5.         //A tetris alakzatokat tároló mátrix, ez alapján történik a rajzolás
  6.         char[,] matrix;
  7.         int id;
  8.         ConsoleColor color;
  9.         string name;
  10.        
  11.  
  12.  
  13.         public char[,] Matrix {
  14.             get { return matrix; }
  15.         }
  16.         public int ID {
  17.             get { return id; }
  18.             set {
  19.                 try {
  20.                     SetID(value);
  21.                 }
  22.                 catch(IDAlreadySetException ia) {
  23.                     ConsoleColor def = Console.ForegroundColor;
  24.                     Console.ForegroundColor = ConsoleColor.Red;
  25.                     Console.WriteLine(ia.Message);
  26.                     Console.ForegroundColor = def;
  27.                 }
  28.             }
  29.         }
  30.         public ConsoleColor Color {
  31.             get { return color; }
  32.         }
  33.         public string Name {
  34.             get { return name; }
  35.         }
  36.  
  37.  
  38.         //static const a tetris alakzat bázis felépítéséhez
  39.         static Formation() {
  40.             formationDB.Add("quad", new char[,] { { '1', '1' }, { '1', '1' } });
  41.             formationDB.Add("line", new char[,] { { '1' }, { '1' }, { '1' }, { '1' } });
  42.             formationDB.Add("line_90", new char[,] { { '1', '1', '1', '1' } });
  43.             formationDB.Add("S", new char[,] { { '0', '1', '1'}, { '1', '1', '0' } });
  44.             formationDB.Add("S_90", new char[,] { { '1', '0'}, { '1', '1' }, { '0', '1' } });
  45.             formationDB.Add("Z", new char[,] { { '1', '1', '0' }, { '0', '1', '1' } });
  46.             formationDB.Add("Z_90", new char[,] { { '0', '1'}, { '1', '1' }, { '1', '0' } });
  47.             formationDB.Add("L", new char[,] { { '1', '0' }, { '1', '0' }, { '1', '1' } });
  48.             formationDB.Add("L_90", new char[,] { { '1', '1', '1' }, { '1', '0', '0' } });
  49.             formationDB.Add("L_180", new char[,] { { '1', '1' }, { '0', '1' }, { '0', '1' } });
  50.             formationDB.Add("L_270", new char[,] { { '0', '0', '1' }, { '1', '1', '1' } });
  51.             formationDB.Add("RL", new char[,] { { '0', '1' }, { '0', '1' }, { '1', '1' } });
  52.             formationDB.Add("RL_90", new char[,] { { '1', '0', '0' }, { '1', '1', '1' } });
  53.             formationDB.Add("RL_180", new char[,] { { '1','1' }, { '1', '0' }, { '1', '0' } });
  54.             formationDB.Add("RL_270", new char[,] { { '1', '1', '1' }, { '0', '0', '1' } });
  55.             formationDB.Add("T", new char[,] { { '1', '1', '1'  }, { '0', '1', '0' } });
  56.             formationDB.Add("T_90", new char[,] { { '0', '1' }, { '1', '1' }, { '0', '1' } });
  57.             formationDB.Add("T_180", new char[,] { { '0', '1', '0' }, { '1', '1', '1' } });
  58.             formationDB.Add("T_270", new char[,] { { '1', '0' }, { '1', '1' }, { '1', '0' } });
  59.  
  60.             colorPool = (ConsoleColor[])ConsoleColor.GetValues(typeof(ConsoleColor));
  61.         }
  62.        
  63.  
  64.         //default const
  65.         public Formation(string formationName) {
  66.             try {
  67.                 GenerateFormation(formationName);
  68.             }
  69.             catch(WrongFormationNameException wf) {
  70.                 Console.WriteLine(wf.Message);
  71.             }
  72.             name = formationName;
  73.             this.id = -1;
  74.             GenerateColor();
  75.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement