-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBaseBricksArray.cs
129 lines (117 loc) · 3.18 KB
/
BaseBricksArray.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using MVCBricks.Core.Shapes;
using System.Drawing;
namespace MVCBricks.Core
{
public abstract class BaseBricksArray : IBricksArray
{
#region attributes
protected int width = 0;
protected int height = 0;
protected string shapeString = "";
protected IBrick[,] shapeArray = null;
protected IPresenter presenter = null;
#endregion attributes
#region methods
public string GetStringFromShapeArray()
{
string ret = "";
for (int row = 0; row < height; row++)
{
for (int column = 0; column < width; column++)
{
if (shapeArray[column, row] != null)
{
//ret += ((int)(shapeArray[column, row].Color)).ToString();
ret += "1";
}
else
{
ret += "0";
}
}
}
return ret;
}
protected Color GetShapeColorFromInteger(int c)
{
Color ret = Color.White;
switch (c)
{
case 1:
ret = Color.Blue;
break;
case 2:
ret = Color.DarkGray;
break;
case 3:
ret = Color.Green;
break;
case 4:
ret = Color.Orange;
break;
case 5:
ret = Color.LightGray;
break;
case 6:
ret = Color.Red;
break;
case 7:
ret = Color.Purple;
break;
case 8:
ret = Color.White;
break;
case 9:
ret = Color.Yellow;
break;
}
return ret;
}
public virtual void InitializeArray()
{
shapeArray = new IBrick[width, height];
for (int row = 0; row < height; row++)
{
for (int column = 0; column < width; column++)
{
shapeArray[column, row] = null;
}
}
}
private string Replicate(string s, int n)
{
string ret = "";
for (int i = 0; i < n; i++)
{
ret += s;
}
return ret;
}
public int Width
{
get { return width; }
}
public int Height
{
get { return height; }
}
public string ShapeString
{
get { return GetStringFromShapeArray(); }
}
public IBrick[,] ShapeArray
{
get { return shapeArray; }
}
public IPresenter Presenter
{
get { return presenter; }
set { presenter = value; }
}
#endregion methods
}
}