Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
tetra-tower
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Oenos
tetra-tower
Commits
d00ff497
Commit
d00ff497
authored
Nov 30, 2018
by
18손재민
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
프레스 관련해서 오류 수정함, 이제 서로 떨어져 있는줄 한번에 지울 때 및 여러 줄 시간 차 두고 지울 때 정상적으로 작동함
parent
ca6197e4
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
140 additions
and
99 deletions
+140
-99
MapManager.cs
Assets/Scripts/TetrisMap/MapManager.cs
+93
-69
Press.cs
Assets/Scripts/TetrisMap/Press.cs
+18
-2
TetriminoSpawner.cs
Assets/Scripts/TetrisMap/TetriminoSpawner.cs
+29
-28
No files found.
Assets/Scripts/TetrisMap/MapManager.cs
View file @
d00ff497
...
@@ -8,7 +8,7 @@ public class MapManager : MonoBehaviour {
...
@@ -8,7 +8,7 @@ public class MapManager : MonoBehaviour {
* variables
* variables
* */
* */
TetriminoSpawner
TS
;
TetriminoSpawner
tetriminoSpawner
;
/// <summary>
/// <summary>
/// Grid showing tiles.
/// Grid showing tiles.
/// </summary>
/// </summary>
...
@@ -67,7 +67,7 @@ public class MapManager : MonoBehaviour {
...
@@ -67,7 +67,7 @@ public class MapManager : MonoBehaviour {
/// <summary>
/// <summary>
/// Tetris Y axis coordinates on Unity.
/// Tetris Y axis coordinates on Unity.
/// </summary>
/// </summary>
public
static
float
[]
tetrisYCoord
=
new
float
[
height
];
public
float
[]
tetrisYCoord
=
new
float
[
height
];
/// <summary>
/// <summary>
/// Choose to make a boss tetrimino or not.
/// Choose to make a boss tetrimino or not.
/// </summary>
/// </summary>
...
@@ -106,18 +106,6 @@ public class MapManager : MonoBehaviour {
...
@@ -106,18 +106,6 @@ public class MapManager : MonoBehaviour {
/*
/*
* functions
* functions
* */
* */
/*
/// <summary>
/// Set coordinates to integer.
/// Only use it for mapCoord adjustment.
/// </summary>
/// <param name="coord">Room's map coordinates.</param>
/// <returns></returns>
public static Vector3 AdjustMapCoord(Vector3 coord)
{
return new Vector3(Mathf.Round(coord.x), Mathf.Round(coord.y), coord.z);
}
*/
/// <summary>
/// <summary>
/// Check if tetrimino is in right x coordinate.
/// Check if tetrimino is in right x coordinate.
/// </summary>
/// </summary>
...
@@ -174,12 +162,16 @@ public class MapManager : MonoBehaviour {
...
@@ -174,12 +162,16 @@ public class MapManager : MonoBehaviour {
return
;
return
;
}
}
}
}
/// <summary>
/// <summary>
/// Find full rows and create presses.
/// Find full rows and create presses.
/// </summary>
/// </summary>
public
void
DeleteFullRows
()
public
void
DeleteFullRows
()
{
{
for
(
int
y
=
realHeight
;
y
>=
0
;
y
--)
int
order
=
0
;
ArrayList
simultaneousPress
=
new
ArrayList
();
for
(
int
y
=
0
;
y
<
realHeight
;
y
++)
{
{
if
(
IsRowFull
(
y
)
&&
!
isRowDeleting
[
y
])
if
(
IsRowFull
(
y
)
&&
!
isRowDeleting
[
y
])
{
{
...
@@ -187,21 +179,25 @@ public class MapManager : MonoBehaviour {
...
@@ -187,21 +179,25 @@ public class MapManager : MonoBehaviour {
Press
leftPress
=
Instantiate
(
press
,
new
Vector3
(
0
,
y
*
tetrisMapSize
,
0
),
Quaternion
.
identity
);
Press
leftPress
=
Instantiate
(
press
,
new
Vector3
(
0
,
y
*
tetrisMapSize
,
0
),
Quaternion
.
identity
);
Press
rightPress
=
Instantiate
(
press
,
new
Vector3
(
10
*
tetrisMapSize
,
y
*
tetrisMapSize
,
0
),
Quaternion
.
identity
);
Press
rightPress
=
Instantiate
(
press
,
new
Vector3
(
10
*
tetrisMapSize
,
y
*
tetrisMapSize
,
0
),
Quaternion
.
identity
);
leftPress
.
initialCollapseTime
=
Time
.
time
;
leftPress
.
initialCollapseTime
=
Time
.
time
;
leftPress
.
row
=
y
;
rightPress
.
initialCollapseTime
=
Time
.
time
;
rightPress
.
initialCollapseTime
=
Time
.
time
;
rightPress
.
row
=
y
;
leftPress
.
isLeft
=
true
;
rightPress
.
isLeft
=
false
;
leftPress
.
row
=
y
;
leftPress
.
bottomRow
=
y
;
leftPress
.
createdOrder
=
order
;
simultaneousPress
.
Add
(
leftPress
);
StartCoroutine
(
TetrisPress
(
leftPress
.
initialCollapseTime
,
leftPress
,
rightPress
));
StartCoroutine
(
TetrisPress
(
leftPress
.
initialCollapseTime
,
leftPress
,
rightPress
));
/*for (int x = 0; x < width; x++)
order
++;
{
Destroy(mapGrid[x, y].gameObject);
mapGrid[x, y] = null;
}
}
DecreaseRowsAbove(y);*/
}
}
foreach
(
Press
child
in
simultaneousPress
)
{
child
.
simultaneouslyCreatedPressNumber
=
order
-
1
;
}
}
}
}
/// <summary>
/// <summary>
/// Extend press than collapse press.
/// Extend and collapse press.
/// When other presses are remain, than reduce their bottom rows.
/// </summary>
/// </summary>
/// <param name="initialCollapseTime">Initial time that collapse has started.</param>
/// <param name="initialCollapseTime">Initial time that collapse has started.</param>
/// <param name="leftPress">Left press.</param>
/// <param name="leftPress">Left press.</param>
...
@@ -216,65 +212,65 @@ public class MapManager : MonoBehaviour {
...
@@ -216,65 +212,65 @@ public class MapManager : MonoBehaviour {
leftPress
.
transform
.
localScale
=
new
Vector3
(
collapseRate
*
20
,
1
,
1
);
leftPress
.
transform
.
localScale
=
new
Vector3
(
collapseRate
*
20
,
1
,
1
);
rightPress
.
transform
.
localScale
=
new
Vector3
(-
collapseRate
*
20
,
1
,
1
);
rightPress
.
transform
.
localScale
=
new
Vector3
(-
collapseRate
*
20
,
1
,
1
);
}
}
int
row
=
leftPress
.
GetComponent
<
Press
>().
row
;
int
row
=
leftPress
.
row
;
Press
[]
presses
=
FindObjectsOfType
<
Press
>();
foreach
(
Press
child
in
presses
)
{
if
(
child
.
isLeft
&&
child
.
row
>
row
)
{
child
.
bottomRow
-=
1
;
}
}
for
(
int
x
=
0
;
x
<
width
;
x
++)
for
(
int
x
=
0
;
x
<
width
;
x
++)
{
{
Destroy
(
mapGrid
[
x
,
row
].
gameObject
);
Destroy
(
mapGrid
[
x
,
row
].
gameObject
);
mapGrid
[
x
,
row
]
=
null
;
mapGrid
[
x
,
row
]
=
null
;
}
}
isRowDeleting
[
row
]
=
false
;
while
(
leftPress
.
transform
.
localScale
.
x
>
1
)
while
(
leftPress
.
transform
.
localScale
.
x
>
1
)
{
{
yield
return
new
WaitForSeconds
(
0.01f
);
yield
return
new
WaitForSeconds
(
0.01f
);
leftPress
.
transform
.
localScale
-=
new
Vector3
(
3
,
0
,
0
);
leftPress
.
transform
.
localScale
-=
new
Vector3
(
3
,
0
,
0
);
rightPress
.
transform
.
localScale
-=
new
Vector3
(-
3
,
0
,
0
);
rightPress
.
transform
.
localScale
-=
new
Vector3
(-
3
,
0
,
0
);
}
}
StartCoroutine
(
DecreaseYCoord
(
row
+
1
));
isRowDeleting
[
row
]
=
false
;
//DecreaseRowsAbove(row);
if
(
leftPress
.
createdOrder
==
leftPress
.
simultaneouslyCreatedPressNumber
)
{
StartCoroutine
(
DecreaseYCoord
(
row
,
leftPress
.
bottomRow
));
}
Destroy
(
leftPress
.
gameObject
);
Destroy
(
leftPress
.
gameObject
);
Destroy
(
rightPress
.
gameObject
);
Destroy
(
rightPress
.
gameObject
);
}
}
/// <summary>
/// <summary>
/// Decrease all
rows above this
row.
/// Decrease all
empty rows between top row and bottom
row.
///
This only c
hanges mapCoord.
///
C
hanges mapCoord.
/// </summary>
/// </summary>
/// <param name="row">Row that will be underneath.</param>
/// <param name="top">Top end of the empty rows.</param>
public
void
DecreaseRowsAbove
(
int
row
)
/// <param name="bottom">Bottom end of the empty rows.</param>
public
void
DecreaseRowsAbove
(
int
top
,
int
bottom
)
{
for
(
int
i
=
bottom
;
i
<=
top
;
i
++)
{
{
for
(
int
y
=
row
;
y
<
realHeight
;
y
++)
for
(
int
y
=
bottom
;
!
isRowDeleting
[
y
]
&&
y
<
realHeight
;
y
++)
{
{
for
(
int
x
=
0
;
x
<
width
;
x
++)
for
(
int
x
=
0
;
x
<
width
;
x
++)
{
{
if
(
mapGrid
[
x
,
y
]
!=
null
&&
mapGrid
[
x
,
y
].
transform
.
parent
)
if
(
y
>
0
&&
mapGrid
[
x
,
y
]
!=
null
&&
mapGrid
[
x
,
y
].
transform
.
parent
)
{
{
mapGrid
[
x
,
y
-
1
]
=
mapGrid
[
x
,
y
];
mapGrid
[
x
,
y
-
1
]
=
mapGrid
[
x
,
y
];
mapGrid
[
x
,
y
]
=
null
;
mapGrid
[
x
,
y
]
=
null
;
mapGrid
[
x
,
y
-
1
].
mapCoord
+=
new
Vector3
(
0
,
-
1
,
0
);
mapGrid
[
x
,
y
-
1
].
mapCoord
+=
new
Vector3
(
0
,
-
1
,
0
);
//mapGrid[x, y - 1].transform.position += new Vector3(0, -tetrisMapSize, 0);
Vector3
coord
=
mapGrid
[
x
,
y
-
1
].
mapCoord
;
mapGrid
[
x
,
y
-
1
].
transform
.
position
=
new
Vector3
(
coord
.
x
*
tetrisMapSize
,
tetrisYCoord
[(
int
)
coord
.
y
],
mapGrid
[
x
,
y
-
1
].
transform
.
position
.
z
);
}
}
}
}
}
Press
[]
presses
=
FindObjectsOfType
<
Press
>();
foreach
(
Press
child
in
presses
)
{
if
(
child
.
row
>
row
)
{
child
.
row
-=
1
;
child
.
transform
.
position
+=
new
Vector3
(
0
,
-
tetrisMapSize
,
0
);
}
}
}
}
SetRoomsYCoord
();
}
}
/// <summary>
/// <summary>
/// Set all rooms' mapCoord
above ths row
to tetrisYCoord.
/// Set all rooms' mapCoord to tetrisYCoord.
/// </summary>
/// </summary>
/// <param name="row">Row that will be underneath</param>
public
void
SetRoomsYCoord
()
public
void
SetRoomsYCoord
(
int
row
)
{
{
for
(
int
y
=
row
;
y
<
realHeight
;
y
++)
for
(
int
y
=
0
;
y
<
realHeight
;
y
++)
{
{
for
(
int
x
=
0
;
x
<
width
;
x
++)
for
(
int
x
=
0
;
x
<
width
;
x
++)
{
{
...
@@ -283,35 +279,48 @@ public class MapManager : MonoBehaviour {
...
@@ -283,35 +279,48 @@ public class MapManager : MonoBehaviour {
Vector3
coord
=
mapGrid
[
x
,
y
].
mapCoord
;
Vector3
coord
=
mapGrid
[
x
,
y
].
mapCoord
;
mapGrid
[
x
,
y
].
transform
.
position
=
new
Vector3
(
coord
.
x
*
tetrisMapSize
,
tetrisYCoord
[(
int
)
coord
.
y
],
mapGrid
[
x
,
y
].
transform
.
position
.
z
);
mapGrid
[
x
,
y
].
transform
.
position
=
new
Vector3
(
coord
.
x
*
tetrisMapSize
,
tetrisYCoord
[(
int
)
coord
.
y
],
mapGrid
[
x
,
y
].
transform
.
position
.
z
);
}
}
}
}
}
}
}
}
/// <summary>
/// <summary>
/// Decreae all tetrisYCoord abobe this row.
/// Decrease tetris' y coord.
/// Changes real position.
/// </summary>
/// </summary>
/// <param name="y">Row that will be underneath.</param>
/// <param name="top">Top end of the empty row.</param>
/// <param name="bottom">Bottom end of the empty row.</param>
/// <returns></returns>
/// <returns></returns>
public
IEnumerator
DecreaseYCoord
(
int
y
)
public
IEnumerator
DecreaseYCoord
(
int
top
,
int
bottom
)
{
{
float
yInitialTime
=
Time
.
time
;
float
yInitialTime
=
Time
.
time
;
float
yFallTime
=
0
,
yFallSpeed
=
0
;
float
yFallTime
=
0
,
yFallSpeed
=
0
;
while
(
tetrisYCoord
[
y
]
>
(
y
-
1
)
*
tetrisMapSize
)
int
row
=
0
;
for
(
int
i
=
0
;
i
<
realHeight
;
i
++)
{
if
(
IsRowEmpty
(
i
))
{
row
=
i
+
1
;
break
;
}
}
while
(
tetrisYCoord
[
top
+
1
]
>
bottom
*
tetrisMapSize
)
{
{
yield
return
new
WaitForSeconds
(
0.01f
);
yield
return
new
WaitForSeconds
(
0.01f
);
if
(
isRowDeleting
[
top
+
1
])
break
;
yFallTime
=
Time
.
time
-
yInitialTime
;
yFallTime
=
Time
.
time
-
yInitialTime
;
yFallSpeed
+=
gravity
*
yFallTime
*
yFallTime
;
yFallSpeed
+=
gravity
*
yFallTime
*
yFallTime
;
for
(
int
i
=
y
;
i
<
realHeight
;
i
++)
for
(
int
i
=
row
;
!
isRowDeleting
[
i
]
&&
i
<
realHeight
;
i
++)
{
{
if
(
tetrisYCoord
[
i
]
>
0
&&
tetrisYCoord
[
i
]
>
tetrisYCoord
[
i
-
1
])
tetrisYCoord
[
i
]
-=
yFallSpeed
;
tetrisYCoord
[
i
]
-=
yFallSpeed
;
}
}
SetRoomsYCoord
(
y
);
SetRoomsYCoord
();
}
}
for
(
int
i
=
y
;
i
<
height
;
i
++)
for
(
int
i
=
0
;
i
<
height
;
i
++)
{
{
tetrisYCoord
[
i
]
=
i
*
tetrisMapSize
;
tetrisYCoord
[
i
]
=
i
*
tetrisMapSize
;
}
}
DecreaseRowsAbove
(
y
);
DecreaseRowsAbove
(
top
,
bottom
);
}
}
/// <summary>
/// <summary>
/// Check row if it is full.
/// Check row if it is full.
...
@@ -326,6 +335,18 @@ public class MapManager : MonoBehaviour {
...
@@ -326,6 +335,18 @@ public class MapManager : MonoBehaviour {
return
true
;
return
true
;
}
}
/// <summary>
/// <summary>
/// Check row if it is empty.
/// </summary>
/// <param name="row">Row you want to check.</param>
/// <returns></returns>
public
static
bool
IsRowEmpty
(
int
row
)
{
for
(
int
x
=
0
;
x
<
width
;
x
++)
if
(
mapGrid
[
x
,
row
]
!=
null
)
return
false
;
return
true
;
}
/// <summary>
/// Update rooms coordinates on mapCoord.
/// Update rooms coordinates on mapCoord.
/// </summary>
/// </summary>
/// <param name="te">Tetrimino you want to update on map.</param>
/// <param name="te">Tetrimino you want to update on map.</param>
...
@@ -460,7 +481,6 @@ public class MapManager : MonoBehaviour {
...
@@ -460,7 +481,6 @@ public class MapManager : MonoBehaviour {
MoveTetriminoMapCoord
(
te
,
new
Vector3
(
0
,
1
,
0
));
MoveTetriminoMapCoord
(
te
,
new
Vector3
(
0
,
1
,
0
));
isTetriminoFalling
=
true
;
isTetriminoFalling
=
true
;
initialFallTime
=
Time
.
time
;
initialFallTime
=
Time
.
time
;
Debug
.
Log
(
te
.
mapCoord
);
StartCoroutine
(
TetriminoDown
(
te
));
StartCoroutine
(
TetriminoDown
(
te
));
//EndTetrimino(currentTetrimino);
//EndTetrimino(currentTetrimino);
}
}
...
@@ -476,7 +496,7 @@ public class MapManager : MonoBehaviour {
...
@@ -476,7 +496,7 @@ public class MapManager : MonoBehaviour {
CreateRoom
(
te
);
CreateRoom
(
te
);
DeleteFullRows
();
DeleteFullRows
();
Destroy
(
currentGhost
.
gameObject
);
Destroy
(
currentGhost
.
gameObject
);
TS
.
MakeTetrimino
();
tetriminoSpawner
.
MakeTetrimino
();
isTetriminoFalling
=
false
;
isTetriminoFalling
=
false
;
}
}
/// <summary>
/// <summary>
...
@@ -628,7 +648,11 @@ public class MapManager : MonoBehaviour {
...
@@ -628,7 +648,11 @@ public class MapManager : MonoBehaviour {
{
{
tetrisYCoord
[
i
]
=
i
*
tetrisMapSize
;
tetrisYCoord
[
i
]
=
i
*
tetrisMapSize
;
}
}
TS
=
GameObject
.
Find
(
"TetriminoSpawner"
).
GetComponent
<
TetriminoSpawner
>();
for
(
int
i
=
0
;
i
<
isRowDeleting
.
Length
;
i
++)
{
isRowDeleting
[
i
]
=
false
;
}
tetriminoSpawner
=
GameObject
.
Find
(
"TetriminoSpawner"
).
GetComponent
<
TetriminoSpawner
>();
}
}
// Use this for initialization
// Use this for initialization
void
Start
()
{
void
Start
()
{
...
...
Assets/Scripts/TetrisMap/Press.cs
View file @
d00ff497
...
@@ -12,9 +12,25 @@ public class Press : MonoBehaviour
...
@@ -12,9 +12,25 @@ public class Press : MonoBehaviour
/// </summary>
/// </summary>
public
float
initialCollapseTime
;
public
float
initialCollapseTime
;
/// <summary>
/// <summary>
///
Time press has started to collapsed
.
///
Row the press is accounting for
.
/// </summary>
/// </summary>
public
int
row
;
public
int
row
;
/// <summary>
/// Lowest empty row below this press.
/// </summary>
public
int
bottomRow
;
/// <summary>
/// Created order of this press between simultaneously created presses.
/// </summary>
public
int
createdOrder
;
/// <summary>
/// Number of presses created simultaneously with this press.
/// </summary>
public
int
simultaneouslyCreatedPressNumber
;
/// <summary>
/// Check if this press is on left side or not.
/// </summary>
public
bool
isLeft
;
// Use this for initialization
// Use this for initialization
...
...
Assets/Scripts/TetrisMap/TetriminoSpawner.cs
View file @
d00ff497
...
@@ -7,7 +7,7 @@ public class TetriminoSpawner : MonoBehaviour {
...
@@ -7,7 +7,7 @@ public class TetriminoSpawner : MonoBehaviour {
/*
/*
* variables
* variables
* */
* */
MapManager
MM
;
MapManager
mapManager
;
/// <summary>
/// <summary>
/// All tetriminoes.
/// All tetriminoes.
/// </summary>
/// </summary>
...
@@ -29,29 +29,30 @@ public class TetriminoSpawner : MonoBehaviour {
...
@@ -29,29 +29,30 @@ public class TetriminoSpawner : MonoBehaviour {
/// </summary>
/// </summary>
public
void
MakeTetrimino
()
public
void
MakeTetrimino
()
{
{
if
(!
MM
.
gameOver
)
if
(!
mapManager
.
gameOver
)
{
{
int
randomPosition
=
Random
.
Range
(
0
,
MapManager
.
width
);
int
randomPosition
=
Random
.
Range
(
0
,
MapManager
.
width
);
int
randomTetrimino
;
int
randomTetrimino
;
if
(
MM
.
spawnBossTetrimino
)
if
(
mapManager
.
spawnBossTetrimino
)
{
{
randomTetrimino
=
7
;
randomTetrimino
=
7
;
MM
.
spawnBossTetrimino
=
false
;
mapManager
.
spawnBossTetrimino
=
false
;
}
}
else
else
randomTetrimino
=
TetriminoRandomizer
();
randomTetrimino
=
TetriminoRandomizer
();
MM
.
currentTetrimino
=
Instantiate
(
tetriminoes
[
randomTetrimino
],
MM
.
tetrisMapCoord
+
MM
.
tetrisMapSize
*
new
Vector3
(
randomPosition
,
MapManager
.
realHeight
+
1
,
MM
.
tetrisMapCoord
.
z
),
Quaternion
.
identity
);
mapManager
.
currentTetrimino
=
Instantiate
(
tetriminoes
[
randomTetrimino
],
MM
.
currentTetrimino
.
mapCoord
=
(
MM
.
currentTetrimino
.
transform
.
position
-
MM
.
tetrisMapCoord
)
/
MM
.
tetrisMapSize
;
mapManager
.
tetrisMapCoord
+
mapManager
.
tetrisMapSize
*
new
Vector3
(
randomPosition
,
MapManager
.
realHeight
+
1
,
mapManager
.
tetrisMapCoord
.
z
),
Quaternion
.
identity
);
MM
.
SetRoomMapCoord
(
MM
.
currentTetrimino
);
mapManager
.
currentTetrimino
.
mapCoord
=
(
mapManager
.
currentTetrimino
.
transform
.
position
-
mapManager
.
tetrisMapCoord
)
/
mapManager
.
tetrisMapSize
;
MM
.
MakeTetriminoRightPlace
(
MM
.
currentTetrimino
);
mapManager
.
SetRoomMapCoord
(
mapManager
.
currentTetrimino
);
for
(
int
i
=
0
;
i
<
MM
.
currentTetrimino
.
rotatedPosition
.
Length
;
i
++)
mapManager
.
MakeTetriminoRightPlace
(
mapManager
.
currentTetrimino
);
for
(
int
i
=
0
;
i
<
mapManager
.
currentTetrimino
.
rotatedPosition
.
Length
;
i
++)
{
{
if
(
Tetrimino
.
rotationInformation
[(
int
)
MM
.
currentTetrimino
.
tetriminoType
].
horizontalLength
[
i
]
+
MM
.
currentTetrimino
.
mapCoord
.
x
>
MapManager
.
width
)
if
(
Tetrimino
.
rotationInformation
[(
int
)
mapManager
.
currentTetrimino
.
tetriminoType
].
horizontalLength
[
i
]
+
mapManager
.
currentTetrimino
.
mapCoord
.
x
>
MapManager
.
width
)
MM
.
currentTetrimino
.
rotatedPosition
[
i
]
=
MapManager
.
width
-
Tetrimino
.
rotationInformation
[(
int
)
MM
.
currentTetrimino
.
tetriminoType
].
horizontalLength
[
i
];
mapManager
.
currentTetrimino
.
rotatedPosition
[
i
]
=
MapManager
.
width
-
Tetrimino
.
rotationInformation
[(
int
)
mapManager
.
currentTetrimino
.
tetriminoType
].
horizontalLength
[
i
];
else
else
MM
.
currentTetrimino
.
rotatedPosition
[
i
]
=
(
int
)
MM
.
currentTetrimino
.
mapCoord
.
x
;
mapManager
.
currentTetrimino
.
rotatedPosition
[
i
]
=
(
int
)
mapManager
.
currentTetrimino
.
mapCoord
.
x
;
}
}
MakeGhost
(
MM
.
currentTetrimino
,
randomTetrimino
);
MakeGhost
(
mapManager
.
currentTetrimino
,
randomTetrimino
);
//MM.controlCurrentTetrimino = true;
//MM.controlCurrentTetrimino = true;
}
}
}
}
...
@@ -60,22 +61,22 @@ public class TetriminoSpawner : MonoBehaviour {
...
@@ -60,22 +61,22 @@ public class TetriminoSpawner : MonoBehaviour {
/// </summary>
/// </summary>
public
void
MakeInitialTetrimino
()
public
void
MakeInitialTetrimino
()
{
{
if
(!
MM
.
gameOver
)
if
(!
mapManager
.
gameOver
)
{
{
int
randomPosition
=
Random
.
Range
(
0
,
MapManager
.
width
);
int
randomPosition
=
Random
.
Range
(
0
,
MapManager
.
width
);
int
randomTetrimino
=
TetriminoRandomizer
();
int
randomTetrimino
=
TetriminoRandomizer
();
MM
.
currentTetrimino
=
Instantiate
(
tetriminoes
[
randomTetrimino
],
MM
.
tetrisMapCoord
+
MM
.
tetrisMapSize
*
new
Vector3
(
randomPosition
,
0
,
MM
.
tetrisMapCoord
.
z
),
Quaternion
.
identity
);
mapManager
.
currentTetrimino
=
Instantiate
(
tetriminoes
[
randomTetrimino
],
mapManager
.
tetrisMapCoord
+
mapManager
.
tetrisMapSize
*
new
Vector3
(
randomPosition
,
0
,
mapManager
.
tetrisMapCoord
.
z
),
Quaternion
.
identity
);
MM
.
startRoom
=
MM
.
currentTetrimino
.
rooms
[
Random
.
Range
(
0
,
MM
.
currentTetrimino
.
rooms
.
Length
)];
mapManager
.
startRoom
=
mapManager
.
currentTetrimino
.
rooms
[
Random
.
Range
(
0
,
mapManager
.
currentTetrimino
.
rooms
.
Length
)];
MM
.
startRoom
.
specialRoomType
=
Room
.
SpecialRoomType
.
Start
;
mapManager
.
startRoom
.
specialRoomType
=
Room
.
SpecialRoomType
.
Start
;
MM
.
currentTetrimino
.
mapCoord
=
(
MM
.
currentTetrimino
.
transform
.
position
-
MM
.
tetrisMapCoord
)
/
MM
.
tetrisMapSize
;
mapManager
.
currentTetrimino
.
mapCoord
=
(
mapManager
.
currentTetrimino
.
transform
.
position
-
mapManager
.
tetrisMapCoord
)
/
mapManager
.
tetrisMapSize
;
MM
.
SetRoomMapCoord
(
MM
.
currentTetrimino
);
mapManager
.
SetRoomMapCoord
(
mapManager
.
currentTetrimino
);
MM
.
MakeTetriminoRightPlace
(
MM
.
currentTetrimino
);
mapManager
.
MakeTetriminoRightPlace
(
mapManager
.
currentTetrimino
);
for
(
int
i
=
0
;
i
<
MM
.
currentTetrimino
.
rooms
.
Length
;
i
++)
for
(
int
i
=
0
;
i
<
mapManager
.
currentTetrimino
.
rooms
.
Length
;
i
++)
{
{
MM
.
currentTetrimino
.
transform
.
position
=
MM
.
currentTetrimino
.
mapCoord
*
MM
.
tetrisMapSize
+
MM
.
tetrisMapCoord
;
mapManager
.
currentTetrimino
.
transform
.
position
=
mapManager
.
currentTetrimino
.
mapCoord
*
mapManager
.
tetrisMapSize
+
mapManager
.
tetrisMapCoord
;
}
}
MM
.
UpdateMap
(
MM
.
currentTetrimino
);
mapManager
.
UpdateMap
(
mapManager
.
currentTetrimino
);
MM
.
CreateRoom
(
MM
.
currentTetrimino
);
mapManager
.
CreateRoom
(
mapManager
.
currentTetrimino
);
MakeTetrimino
();
MakeTetrimino
();
}
}
}
}
...
@@ -85,11 +86,11 @@ public class TetriminoSpawner : MonoBehaviour {
...
@@ -85,11 +86,11 @@ public class TetriminoSpawner : MonoBehaviour {
/// <param name="te">Which tetrimino to make ghost</param>
/// <param name="te">Which tetrimino to make ghost</param>
public
void
MakeGhost
(
Tetrimino
te
,
int
ghostType
)
public
void
MakeGhost
(
Tetrimino
te
,
int
ghostType
)
{
{
MM
.
currentGhost
=
Instantiate
(
ghosts
[
ghostType
],
te
.
transform
.
position
,
Quaternion
.
identity
);
mapManager
.
currentGhost
=
Instantiate
(
ghosts
[
ghostType
],
te
.
transform
.
position
,
Quaternion
.
identity
);
MM
.
currentGhost
.
mapCoord
=
te
.
mapCoord
;
mapManager
.
currentGhost
.
mapCoord
=
te
.
mapCoord
;
for
(
int
i
=
0
;
i
<
te
.
rooms
.
Length
;
i
++)
for
(
int
i
=
0
;
i
<
te
.
rooms
.
Length
;
i
++)
{
{
MM
.
currentGhost
.
rooms
[
i
].
mapCoord
=
te
.
rooms
[
i
].
mapCoord
;
mapManager
.
currentGhost
.
rooms
[
i
].
mapCoord
=
te
.
rooms
[
i
].
mapCoord
;
}
}
}
}
...
@@ -122,7 +123,7 @@ public class TetriminoSpawner : MonoBehaviour {
...
@@ -122,7 +123,7 @@ public class TetriminoSpawner : MonoBehaviour {
* */
* */
private
void
Awake
()
private
void
Awake
()
{
{
MM
=
GameObject
.
Find
(
"MapManager"
).
GetComponent
<
MapManager
>();
mapManager
=
GameObject
.
Find
(
"MapManager"
).
GetComponent
<
MapManager
>();
}
}
// Use this for initialization
// Use this for initialization
void
Start
()
{
void
Start
()
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment