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
9cf3e145
Commit
9cf3e145
authored
Nov 18, 2018
by
18손재민
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
테트리미노 드랍 기능 수정중
parent
93a18e68
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
46 additions
and
21 deletions
+46
-21
MapManager.cs
Assets/Scripts/TetrisMap/MapManager.cs
+45
-20
Test.cs
Assets/Scripts/TetrisMap/Test.cs
+1
-0
TetriminoSpawner.cs
Assets/Scripts/TetrisMap/TetriminoSpawner.cs
+0
-1
No files found.
Assets/Scripts/TetrisMap/MapManager.cs
View file @
9cf3e145
...
@@ -36,14 +36,18 @@ public class MapManager : MonoBehaviour {
...
@@ -36,14 +36,18 @@ public class MapManager : MonoBehaviour {
/// </summary>
/// </summary>
public
static
Room
[,]
mapGrid
=
new
Room
[
width
,
height
];
public
static
Room
[,]
mapGrid
=
new
Room
[
width
,
height
];
/// <summary>
/// <summary>
/// Tetris Y axis coordinates on Unity.
/// </summary>
public
static
float
[]
tetrisYCoord
=
new
float
[
height
];
/// <summary>
/// Current state of game.
/// Current state of game.
/// </summary>
/// </summary>
public
bool
gameOver
=
false
;
public
bool
gameOver
=
false
;
/// <summary>
/// <summary>
/// Check if tetrimino is falling.
/// </summary>
public
bool
isTetriminoFalling
=
false
;
/// <summary>
/// Tetris Y axis coordinates on Unity.
/// </summary>
public
static
float
[]
tetrisYCoord
=
new
float
[
height
];
/// <summary>
/// Choose to make a boss tetrimino or not.
/// Choose to make a boss tetrimino or not.
/// </summary>
/// </summary>
public
bool
spawnBossTetrimino
=
false
;
public
bool
spawnBossTetrimino
=
false
;
...
@@ -213,7 +217,14 @@ public class MapManager : MonoBehaviour {
...
@@ -213,7 +217,14 @@ public class MapManager : MonoBehaviour {
{
{
for
(
int
i
=
0
;
i
<
te
.
rooms
.
Length
;
i
++)
for
(
int
i
=
0
;
i
<
te
.
rooms
.
Length
;
i
++)
{
{
if
((
int
)
te
.
rooms
[
i
].
mapCoord
.
y
>
19
)
{
gameOver
=
true
;
Debug
.
Log
(
"Game Over"
);
return
;
}
mapGrid
[(
int
)
te
.
rooms
[
i
].
mapCoord
.
x
,
(
int
)
te
.
rooms
[
i
].
mapCoord
.
y
]
=
te
.
rooms
[
i
];
mapGrid
[(
int
)
te
.
rooms
[
i
].
mapCoord
.
x
,
(
int
)
te
.
rooms
[
i
].
mapCoord
.
y
]
=
te
.
rooms
[
i
];
}
}
}
}
/// <summary>
/// <summary>
...
@@ -337,18 +348,23 @@ public class MapManager : MonoBehaviour {
...
@@ -337,18 +348,23 @@ public class MapManager : MonoBehaviour {
MoveTetriminoMapCoord
(
te
,
new
Vector3
(
0
,
-
1
,
0
));
MoveTetriminoMapCoord
(
te
,
new
Vector3
(
0
,
-
1
,
0
));
}
}
MoveTetriminoMapCoord
(
te
,
new
Vector3
(
0
,
1
,
0
));
MoveTetriminoMapCoord
(
te
,
new
Vector3
(
0
,
1
,
0
));
i
f
(
te
==
currentTetrimino
)
i
sTetriminoFalling
=
true
;
EndTetrimino
(
currentTetrimino
);
StartCoroutine
(
TetriminoDown
(
te
)
);
//
StartCoroutine(TetriminoDown(te)
);
//
EndTetrimino(currentTetrimino
);
}
}
/// <summary>
/// End tetrimino's falling and make rooms and new tetrimino.
/// </summary>
/// <param name="te">Tetrimino you want to end.</param>
public
void
EndTetrimino
(
Tetrimino
te
)
public
void
EndTetrimino
(
Tetrimino
te
)
{
{
currentTetrimino
.
transform
.
position
=
new
Vector3
(
currentTetrimino
.
mapCoord
.
x
*
tetrisMapSize
,
tetrisYCoord
[(
int
)
currentTetrimino
.
mapCoord
.
y
],
currentTetrimino
.
mapCoord
.
z
*
tetrisMapSize
);
te
.
transform
.
position
=
new
Vector3
(
te
.
mapCoord
.
x
*
tetrisMapSize
,
tetrisYCoord
[(
int
)
te
.
mapCoord
.
y
],
te
.
mapCoord
.
z
*
tetrisMapSize
);
UpdateMap
(
te
);
UpdateMap
(
te
);
CreateRoom
(
currentTetrimino
);
CreateRoom
(
te
);
DeleteFullRows
();
DeleteFullRows
();
Destroy
(
currentGhost
.
gameObject
);
Destroy
(
currentGhost
.
gameObject
);
TS
.
MakeTetrimino
();
TS
.
MakeTetrimino
();
isTetriminoFalling
=
false
;
}
}
/// <summary>
/// <summary>
/// Get tetrimino down.
/// Get tetrimino down.
...
@@ -356,18 +372,19 @@ public class MapManager : MonoBehaviour {
...
@@ -356,18 +372,19 @@ public class MapManager : MonoBehaviour {
/// <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
)
{
{
while
(
t
rue
)
while
(
t
e
.
transform
.
position
.
y
>
tetrisYCoord
[(
int
)
te
.
mapCoord
.
y
]
)
{
{
if
(
currentTetrimino
)
yield
return
new
WaitForSeconds
(
0.2f
);
yield
return
null
;
te
.
transform
.
position
+=
new
Vector3
(
0
,
-
24
,
0
)
;
}
}
EndTetrimino
(
currentTetrimino
);
}
}
/// <summary>
/// <summary>
/// Get ghost down.
/// Get ghost 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>
public
void
Ghost
Down
(
Tetrimino
ghost
,
Tetrimino
te
)
public
void
Ghost
Control
(
Tetrimino
ghost
,
Tetrimino
te
)
{
{
/*if(ghost.rotatedAngle != te.rotatedAngle)
/*if(ghost.rotatedAngle != te.rotatedAngle)
TetriminoRotate(ghost, te.rotatedAngle - ghost.rotatedAngle);*/
TetriminoRotate(ghost, te.rotatedAngle - ghost.rotatedAngle);*/
...
@@ -377,7 +394,6 @@ public class MapManager : MonoBehaviour {
...
@@ -377,7 +394,6 @@ public class MapManager : MonoBehaviour {
currentGhost
.
rooms
[
i
].
mapCoord
=
currentTetrimino
.
rooms
[
i
].
mapCoord
;
currentGhost
.
rooms
[
i
].
mapCoord
=
currentTetrimino
.
rooms
[
i
].
mapCoord
;
currentGhost
.
rooms
[
i
].
transform
.
position
=
(
currentGhost
.
rooms
[
i
].
mapCoord
-
currentGhost
.
mapCoord
)
*
tetrisMapSize
+
currentGhost
.
transform
.
position
;
currentGhost
.
rooms
[
i
].
transform
.
position
=
(
currentGhost
.
rooms
[
i
].
mapCoord
-
currentGhost
.
mapCoord
)
*
tetrisMapSize
+
currentGhost
.
transform
.
position
;
}
}
while
(
IsRightGhost
(
ghost
))
while
(
IsRightGhost
(
ghost
))
{
{
MoveTetriminoMapCoord
(
ghost
,
new
Vector3
(
0
,
-
1
,
0
));
MoveTetriminoMapCoord
(
ghost
,
new
Vector3
(
0
,
-
1
,
0
));
...
@@ -397,6 +413,7 @@ public class MapManager : MonoBehaviour {
...
@@ -397,6 +413,7 @@ public class MapManager : MonoBehaviour {
{
{
if
(
Input
.
GetKeyDown
(
KeyCode
.
Space
)
&&
GameManager
.
gameState
==
GameManager
.
GameState
.
Tetris
)
if
(
Input
.
GetKeyDown
(
KeyCode
.
Space
)
&&
GameManager
.
gameState
==
GameManager
.
GameState
.
Tetris
)
{
{
isTetriminoFalling
=
true
;
TetriminoMapCoordDown
(
currentTetrimino
);
TetriminoMapCoordDown
(
currentTetrimino
);
//StartCoroutine(TetriminoDown(currentTetrimino));
//StartCoroutine(TetriminoDown(currentTetrimino));
}
}
...
@@ -473,13 +490,21 @@ public class MapManager : MonoBehaviour {
...
@@ -473,13 +490,21 @@ public class MapManager : MonoBehaviour {
// Update is called once per frame
// Update is called once per frame
void
Update
()
{
void
Update
()
{
if
(!
gameOver
)
{
if
(!
isTetriminoFalling
)
{
TetriminoControl
(
currentTetrimino
);
TetriminoControl
(
currentTetrimino
);
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
)
{
{
GhostDown
(
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 @
9cf3e145
...
@@ -12,6 +12,7 @@ public class Test : MonoBehaviour {
...
@@ -12,6 +12,7 @@ public class Test : MonoBehaviour {
public
void
ChangeTetrimino
()
public
void
ChangeTetrimino
()
{
{
Destroy
(
MM
.
currentTetrimino
.
gameObject
);
Destroy
(
MM
.
currentTetrimino
.
gameObject
);
Destroy
(
MM
.
currentGhost
.
gameObject
);
TS
.
MakeTetrimino
();
TS
.
MakeTetrimino
();
}
}
public
void
SpawnBossTetrimino
()
public
void
SpawnBossTetrimino
()
...
...
Assets/Scripts/TetrisMap/TetriminoSpawner.cs
View file @
9cf3e145
...
@@ -91,7 +91,6 @@ public class TetriminoSpawner : MonoBehaviour {
...
@@ -91,7 +91,6 @@ public class TetriminoSpawner : MonoBehaviour {
{
{
MM
.
currentGhost
.
rooms
[
i
].
mapCoord
=
te
.
rooms
[
i
].
mapCoord
;
MM
.
currentGhost
.
rooms
[
i
].
mapCoord
=
te
.
rooms
[
i
].
mapCoord
;
}
}
MM
.
TetriminoMapCoordDown
(
MM
.
currentGhost
);
}
}
/// <summary>
/// <summary>
...
...
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