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
21d77371
Commit
21d77371
authored
Nov 28, 2018
by
18손재민
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
프레스 만들고 있음 현재 프레스 압축은 잘 작동함 이제 프레스 펼쳐지고 떨어지는거 만들면 된다
parent
7a20aadd
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
54 additions
and
19 deletions
+54
-19
MapManager.cs
Assets/Scripts/TetrisMap/MapManager.cs
+46
-14
Press.cs
Assets/Scripts/TetrisMap/Press.cs
+8
-5
No files found.
Assets/Scripts/TetrisMap/MapManager.cs
View file @
21d77371
...
@@ -45,10 +45,6 @@ public class MapManager : MonoBehaviour {
...
@@ -45,10 +45,6 @@ public class MapManager : MonoBehaviour {
/// The time taken for a press to be collapsed.
/// The time taken for a press to be collapsed.
/// </summary>
/// </summary>
public
float
collapseTime
;
public
float
collapseTime
;
/// <summary>
/// Time press has started to collapsed.
/// </summary>
private
float
initialCollapseTime
;
public
static
int
height
=
24
,
width
=
10
,
realHeight
=
height
-
5
;
public
static
int
height
=
24
,
width
=
10
,
realHeight
=
height
-
5
;
...
@@ -83,7 +79,7 @@ public class MapManager : MonoBehaviour {
...
@@ -83,7 +79,7 @@ public class MapManager : MonoBehaviour {
/// <summary>
/// <summary>
/// Presses one row.
/// Presses one row.
/// </summary>
/// </summary>
public
GameObject
tetrisP
ress
;
public
Press
p
ress
;
/// <summary>
/// <summary>
/// Current tetrimino waiting for falling.
/// Current tetrimino waiting for falling.
/// </summary>
/// </summary>
...
@@ -188,12 +184,13 @@ public class MapManager : MonoBehaviour {
...
@@ -188,12 +184,13 @@ public class MapManager : MonoBehaviour {
if
(
IsRowFull
(
y
)
&&
!
isRowDeleting
[
y
])
if
(
IsRowFull
(
y
)
&&
!
isRowDeleting
[
y
])
{
{
isRowDeleting
[
y
]
=
true
;
isRowDeleting
[
y
]
=
true
;
initialCollapseTime
=
Time
.
time
;
Press
leftPress
=
Instantiate
(
press
,
new
Vector3
(
0
,
y
*
24
,
0
),
Quaternion
.
identity
);
GameObject
leftPress
=
Instantiate
(
tetrisPress
,
new
Vector3
(
0
,
y
*
24
,
0
),
Quaternion
.
identity
);
Press
rightPress
=
Instantiate
(
press
,
new
Vector3
(
240
,
y
*
24
,
0
),
Quaternion
.
identity
);
leftPress
.
GetComponent
<
Press
>().
isLeft
=
true
;
leftPress
.
initialCollapseTime
=
Time
.
time
;
GameObject
rightPress
=
Instantiate
(
tetrisPress
,
new
Vector3
(
240
,
y
*
24
,
0
),
Quaternion
.
identity
);
leftPress
.
row
=
y
;
rightPress
.
GetComponent
<
Press
>().
isLeft
=
false
;
rightPress
.
initialCollapseTime
=
Time
.
time
;
StartCoroutine
(
TetrisPress
(
y
,
leftPress
,
rightPress
));
rightPress
.
row
=
y
;
StartCoroutine
(
TetrisPress
(
leftPress
.
initialCollapseTime
,
leftPress
,
rightPress
));
/*for (int x = 0; x < width; x++)
/*for (int x = 0; x < width; x++)
{
{
Destroy(mapGrid[x, y].gameObject);
Destroy(mapGrid[x, y].gameObject);
...
@@ -203,7 +200,7 @@ public class MapManager : MonoBehaviour {
...
@@ -203,7 +200,7 @@ public class MapManager : MonoBehaviour {
}
}
}
}
}
}
public
IEnumerator
TetrisPress
(
int
row
,
GameObject
leftPress
,
GameObject
rightPress
)
public
IEnumerator
TetrisPress
(
float
initialCollapseTime
,
Press
leftPress
,
Press
rightPress
)
{
{
while
(
Time
.
time
-
initialCollapseTime
<
collapseTime
)
while
(
Time
.
time
-
initialCollapseTime
<
collapseTime
)
{
{
...
@@ -212,6 +209,13 @@ public class MapManager : MonoBehaviour {
...
@@ -212,6 +209,13 @@ 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
;
for
(
int
x
=
0
;
x
<
width
;
x
++)
for
(
int
x
=
0
;
x
<
width
;
x
++)
{
{
Destroy
(
mapGrid
[
x
,
row
].
gameObject
);
Destroy
(
mapGrid
[
x
,
row
].
gameObject
);
...
@@ -219,8 +223,8 @@ public class MapManager : MonoBehaviour {
...
@@ -219,8 +223,8 @@ public class MapManager : MonoBehaviour {
}
}
isRowDeleting
[
row
]
=
false
;
isRowDeleting
[
row
]
=
false
;
DecreaseRowsAbove
(
row
);
DecreaseRowsAbove
(
row
);
Destroy
(
leftPress
);
Destroy
(
leftPress
.
gameObject
);
Destroy
(
rightPress
);
Destroy
(
rightPress
.
gameObject
);
}
}
/// <summary>
/// <summary>
/// Decrease all rows above this row.
/// Decrease all rows above this row.
...
@@ -242,6 +246,15 @@ public class MapManager : MonoBehaviour {
...
@@ -242,6 +246,15 @@ public class MapManager : MonoBehaviour {
}
}
}
}
Press
[]
presses
=
FindObjectsOfType
<
Press
>();
foreach
(
Press
child
in
presses
)
{
if
(
child
.
row
>
row
)
{
child
.
row
-=
1
;
child
.
transform
.
position
+=
new
Vector3
(
0
,
-
24
,
0
);
}
}
}
}
/// <summary>
/// <summary>
/// Check row if it is full.
/// Check row if it is full.
...
@@ -421,6 +434,8 @@ public class MapManager : MonoBehaviour {
...
@@ -421,6 +434,8 @@ public class MapManager : MonoBehaviour {
fallSpeed
+=
gravity
*
fallTime
*
fallTime
;
fallSpeed
+=
gravity
*
fallTime
*
fallTime
;
te
.
transform
.
position
+=
new
Vector3
(
0
,
-
fallSpeed
,
0
);
te
.
transform
.
position
+=
new
Vector3
(
0
,
-
fallSpeed
,
0
);
}
}
GameObject
camera
=
GameObject
.
Find
(
"Tetris Camera"
);
StartCoroutine
(
Shake
(
10
,
camera
.
transform
.
position
,
camera
));
EndTetrimino
(
currentTetrimino
);
EndTetrimino
(
currentTetrimino
);
}
}
/// <summary>
/// <summary>
...
@@ -508,6 +523,23 @@ public class MapManager : MonoBehaviour {
...
@@ -508,6 +523,23 @@ public class MapManager : MonoBehaviour {
{
{
}*/
}*/
public
IEnumerator
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
;
//Debug.Log(amount);
yield
return
null
;
}
camera
.
transform
.
localPosition
=
originPos
;
}
void
Awake
()
void
Awake
()
{
{
...
...
Assets/Scripts/TetrisMap/Press.cs
View file @
21d77371
...
@@ -7,11 +7,14 @@ public class Press : MonoBehaviour
...
@@ -7,11 +7,14 @@ public class Press : MonoBehaviour
/*
/*
* variables
* variables
* */
* */
/// <summary>
/// <summary>
/// If this press is on left side or not.
/// Time press has started to collapsed.
/// </summary>
public
float
initialCollapseTime
;
/// <summary>
/// Time press has started to collapsed.
/// </summary>
/// </summary>
public
bool
isLeft
;
public
int
row
;
// Use this for initialization
// Use this for initialization
...
...
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