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
ca6197e4
Commit
ca6197e4
authored
Nov 29, 2018
by
18손재민
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
프레스 구현 거의 완료, 한 줄 없어지면 그 위에 줄들 서서히 떨어지는거 구현했음 에러 있는지 찾는 중
parent
21d77371
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
98 additions
and
24 deletions
+98
-24
MapManager.prefab
Assets/Prefabs/MapManager.prefab
+3
-3
MapManager.cs
Assets/Scripts/TetrisMap/MapManager.cs
+93
-20
Test.cs
Assets/Scripts/TetrisMap/Test.cs
+2
-1
No files found.
Assets/Prefabs/MapManager.prefab
View file @
ca6197e4
...
@@ -56,13 +56,13 @@ MonoBehaviour:
...
@@ -56,13 +56,13 @@ MonoBehaviour:
tetrisMapCoord
:
{
x
:
0
,
y
:
0
,
z
:
0
}
tetrisMapCoord
:
{
x
:
0
,
y
:
0
,
z
:
0
}
initialFallSpeed
:
-0.1
initialFallSpeed
:
-0.1
gravity
:
0.98
gravity
:
0.98
collapseTime
:
1
collapseTime
:
1
0
gameOver
:
0
gameOver
:
0
isTetriminoFalling
:
0
isTetriminoFalling
:
0
isRowDeleting
:
0000000000000000000000000000000000000000
spawnBossTetrimino
:
0
spawnBossTetrimino
:
0
tetrisMap
:
{
fileID
:
1320366940629302
,
guid
:
668207ef06c134e40b24375977c2c930
,
type
:
2
}
tetrisMap
:
{
fileID
:
1320366940629302
,
guid
:
668207ef06c134e40b24375977c2c930
,
type
:
2
}
tetrisPress
:
{
fileID
:
1842283105111692
,
guid
:
8e750fd197a05d84c9fb8557eb95c666
,
press
:
{
fileID
:
114990664041074520
,
guid
:
8e750fd197a05d84c9fb8557eb95c666
,
type
:
2
}
type
:
2
}
currentTetrimino
:
{
fileID
:
0
}
currentTetrimino
:
{
fileID
:
0
}
currentGhost
:
{
fileID
:
0
}
currentGhost
:
{
fileID
:
0
}
normalRoomList
:
normalRoomList
:
...
...
Assets/Scripts/TetrisMap/MapManager.cs
View file @
ca6197e4
...
@@ -175,7 +175,7 @@ public class MapManager : MonoBehaviour {
...
@@ -175,7 +175,7 @@ public class MapManager : MonoBehaviour {
}
}
}
}
/// <summary>
/// <summary>
/// Find
and delete full row
s.
/// Find
full rows and create presse
s.
/// </summary>
/// </summary>
public
void
DeleteFullRows
()
public
void
DeleteFullRows
()
{
{
...
@@ -184,8 +184,8 @@ public class MapManager : MonoBehaviour {
...
@@ -184,8 +184,8 @@ public class MapManager : MonoBehaviour {
if
(
IsRowFull
(
y
)
&&
!
isRowDeleting
[
y
])
if
(
IsRowFull
(
y
)
&&
!
isRowDeleting
[
y
])
{
{
isRowDeleting
[
y
]
=
true
;
isRowDeleting
[
y
]
=
true
;
Press
leftPress
=
Instantiate
(
press
,
new
Vector3
(
0
,
y
*
24
,
0
),
Quaternion
.
identity
);
Press
leftPress
=
Instantiate
(
press
,
new
Vector3
(
0
,
y
*
tetrisMapSize
,
0
),
Quaternion
.
identity
);
Press
rightPress
=
Instantiate
(
press
,
new
Vector3
(
240
,
y
*
24
,
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
;
leftPress
.
row
=
y
;
rightPress
.
initialCollapseTime
=
Time
.
time
;
rightPress
.
initialCollapseTime
=
Time
.
time
;
...
@@ -200,6 +200,13 @@ public class MapManager : MonoBehaviour {
...
@@ -200,6 +200,13 @@ public class MapManager : MonoBehaviour {
}
}
}
}
}
}
/// <summary>
/// Extend press than collapse press.
/// </summary>
/// <param name="initialCollapseTime">Initial time that collapse has started.</param>
/// <param name="leftPress">Left press.</param>
/// <param name="rightPress">Right press.</param>
/// <returns></returns>
public
IEnumerator
TetrisPress
(
float
initialCollapseTime
,
Press
leftPress
,
Press
rightPress
)
public
IEnumerator
TetrisPress
(
float
initialCollapseTime
,
Press
leftPress
,
Press
rightPress
)
{
{
while
(
Time
.
time
-
initialCollapseTime
<
collapseTime
)
while
(
Time
.
time
-
initialCollapseTime
<
collapseTime
)
...
@@ -209,12 +216,6 @@ public class MapManager : MonoBehaviour {
...
@@ -209,12 +216,6 @@ 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
);
}
}
while
(
leftPress
.
transform
.
localScale
.
x
>
1
)
{
yield
return
new
WaitForSeconds
(
0.01f
);
leftPress
.
transform
.
localScale
-=
new
Vector3
(
5
,
0
,
0
);
rightPress
.
transform
.
localScale
-=
new
Vector3
(-
5
,
0
,
0
);
}
int
row
=
leftPress
.
GetComponent
<
Press
>().
row
;
int
row
=
leftPress
.
GetComponent
<
Press
>().
row
;
for
(
int
x
=
0
;
x
<
width
;
x
++)
for
(
int
x
=
0
;
x
<
width
;
x
++)
{
{
...
@@ -222,12 +223,20 @@ public class MapManager : MonoBehaviour {
...
@@ -222,12 +223,20 @@ public class MapManager : MonoBehaviour {
mapGrid
[
x
,
row
]
=
null
;
mapGrid
[
x
,
row
]
=
null
;
}
}
isRowDeleting
[
row
]
=
false
;
isRowDeleting
[
row
]
=
false
;
DecreaseRowsAbove
(
row
);
while
(
leftPress
.
transform
.
localScale
.
x
>
1
)
{
yield
return
new
WaitForSeconds
(
0.01f
);
leftPress
.
transform
.
localScale
-=
new
Vector3
(
3
,
0
,
0
);
rightPress
.
transform
.
localScale
-=
new
Vector3
(-
3
,
0
,
0
);
}
StartCoroutine
(
DecreaseYCoord
(
row
+
1
));
//DecreaseRowsAbove(row);
Destroy
(
leftPress
.
gameObject
);
Destroy
(
leftPress
.
gameObject
);
Destroy
(
rightPress
.
gameObject
);
Destroy
(
rightPress
.
gameObject
);
}
}
/// <summary>
/// <summary>
/// Decrease all rows above this row.
/// Decrease all rows above this row.
/// This only changes mapCoord.
/// </summary>
/// </summary>
/// <param name="row">Row that will be underneath.</param>
/// <param name="row">Row that will be underneath.</param>
public
void
DecreaseRowsAbove
(
int
row
)
public
void
DecreaseRowsAbove
(
int
row
)
...
@@ -241,7 +250,10 @@ public class MapManager : MonoBehaviour {
...
@@ -241,7 +250,10 @@ public class MapManager : MonoBehaviour {
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
);
//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
);
}
}
}
}
...
@@ -252,11 +264,56 @@ public class MapManager : MonoBehaviour {
...
@@ -252,11 +264,56 @@ public class MapManager : MonoBehaviour {
if
(
child
.
row
>
row
)
if
(
child
.
row
>
row
)
{
{
child
.
row
-=
1
;
child
.
row
-=
1
;
child
.
transform
.
position
+=
new
Vector3
(
0
,
-
24
,
0
);
child
.
transform
.
position
+=
new
Vector3
(
0
,
-
tetrisMapSize
,
0
);
}
}
}
/// <summary>
/// Set all rooms' mapCoord above ths row to tetrisYCoord.
/// </summary>
/// <param name="row">Row that will be underneath</param>
public
void
SetRoomsYCoord
(
int
row
)
{
for
(
int
y
=
row
;
y
<
realHeight
;
y
++)
{
for
(
int
x
=
0
;
x
<
width
;
x
++)
{
if
(
mapGrid
[
x
,
y
]
!=
null
&&
mapGrid
[
x
,
y
].
transform
.
parent
)
{
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
);
}
}
}
}
}
}
}
/// <summary>
/// <summary>
/// Decreae all tetrisYCoord abobe this row.
/// </summary>
/// <param name="y">Row that will be underneath.</param>
/// <returns></returns>
public
IEnumerator
DecreaseYCoord
(
int
y
)
{
float
yInitialTime
=
Time
.
time
;
float
yFallTime
=
0
,
yFallSpeed
=
0
;
while
(
tetrisYCoord
[
y
]
>
(
y
-
1
)
*
tetrisMapSize
)
{
yield
return
new
WaitForSeconds
(
0.01f
);
yFallTime
=
Time
.
time
-
yInitialTime
;
yFallSpeed
+=
gravity
*
yFallTime
*
yFallTime
;
for
(
int
i
=
y
;
i
<
realHeight
;
i
++)
{
tetrisYCoord
[
i
]
-=
yFallSpeed
;
}
SetRoomsYCoord
(
y
);
}
for
(
int
i
=
y
;
i
<
height
;
i
++)
{
tetrisYCoord
[
i
]
=
i
*
tetrisMapSize
;
}
DecreaseRowsAbove
(
y
);
}
/// <summary>
/// Check row if it is full.
/// Check row if it is full.
/// </summary>
/// </summary>
/// <param name="row">Row you want to check.</param>
/// <param name="row">Row you want to check.</param>
...
@@ -403,6 +460,7 @@ public class MapManager : MonoBehaviour {
...
@@ -403,6 +460,7 @@ 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);
}
}
...
@@ -422,7 +480,7 @@ public class MapManager : MonoBehaviour {
...
@@ -422,7 +480,7 @@ public class MapManager : MonoBehaviour {
isTetriminoFalling
=
false
;
isTetriminoFalling
=
false
;
}
}
/// <summary>
/// <summary>
/// Get tetrimino down.
/// Get tetrimino
's position
down.
/// </summary>
/// </summary>
/// <param name="te">Which tetrimino to move.</param>
/// <param name="te">Which tetrimino to move.</param>
public
IEnumerator
TetriminoDown
(
Tetrimino
te
)
public
IEnumerator
TetriminoDown
(
Tetrimino
te
)
...
@@ -439,7 +497,7 @@ public class MapManager : MonoBehaviour {
...
@@ -439,7 +497,7 @@ public class MapManager : MonoBehaviour {
EndTetrimino
(
currentTetrimino
);
EndTetrimino
(
currentTetrimino
);
}
}
/// <summary>
/// <summary>
/// Get ghost down.
/// Get ghost
's position
down.
/// </summary>
/// </summary>
/// <param name="ghost">Which ghost to move.</param>
/// <param name="ghost">Which ghost to move.</param>
/// <param name="te">Which tetrimino you'd like to sink with ghost.</param>
/// <param name="te">Which tetrimino you'd like to sink with ghost.</param>
...
@@ -494,6 +552,10 @@ public class MapManager : MonoBehaviour {
...
@@ -494,6 +552,10 @@ public class MapManager : MonoBehaviour {
TetriminoRotate
(
currentTetrimino
,
-
1
);
TetriminoRotate
(
currentTetrimino
,
-
1
);
}
}
}
}
/// <summary>
/// Set rooms' mapCoord on this tetrimino.
/// </summary>
/// <param name="te">Tetrimino you want to set rooms' mapCoord.</param>
public
void
SetRoomMapCoord
(
Tetrimino
te
)
public
void
SetRoomMapCoord
(
Tetrimino
te
)
{
{
for
(
int
i
=
0
;
i
<
te
.
rooms
.
Length
;
i
++)
for
(
int
i
=
0
;
i
<
te
.
rooms
.
Length
;
i
++)
...
@@ -501,6 +563,10 @@ public class MapManager : MonoBehaviour {
...
@@ -501,6 +563,10 @@ public class MapManager : MonoBehaviour {
te
.
rooms
[
i
].
mapCoord
=
te
.
mapCoord
+
(
te
.
rooms
[
i
].
transform
.
localPosition
/
tetrisMapSize
);
te
.
rooms
[
i
].
mapCoord
=
te
.
mapCoord
+
(
te
.
rooms
[
i
].
transform
.
localPosition
/
tetrisMapSize
);
}
}
}
}
/// <summary>
/// Create rooms player will move.
/// </summary>
/// <param name="te">Tetrimino you want to create rooms.</param>
public
void
CreateRoom
(
Tetrimino
te
)
public
void
CreateRoom
(
Tetrimino
te
)
{
{
for
(
int
i
=
0
;
i
<
te
.
rooms
.
Length
;
i
++)
for
(
int
i
=
0
;
i
<
te
.
rooms
.
Length
;
i
++)
...
@@ -523,6 +589,13 @@ public class MapManager : MonoBehaviour {
...
@@ -523,6 +589,13 @@ public class MapManager : MonoBehaviour {
{
{
}*/
}*/
/// <summary>
/// Shake the camera when tetrimino has fallen.
/// </summary>
/// <param name="_amount">Amount you want to shake the camera.</param>
/// <param name="originPos">Original position of the camera.</param>
/// <param name="camera">Camera you want to shake.</param>
/// <returns></returns>
public
IEnumerator
Shake
(
float
_amount
,
Vector3
originPos
,
GameObject
camera
)
public
IEnumerator
Shake
(
float
_amount
,
Vector3
originPos
,
GameObject
camera
)
{
{
float
amount
=
_amount
;
float
amount
=
_amount
;
...
@@ -553,7 +626,7 @@ public class MapManager : MonoBehaviour {
...
@@ -553,7 +626,7 @@ public class MapManager : MonoBehaviour {
Tetrimino
.
rotationInformation
[
7
].
horizontalLength
=
new
int
[
4
]
{
1
,
1
,
1
,
1
};
//Boss
Tetrimino
.
rotationInformation
[
7
].
horizontalLength
=
new
int
[
4
]
{
1
,
1
,
1
,
1
};
//Boss
for
(
int
i
=
0
;
i
<
tetrisYCoord
.
Length
;
i
++)
for
(
int
i
=
0
;
i
<
tetrisYCoord
.
Length
;
i
++)
{
{
tetrisYCoord
[
i
]
=
i
*
24
;
tetrisYCoord
[
i
]
=
i
*
tetrisMapSize
;
}
}
TS
=
GameObject
.
Find
(
"TetriminoSpawner"
).
GetComponent
<
TetriminoSpawner
>();
TS
=
GameObject
.
Find
(
"TetriminoSpawner"
).
GetComponent
<
TetriminoSpawner
>();
}
}
...
@@ -571,12 +644,12 @@ public class MapManager : MonoBehaviour {
...
@@ -571,12 +644,12 @@ public class MapManager : MonoBehaviour {
TetriminoControl
(
currentTetrimino
);
TetriminoControl
(
currentTetrimino
);
if
(!
isTetriminoFalling
)
if
(!
isTetriminoFalling
)
currentTetrimino
.
transform
.
position
=
new
Vector3
(
currentTetrimino
.
mapCoord
.
x
*
tetrisMapSize
,
tetrisYCoord
[(
int
)
currentTetrimino
.
mapCoord
.
y
],
currentTetrimino
.
mapCoord
.
z
*
tetrisMapSize
);
currentTetrimino
.
transform
.
position
=
new
Vector3
(
currentTetrimino
.
mapCoord
.
x
*
tetrisMapSize
,
tetrisYCoord
[(
int
)
currentTetrimino
.
mapCoord
.
y
],
currentTetrimino
.
mapCoord
.
z
*
tetrisMapSize
);
}
if
(
currentGhost
!=
null
)
if
(
currentGhost
!=
null
)
{
{
GhostControl
(
currentGhost
,
currentTetrimino
);
GhostControl
(
currentGhost
,
currentTetrimino
);
currentGhost
.
transform
.
position
=
new
Vector3
(
currentGhost
.
mapCoord
.
x
*
tetrisMapSize
,
tetrisYCoord
[(
int
)
currentGhost
.
mapCoord
.
y
],
currentGhost
.
mapCoord
.
z
*
tetrisMapSize
);
currentGhost
.
transform
.
position
=
new
Vector3
(
currentGhost
.
mapCoord
.
x
*
tetrisMapSize
,
tetrisYCoord
[(
int
)
currentGhost
.
mapCoord
.
y
],
currentGhost
.
mapCoord
.
z
*
tetrisMapSize
);
}
}
}
//currentTetrimino.transform.position = currentTetrimino.mapCoord * tetrisMapSize + tetrisMapCoord;
//currentTetrimino.transform.position = currentTetrimino.mapCoord * tetrisMapSize + tetrisMapCoord;
}
}
...
...
Assets/Scripts/TetrisMap/Test.cs
View file @
ca6197e4
...
@@ -6,7 +6,8 @@ public class Test : MonoBehaviour {
...
@@ -6,7 +6,8 @@ public class Test : MonoBehaviour {
MapManager
MM
;
MapManager
MM
;
TetriminoSpawner
TS
;
TetriminoSpawner
TS
;
public
static
Vector3
tetrisCameraCoord
=
new
Vector3
(
180
,
240
,
-
1
);
public
static
Vector3
tetrisCameraCoord
=
new
Vector3
(
180
,
0
,
-
1
);
public
static
float
tetrisMapSize
=
300
;
public
static
float
tetrisMapSize
=
300
;
public
void
ChangeTetrimino
()
public
void
ChangeTetrimino
()
...
...
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