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
1215823d
Commit
1215823d
authored
Jan 01, 2019
by
18손재민
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
타이머 구현함 이제 시간 지나면 테트리미노 떨어짐
parent
ed5a2e58
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
39 additions
and
17 deletions
+39
-17
MapManager.cs
Assets/Scripts/TetrisMap/MapManager.cs
+17
-3
Test.cs
Assets/Scripts/TetrisMap/Test.cs
+20
-13
TetriminoSpawner.cs
Assets/Scripts/TetrisMap/TetriminoSpawner.cs
+2
-1
No files found.
Assets/Scripts/TetrisMap/MapManager.cs
View file @
1215823d
...
...
@@ -33,6 +33,15 @@ public class MapManager : MonoBehaviour {
/// Tetrimino falling gravity.
/// </summary>
public
float
gravity
=
0.98f
;
public
float
timeToFallTetrimino
=
100.0f
;
/// <summary>
/// Time tetris waits to fall.
/// </summary>
public
float
tetriminoWaitedTime
;
/// <summary>
/// Time tetris has created.
/// </summary>
public
float
tetriminoCreatedTime
;
/// <summary>
/// Time Tetrimino has fallen.
/// </summary>
...
...
@@ -391,9 +400,13 @@ public class MapManager : MonoBehaviour {
/// Display how much time is it remain to fall current tetrimino.
/// </summary>
/// <returns></returns>
public
IEnumerator
Display
Time
()
public
IEnumerator
CountTetriminoWaiting
Time
()
{
yield
return
null
;
while
(!
isTetriminoFalling
)
{
yield
return
new
WaitForSeconds
(
0.1f
);
tetriminoWaitedTime
=
Time
.
time
-
tetriminoCreatedTime
;
}
}
/// <summary>
/// Move tetrimino horizontally.
...
...
@@ -514,6 +527,7 @@ public class MapManager : MonoBehaviour {
{
te
.
transform
.
position
=
new
Vector3
(
te
.
mapCoord
.
x
*
tetrisMapSize
,
tetrisYCoord
[(
int
)
te
.
mapCoord
.
y
],
te
.
mapCoord
.
z
*
tetrisMapSize
);
fallSpeed
=
initialFallSpeed
;
tetriminoWaitedTime
=
0
;
UpdateMap
(
te
);
CreateRoom
(
te
);
DeleteFullRows
();
...
...
@@ -565,7 +579,7 @@ public class MapManager : MonoBehaviour {
/// <param name="te">Tetrimino you want to move.</param>
public
void
TetriminoControl
(
Tetrimino
te
)
{
if
(
Input
.
GetKeyDown
(
KeyCode
.
Space
)
&&
GameManager
.
gameState
==
GameManager
.
GameState
.
Tetris
)
if
(
(
Input
.
GetKeyDown
(
KeyCode
.
Space
)
&&
GameManager
.
gameState
==
GameManager
.
GameState
.
Tetris
)
||
tetriminoWaitedTime
>
timeToFallTetrimino
)
{
isTetriminoFalling
=
true
;
TetriminoMapCoordDown
(
currentTetrimino
);
...
...
Assets/Scripts/TetrisMap/Test.cs
View file @
1215823d
using
System.Collections
;
using
System.Collections.Generic
;
using
UnityEngine
;
using
UnityEngine.UI
;
public
class
Test
:
MonoBehaviour
{
MapManager
MM
;
TetriminoSpawner
TS
;
public
static
Vector3
tetrisCameraCoord
=
new
Vector3
(
180
,
0
,
-
1
);
MapManager
mapManager
;
TetriminoSpawner
tetriminoSpawner
;
public
static
Vector3
tetrisCameraCoord
=
new
Vector3
(
180
,
0
,
-
1
);
public
static
float
tetrisMapSize
=
300
;
public
Text
timer
;
public
void
ChangeTetrimino
()
{
Destroy
(
MM
.
currentTetrimino
.
gameObject
);
Destroy
(
MM
.
currentGhost
.
gameObject
);
TS
.
MakeTetrimino
();
Destroy
(
mapManager
.
currentTetrimino
.
gameObject
);
Destroy
(
mapManager
.
currentGhost
.
gameObject
);
tetriminoSpawner
.
MakeTetrimino
();
}
public
void
SpawnBossTetrimino
()
{
MM
.
spawnBossTetrimino
=
true
;
mapManager
.
spawnBossTetrimino
=
true
;
}
public
void
Gold
()
{
MM
.
UpgradeRoom
(
MapManager
.
SpecialRoomType
.
Gold
);
mapManager
.
UpgradeRoom
(
MapManager
.
SpecialRoomType
.
Gold
);
}
public
void
Amethyst
()
{
MM
.
UpgradeRoom
(
MapManager
.
SpecialRoomType
.
Amethyst
);
mapManager
.
UpgradeRoom
(
MapManager
.
SpecialRoomType
.
Amethyst
);
}
public
void
BothSide
()
{
MM
.
UpgradeRoom
(
MapManager
.
SpecialRoomType
.
BothSide
);
mapManager
.
UpgradeRoom
(
MapManager
.
SpecialRoomType
.
BothSide
);
}
public
void
Boss
()
{
SpawnBossTetrimino
();
}
public
void
Timer
()
{
timer
.
text
=
(
mapManager
.
timeToFallTetrimino
-
mapManager
.
tetriminoWaitedTime
).
ToString
();
}
private
void
Awake
()
{
MM
=
GameObject
.
Find
(
"MapManager"
).
GetComponent
<
MapManager
>();
TS
=
GameObject
.
Find
(
"TetriminoSpawner"
).
GetComponent
<
TetriminoSpawner
>();
mapManager
=
GameObject
.
Find
(
"MapManager"
).
GetComponent
<
MapManager
>();
tetriminoSpawner
=
GameObject
.
Find
(
"TetriminoSpawner"
).
GetComponent
<
TetriminoSpawner
>();
}
// Use this for initialization
void
Start
()
{
...
...
@@ -53,6 +58,8 @@ public class Test : MonoBehaviour {
ChangeTetrimino
();
if
(
Input
.
GetKeyDown
(
KeyCode
.
Alpha2
))
SpawnBossTetrimino
();
if
(!
mapManager
.
isTetriminoFalling
)
Timer
();
/*if (Input.GetKeyDown(KeyCode.Tab) && GameManager.gameState != GameManager.GameState.Tetris)
{
GameManager.gameState = GameManager.GameState.Tetris;
...
...
Assets/Scripts/TetrisMap/TetriminoSpawner.cs
View file @
1215823d
...
...
@@ -54,11 +54,12 @@ public class TetriminoSpawner : MonoBehaviour {
}
MakeGhost
(
mapManager
.
currentTetrimino
,
randomTetrimino
);
mapManager
.
isTetriminoFalling
=
false
;
Debug
.
Log
(
mapManager
.
roomsWaiting
.
Count
);
while
(
mapManager
.
roomsWaiting
.
Count
!=
0
&&
mapManager
.
currentTetrimino
.
notNormalRoomCount
<
4
)
{
mapManager
.
UpgradeRoom
(
mapManager
.
roomsWaiting
.
Dequeue
());
}
mapManager
.
tetriminoCreatedTime
=
Time
.
time
;
StartCoroutine
(
mapManager
.
CountTetriminoWaitingTime
());
}
}
/// <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