Skip to content

Commit 0352c11

Browse files
committed
Change code formatting style
1 parent a75dba0 commit 0352c11

File tree

4 files changed

+81
-81
lines changed

4 files changed

+81
-81
lines changed

Assets/Scripts/Board.cs

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,20 @@ public class Board : MonoBehaviour
1515
public RectInt Bounds {
1616
get
1717
{
18-
Vector2Int position = new Vector2Int(-this.boardSize.x / 2, -this.boardSize.y / 2);
19-
return new RectInt(position, this.boardSize);
18+
Vector2Int position = new Vector2Int(-boardSize.x / 2, -boardSize.y / 2);
19+
return new RectInt(position, boardSize);
2020
}
2121
}
2222

2323
private void Awake()
2424
{
25-
this.tilemap = GetComponentInChildren<Tilemap>();
26-
this.activePiece = GetComponentInChildren<Piece>();
27-
this.nextPiece = this.gameObject.AddComponent<Piece>();
28-
this.nextPiece.enabled = false;
25+
tilemap = GetComponentInChildren<Tilemap>();
26+
activePiece = GetComponentInChildren<Piece>();
27+
nextPiece = gameObject.AddComponent<Piece>();
28+
nextPiece.enabled = false;
2929

30-
for (int i = 0; i < this.tetrominoes.Length; i++) {
31-
this.tetrominoes[i].Initialize();
30+
for (int i = 0; i < tetrominoes.Length; i++) {
31+
tetrominoes[i].Initialize();
3232
}
3333
}
3434

@@ -40,33 +40,33 @@ private void Start()
4040

4141
private void SetNextPiece()
4242
{
43-
if (this.nextPiece.cells != null) {
44-
Clear(this.nextPiece);
43+
if (nextPiece.cells != null) {
44+
Clear(nextPiece);
4545
}
4646

47-
int random = Random.Range(0, this.tetrominoes.Length);
48-
TetrominoData data = this.tetrominoes[random];
47+
int random = Random.Range(0, tetrominoes.Length);
48+
TetrominoData data = tetrominoes[random];
4949

50-
this.nextPiece.Initialize(this, this.previewPosition, data);
51-
Set(this.nextPiece);
50+
nextPiece.Initialize(this, previewPosition, data);
51+
Set(nextPiece);
5252
}
5353

5454
public void SpawnPiece()
5555
{
56-
this.activePiece.Initialize(this, this.spawnPosition, this.nextPiece.data);
56+
activePiece.Initialize(this, spawnPosition, nextPiece.data);
5757

58-
if (!IsValidPosition(this.activePiece, this.spawnPosition)) {
58+
if (!IsValidPosition(activePiece, spawnPosition)) {
5959
GameOver();
6060
} else {
61-
Set(this.activePiece);
61+
Set(activePiece);
6262
}
6363

6464
SetNextPiece();
6565
}
6666

6767
public void GameOver()
6868
{
69-
this.tilemap.ClearAllTiles();
69+
tilemap.ClearAllTiles();
7070

7171
// Do anything else you want on game over here..
7272
}
@@ -76,7 +76,7 @@ public void Set(Piece piece)
7676
for (int i = 0; i < piece.cells.Length; i++)
7777
{
7878
Vector3Int tilePosition = piece.cells[i] + piece.position;
79-
this.tilemap.SetTile(tilePosition, piece.data.tile);
79+
tilemap.SetTile(tilePosition, piece.data.tile);
8080
}
8181
}
8282

@@ -85,13 +85,13 @@ public void Clear(Piece piece)
8585
for (int i = 0; i < piece.cells.Length; i++)
8686
{
8787
Vector3Int tilePosition = piece.cells[i] + piece.position;
88-
this.tilemap.SetTile(tilePosition, null);
88+
tilemap.SetTile(tilePosition, null);
8989
}
9090
}
9191

9292
public bool IsValidPosition(Piece piece, Vector3Int position)
9393
{
94-
RectInt bounds = this.Bounds;
94+
RectInt bounds = Bounds;
9595

9696
// The position is only valid if every cell is valid
9797
for (int i = 0; i < piece.cells.Length; i++)
@@ -104,7 +104,7 @@ public bool IsValidPosition(Piece piece, Vector3Int position)
104104
}
105105

106106
// A tile already occupies the position, thus invalid
107-
if (this.tilemap.HasTile(tilePosition)) {
107+
if (tilemap.HasTile(tilePosition)) {
108108
return false;
109109
}
110110
}
@@ -114,7 +114,7 @@ public bool IsValidPosition(Piece piece, Vector3Int position)
114114

115115
public void ClearLines()
116116
{
117-
RectInt bounds = this.Bounds;
117+
RectInt bounds = Bounds;
118118
int row = bounds.yMin;
119119

120120
// Clear from bottom to top
@@ -132,14 +132,14 @@ public void ClearLines()
132132

133133
public bool IsLineFull(int row)
134134
{
135-
RectInt bounds = this.Bounds;
135+
RectInt bounds = Bounds;
136136

137137
for (int col = bounds.xMin; col < bounds.xMax; col++)
138138
{
139139
Vector3Int position = new Vector3Int(col, row, 0);
140140

141141
// The line is not full if a tile is missing
142-
if (!this.tilemap.HasTile(position)) {
142+
if (!tilemap.HasTile(position)) {
143143
return false;
144144
}
145145
}
@@ -149,13 +149,13 @@ public bool IsLineFull(int row)
149149

150150
public void LineClear(int row)
151151
{
152-
RectInt bounds = this.Bounds;
152+
RectInt bounds = Bounds;
153153

154154
// Clear all tiles in the row
155155
for (int col = bounds.xMin; col < bounds.xMax; col++)
156156
{
157157
Vector3Int position = new Vector3Int(col, row, 0);
158-
this.tilemap.SetTile(position, null);
158+
tilemap.SetTile(position, null);
159159
}
160160

161161
// Shift every row above down one
@@ -164,10 +164,10 @@ public void LineClear(int row)
164164
for (int col = bounds.xMin; col < bounds.xMax; col++)
165165
{
166166
Vector3Int position = new Vector3Int(col, row + 1, 0);
167-
TileBase above = this.tilemap.GetTile(position);
167+
TileBase above = tilemap.GetTile(position);
168168

169169
position = new Vector3Int(col, row, 0);
170-
this.tilemap.SetTile(position, above);
170+
tilemap.SetTile(position, above);
171171
}
172172

173173
row++;

Assets/Scripts/Ghost.cs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ public class Ghost : MonoBehaviour
1313

1414
private void Awake()
1515
{
16-
this.tilemap = GetComponentInChildren<Tilemap>();
17-
this.cells = new Vector3Int[4];
16+
tilemap = GetComponentInChildren<Tilemap>();
17+
cells = new Vector3Int[4];
1818
}
1919

2020
private void LateUpdate()
@@ -27,49 +27,49 @@ private void LateUpdate()
2727

2828
private void Clear()
2929
{
30-
for (int i = 0; i < this.cells.Length; i++)
30+
for (int i = 0; i < cells.Length; i++)
3131
{
32-
Vector3Int tilePosition = this.cells[i] + this.position;
33-
this.tilemap.SetTile(tilePosition, null);
32+
Vector3Int tilePosition = cells[i] + position;
33+
tilemap.SetTile(tilePosition, null);
3434
}
3535
}
3636

3737
private void Copy()
3838
{
39-
for (int i = 0; i < this.cells.Length; i++) {
40-
this.cells[i] = this.trackingPiece.cells[i];
39+
for (int i = 0; i < cells.Length; i++) {
40+
cells[i] = trackingPiece.cells[i];
4141
}
4242
}
4343

4444
private void Drop()
4545
{
46-
Vector3Int position = this.trackingPiece.position;
46+
Vector3Int position = trackingPiece.position;
4747

4848
int current = position.y;
49-
int bottom = -this.mainBoard.boardSize.y / 2 - 1;
49+
int bottom = -mainBoard.boardSize.y / 2 - 1;
5050

51-
this.mainBoard.Clear(this.trackingPiece);
51+
mainBoard.Clear(trackingPiece);
5252

5353
for (int row = current; row >= bottom; row--)
5454
{
5555
position.y = row;
5656

57-
if (this.mainBoard.IsValidPosition(this.trackingPiece, position)) {
57+
if (mainBoard.IsValidPosition(trackingPiece, position)) {
5858
this.position = position;
5959
} else {
6060
break;
6161
}
6262
}
6363

64-
this.mainBoard.Set(this.trackingPiece);
64+
mainBoard.Set(trackingPiece);
6565
}
6666

6767
private void Set()
6868
{
69-
for (int i = 0; i < this.cells.Length; i++)
69+
for (int i = 0; i < cells.Length; i++)
7070
{
71-
Vector3Int tilePosition = this.cells[i] + this.position;
72-
this.tilemap.SetTile(tilePosition, this.tile);
71+
Vector3Int tilePosition = cells[i] + position;
72+
tilemap.SetTile(tilePosition, tile);
7373
}
7474
}
7575

0 commit comments

Comments
 (0)