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
ed5a2e58
Commit
ed5a2e58
authored
Dec 04, 2018
by
18손재민
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
방 업그레이드 구현 중
parent
d00ff497
Changes
6
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
748 additions
and
1567 deletions
+748
-1567
Room Amethyst.prefab
Assets/Prefabs/Rooms/SpecialRoom/Room Amethyst.prefab
+636
-1538
MapManager.cs
Assets/Scripts/TetrisMap/MapManager.cs
+86
-22
Room.cs
Assets/Scripts/TetrisMap/Room.cs
+1
-5
Test.cs
Assets/Scripts/TetrisMap/Test.cs
+16
-0
Tetrimino.cs
Assets/Scripts/TetrisMap/Tetrimino.cs
+2
-0
TetriminoSpawner.cs
Assets/Scripts/TetrisMap/TetriminoSpawner.cs
+7
-2
No files found.
Assets/Prefabs/Rooms/SpecialRoom/Room Amethyst.prefab
View file @
ed5a2e58
This diff is collapsed.
Click to expand it.
Assets/Scripts/TetrisMap/MapManager.cs
View file @
ed5a2e58
...
...
@@ -46,7 +46,7 @@ public class MapManager : MonoBehaviour {
/// </summary>
public
float
collapseTime
;
public
static
int
height
=
24
,
width
=
10
,
realHeight
=
height
-
5
;
public
const
int
height
=
24
,
width
=
10
,
realHeight
=
19
;
/// <summary>
/// Absolute coordinates on tetris map.
...
...
@@ -63,11 +63,15 @@ public class MapManager : MonoBehaviour {
/// <summary>
/// Check if this row is being deleted.
/// </summary>
p
ubl
ic
bool
[]
isRowDeleting
=
new
bool
[
20
];
p
rivate
stat
ic
bool
[]
isRowDeleting
=
new
bool
[
20
];
/// <summary>
/// Tetris Y axis coordinates on Unity.
/// </summary>
public
float
[]
tetrisYCoord
=
new
float
[
height
];
private
static
float
[]
tetrisYCoord
=
new
float
[
height
];
/// <summary>
/// Array that saves presses.
/// </summary>
public
Press
[]
presses
=
new
Press
[
realHeight
];
/// <summary>
/// Choose to make a boss tetrimino or not.
/// </summary>
...
...
@@ -89,6 +93,10 @@ public class MapManager : MonoBehaviour {
/// </summary>
public
Tetrimino
currentGhost
;
/// <summary>
/// Enum for special room types.
/// </summary>
public
enum
SpecialRoomType
{
Start
,
Item
,
BothSide
,
Gold
,
Amethyst
,
Boss
,
Normal
};
/// <summary>
/// List for the normal Room candidates.
/// </summary>
public
RoomInGame
[]
normalRoomList
;
...
...
@@ -97,11 +105,14 @@ public class MapManager : MonoBehaviour {
/// </summary>
public RoomInGame[] itemRoomList;*/
/// <summary>
///
List
for the special Room candidates.
///
Array
for the special Room candidates.
/// </summary>
public
RoomInGame
[]
specialRoomList
;
public
bool
controlCurrentTetrimino
=
false
;
public
Room
startRoom
;
/// <summary>
/// Queue that saves rooms waiting for upgrade tetrimino.
/// </summary>
public
Queue
<
SpecialRoomType
>
roomsWaiting
=
new
Queue
<
SpecialRoomType
>();
/*
* functions
...
...
@@ -185,6 +196,7 @@ public class MapManager : MonoBehaviour {
leftPress
.
row
=
y
;
leftPress
.
bottomRow
=
y
;
leftPress
.
createdOrder
=
order
;
presses
[
y
]
=
leftPress
;
simultaneousPress
.
Add
(
leftPress
);
StartCoroutine
(
TetrisPress
(
leftPress
.
initialCollapseTime
,
leftPress
,
rightPress
));
order
++;
...
...
@@ -213,12 +225,12 @@ public class MapManager : MonoBehaviour {
rightPress
.
transform
.
localScale
=
new
Vector3
(-
collapseRate
*
20
,
1
,
1
);
}
int
row
=
leftPress
.
row
;
Press
[]
presses
=
FindObjectsOfType
<
Press
>();
foreach
(
Press
child
in
presses
)
for
(
int
i
=
row
+
1
;
i
<
realHeight
;
i
++)
{
if
(
child
.
isLeft
&&
child
.
row
>
row
)
if
(
isRowDeleting
[
i
]
)
{
child
.
bottomRow
-=
1
;
presses
[
i
].
bottomRow
=
leftPress
.
bottomRow
+
i
-
row
-
1
;
break
;
}
}
for
(
int
x
=
0
;
x
<
width
;
x
++)
...
...
@@ -237,6 +249,8 @@ public class MapManager : MonoBehaviour {
{
StartCoroutine
(
DecreaseYCoord
(
row
,
leftPress
.
bottomRow
));
}
presses
[
row
]
=
null
;
UpgradeRoom
(
SpecialRoomType
.
Item
);
Destroy
(
leftPress
.
gameObject
);
Destroy
(
rightPress
.
gameObject
);
}
...
...
@@ -294,6 +308,7 @@ public class MapManager : MonoBehaviour {
float
yInitialTime
=
Time
.
time
;
float
yFallTime
=
0
,
yFallSpeed
=
0
;
int
row
=
0
;
bool
shakeCamera
=
true
;
for
(
int
i
=
0
;
i
<
realHeight
;
i
++)
{
if
(
IsRowEmpty
(
i
))
...
...
@@ -306,7 +321,10 @@ public class MapManager : MonoBehaviour {
{
yield
return
new
WaitForSeconds
(
0.01f
);
if
(
isRowDeleting
[
top
+
1
])
{
shakeCamera
=
false
;
break
;
}
yFallTime
=
Time
.
time
-
yInitialTime
;
yFallSpeed
+=
gravity
*
yFallTime
*
yFallTime
;
for
(
int
i
=
row
;
!
isRowDeleting
[
i
]
&&
i
<
realHeight
;
i
++)
...
...
@@ -316,6 +334,11 @@ public class MapManager : MonoBehaviour {
}
SetRoomsYCoord
();
}
if
(
shakeCamera
)
{
GameObject
camera
=
GameObject
.
Find
(
"Tetris Camera"
);
StartCoroutine
(
CameraShake
(
5
*
(
top
-
bottom
+
1
),
camera
.
transform
.
position
,
camera
));
}
for
(
int
i
=
0
;
i
<
height
;
i
++)
{
tetrisYCoord
[
i
]
=
i
*
tetrisMapSize
;
...
...
@@ -330,7 +353,7 @@ public class MapManager : MonoBehaviour {
public
static
bool
IsRowFull
(
int
row
)
{
for
(
int
x
=
0
;
x
<
width
;
x
++)
if
(
mapGrid
[
x
,
row
]
==
null
||
mapGrid
[
x
,
row
].
specialRoomType
==
Room
.
SpecialRoomType
.
Boss
)
if
(
mapGrid
[
x
,
row
]
==
null
||
mapGrid
[
x
,
row
].
specialRoomType
==
SpecialRoomType
.
Boss
)
return
false
;
return
true
;
}
...
...
@@ -479,7 +502,6 @@ public class MapManager : MonoBehaviour {
MoveTetriminoMapCoord
(
te
,
new
Vector3
(
0
,
-
1
,
0
));
}
MoveTetriminoMapCoord
(
te
,
new
Vector3
(
0
,
1
,
0
));
isTetriminoFalling
=
true
;
initialFallTime
=
Time
.
time
;
StartCoroutine
(
TetriminoDown
(
te
));
//EndTetrimino(currentTetrimino);
...
...
@@ -496,8 +518,8 @@ public class MapManager : MonoBehaviour {
CreateRoom
(
te
);
DeleteFullRows
();
Destroy
(
currentGhost
.
gameObject
);
tetriminoSpawner
.
MakeTetrimino
(
);
isTetriminoFalling
=
false
;
StartCoroutine
(
MakeNextTetrimino
()
);
//tetriminoSpawner.MakeTetrimino()
;
}
/// <summary>
/// Get tetrimino's position down.
...
...
@@ -513,7 +535,7 @@ public class MapManager : MonoBehaviour {
te
.
transform
.
position
+=
new
Vector3
(
0
,
-
fallSpeed
,
0
);
}
GameObject
camera
=
GameObject
.
Find
(
"Tetris Camera"
);
StartCoroutine
(
Shake
(
1
0
,
camera
.
transform
.
position
,
camera
));
StartCoroutine
(
CameraShake
(
2
0
,
camera
.
transform
.
position
,
camera
));
EndTetrimino
(
currentTetrimino
);
}
/// <summary>
...
...
@@ -594,7 +616,7 @@ public class MapManager : MonoBehaviour {
UpdateMap
(
currentTetrimino
);
te
.
rooms
[
i
].
transform
.
parent
=
grid
;
te
.
rooms
[
i
].
transform
.
position
+=
new
Vector3
(
0
,
0
,
-
2
);
if
(
te
.
rooms
[
i
].
specialRoomType
!=
Room
.
SpecialRoomType
.
Normal
)
if
(
te
.
rooms
[
i
].
specialRoomType
!=
SpecialRoomType
.
Normal
)
{
Instantiate
(
specialRoomList
[(
int
)
te
.
rooms
[
i
].
specialRoomType
],
te
.
rooms
[
i
].
transform
.
position
+
new
Vector3
(
0
,
0
,
2
),
Quaternion
.
identity
,
te
.
rooms
[
i
].
transform
);
}
...
...
@@ -605,10 +627,54 @@ public class MapManager : MonoBehaviour {
}
Destroy
(
te
.
gameObject
);
}
/*public void UpgradeRoom(Tetrimino te, Room.SpecialRoomType)
/// <summary>
/// Upgrade rooms.
/// </summary>
/// <param name="roomType">Rooms you want to upgrade.</param>
public
void
UpgradeRoom
(
SpecialRoomType
roomType
)
{
}*/
if
(!
isTetriminoFalling
)
{
if
(
roomType
!=
SpecialRoomType
.
Item
&&
currentTetrimino
.
notNormalRoomCount
<
4
)
{
int
randomRoom
=
Random
.
Range
(
0
,
currentTetrimino
.
rooms
.
Length
);
if
(
currentTetrimino
.
rooms
[
randomRoom
].
specialRoomType
==
SpecialRoomType
.
Normal
)
{
currentTetrimino
.
notNormalRoomCount
++;
currentTetrimino
.
rooms
[
randomRoom
].
specialRoomType
=
roomType
;
return
;
}
else
{
UpgradeRoom
(
roomType
);
return
;
}
}
else
if
(
roomType
==
SpecialRoomType
.
Item
)
{
if
(
currentTetrimino
.
itemRoomIndex
!=
-
1
)
{
currentTetrimino
.
rooms
[
currentTetrimino
.
itemRoomIndex
].
itemRoomType
++;
return
;
}
else
{
int
randomRoom
=
Random
.
Range
(
0
,
currentTetrimino
.
rooms
.
Length
);
currentTetrimino
.
notNormalRoomCount
++;
currentTetrimino
.
itemRoomIndex
=
randomRoom
;
currentTetrimino
.
rooms
[
randomRoom
].
specialRoomType
=
roomType
;
currentTetrimino
.
rooms
[
randomRoom
].
itemRoomType
++;
return
;
}
}
}
roomsWaiting
.
Enqueue
(
roomType
);
}
public
IEnumerator
MakeNextTetrimino
()
{
yield
return
new
WaitForSeconds
(
1f
);
tetriminoSpawner
.
MakeTetrimino
();
}
/// <summary>
/// Shake the camera when tetrimino has fallen.
/// </summary>
...
...
@@ -616,18 +682,16 @@ public class MapManager : MonoBehaviour {
/// <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
Camera
Shake
(
float
_amount
,
Vector3
originPos
,
GameObject
camera
)
{
float
amount
=
_amount
;
while
(
amount
>
0
)
{
//transform.localPosition = (Vector3)Random.insideUnitCircle * amount + originPos;
camera
.
transform
.
localPosition
=
new
Vector3
(
0.2f
*
Random
.
insideUnitCircle
.
x
*
amount
+
originPos
.
x
,
Random
.
insideUnitCircle
.
y
*
amount
+
originPos
.
y
,
originPos
.
z
);
//transform.localPosition = new Vector3(Random.insideUnitCircle.x * amount + originPos.x, originPos.y, originPos.z);
//transform.localPosition = new Vector3(originPos.x, Random.insideUnitCircle.y * amount + originPos.y, originPos.z);
amount
-=
_amount
/
25
;
amount
-=
_amount
/
40
;
//Debug.Log(amount);
yield
return
null
;
}
...
...
Assets/Scripts/TetrisMap/Room.cs
View file @
ed5a2e58
...
...
@@ -34,13 +34,9 @@ public class Room : MonoBehaviour
/// </summary>
public
int
itemRoomType
;
/// <summary>
/// Enum for special room types.
/// </summary>
public
enum
SpecialRoomType
{
Start
,
Item
,
BothSide
,
Gold
,
Amethyst
,
Boss
,
Normal
};
/// <summary>
/// Special room types.
/// </summary>
public
SpecialRoomType
specialRoomType
;
public
MapManager
.
SpecialRoomType
specialRoomType
;
/// <summary>
/// Select which doors would be opened.
...
...
Assets/Scripts/TetrisMap/Test.cs
View file @
ed5a2e58
...
...
@@ -20,6 +20,22 @@ public class Test : MonoBehaviour {
{
MM
.
spawnBossTetrimino
=
true
;
}
public
void
Gold
()
{
MM
.
UpgradeRoom
(
MapManager
.
SpecialRoomType
.
Gold
);
}
public
void
Amethyst
()
{
MM
.
UpgradeRoom
(
MapManager
.
SpecialRoomType
.
Amethyst
);
}
public
void
BothSide
()
{
MM
.
UpgradeRoom
(
MapManager
.
SpecialRoomType
.
BothSide
);
}
public
void
Boss
()
{
SpawnBossTetrimino
();
}
private
void
Awake
()
{
...
...
Assets/Scripts/TetrisMap/Tetrimino.cs
View file @
ed5a2e58
...
...
@@ -36,6 +36,8 @@ public class Tetrimino : MonoBehaviour {
/// Each rooms for this tetrimino.
/// </summary>
public
Room
[]
rooms
;
public
int
notNormalRoomCount
=
0
;
public
int
itemRoomIndex
=
-
1
;
/// <summary>
/// Tetrimino rotated angle.
/// </summary>
...
...
Assets/Scripts/TetrisMap/TetriminoSpawner.cs
View file @
ed5a2e58
...
...
@@ -53,7 +53,12 @@ public class TetriminoSpawner : MonoBehaviour {
mapManager
.
currentTetrimino
.
rotatedPosition
[
i
]
=
(
int
)
mapManager
.
currentTetrimino
.
mapCoord
.
x
;
}
MakeGhost
(
mapManager
.
currentTetrimino
,
randomTetrimino
);
//MM.controlCurrentTetrimino = true;
mapManager
.
isTetriminoFalling
=
false
;
Debug
.
Log
(
mapManager
.
roomsWaiting
.
Count
);
while
(
mapManager
.
roomsWaiting
.
Count
!=
0
&&
mapManager
.
currentTetrimino
.
notNormalRoomCount
<
4
)
{
mapManager
.
UpgradeRoom
(
mapManager
.
roomsWaiting
.
Dequeue
());
}
}
}
/// <summary>
...
...
@@ -67,7 +72,7 @@ public class TetriminoSpawner : MonoBehaviour {
int
randomTetrimino
=
TetriminoRandomizer
();
mapManager
.
currentTetrimino
=
Instantiate
(
tetriminoes
[
randomTetrimino
],
mapManager
.
tetrisMapCoord
+
mapManager
.
tetrisMapSize
*
new
Vector3
(
randomPosition
,
0
,
mapManager
.
tetrisMapCoord
.
z
),
Quaternion
.
identity
);
mapManager
.
startRoom
=
mapManager
.
currentTetrimino
.
rooms
[
Random
.
Range
(
0
,
mapManager
.
currentTetrimino
.
rooms
.
Length
)];
mapManager
.
startRoom
.
specialRoomType
=
Room
.
SpecialRoomType
.
Start
;
mapManager
.
startRoom
.
specialRoomType
=
MapManager
.
SpecialRoomType
.
Start
;
mapManager
.
currentTetrimino
.
mapCoord
=
(
mapManager
.
currentTetrimino
.
transform
.
position
-
mapManager
.
tetrisMapCoord
)
/
mapManager
.
tetrisMapSize
;
mapManager
.
SetRoomMapCoord
(
mapManager
.
currentTetrimino
);
mapManager
.
MakeTetriminoRightPlace
(
mapManager
.
currentTetrimino
);
...
...
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