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
93a18e68
Commit
93a18e68
authored
Nov 16, 2018
by
18손재민
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
고스트 오류 수정
parent
d12b1be8
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
52 additions
and
66 deletions
+52
-66
GhostManager.cs
Assets/Scripts/TetrisMap/GhostManager.cs
+0
-48
GhostManager.cs.meta
Assets/Scripts/TetrisMap/GhostManager.cs.meta
+0
-11
MapManager.cs
Assets/Scripts/TetrisMap/MapManager.cs
+52
-7
No files found.
Assets/Scripts/TetrisMap/GhostManager.cs
deleted
100644 → 0
View file @
d12b1be8
using
System.Collections
;
using
System.Collections.Generic
;
using
UnityEngine
;
public
class
GhostManager
:
MonoBehaviour
{
MapManager
MM
;
public
bool
IsRightGhost
(
Tetrimino
te
)
{
for
(
int
i
=
0
;
i
<
te
.
rooms
.
Length
;
i
++)
{
if
(
te
.
rooms
[
i
].
mapCoord
.
y
<
0
)
return
false
;
else
if
(
MapManager
.
mapGrid
[(
int
)
te
.
rooms
[
i
].
mapCoord
.
x
,
(
int
)
te
.
rooms
[
i
].
mapCoord
.
y
]
!=
null
)
return
false
;
}
return
true
;
}
public
void
GhostDown
(
Tetrimino
ghost
,
Tetrimino
te
)
{
while
(
IsRightGhost
(
ghost
))
{
MM
.
MoveTetriminoMapCoord
(
ghost
,
new
Vector3
(
0
,
-
1
,
0
));
}
MM
.
MoveTetriminoMapCoord
(
ghost
,
new
Vector3
(
0
,
1
,
0
));
}
private
void
Awake
()
{
MM
=
GameObject
.
Find
(
"MapManager"
).
GetComponent
<
MapManager
>();
}
// Use this for initialization
void
Start
()
{
}
// Update is called once per frame
void
Update
()
{
MM
.
currentGhost
.
mapCoord
=
MM
.
currentTetrimino
.
mapCoord
;
for
(
int
i
=
0
;
i
<
MM
.
currentGhost
.
rooms
.
Length
;
i
++)
{
MM
.
currentGhost
.
rooms
[
i
].
mapCoord
=
MM
.
currentTetrimino
.
rooms
[
i
].
mapCoord
;
MM
.
currentGhost
.
rooms
[
i
].
transform
.
position
=
(
MM
.
currentGhost
.
rooms
[
i
].
mapCoord
-
MM
.
currentGhost
.
mapCoord
)
*
MM
.
tetrisMapSize
+
MM
.
currentGhost
.
transform
.
position
;
}
GhostDown
(
MM
.
currentGhost
,
MM
.
currentTetrimino
);
}
}
Assets/Scripts/TetrisMap/GhostManager.cs.meta
deleted
100644 → 0
View file @
d12b1be8
fileFormatVersion: 2
guid: 925d029b76b3b254b81e73583f901369
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
Assets/Scripts/TetrisMap/MapManager.cs
View file @
93a18e68
...
@@ -110,6 +110,22 @@ public class MapManager : MonoBehaviour {
...
@@ -110,6 +110,22 @@ public class MapManager : MonoBehaviour {
return
0
;
return
0
;
}
}
/// <summary>
/// <summary>
/// Check if ghost is at right place.
/// </summary>
/// <param name="te">Ghost to check</param>
/// <returns>True for right place, false for wrong place</returns>
public
bool
IsRightGhost
(
Tetrimino
te
)
{
for
(
int
i
=
0
;
i
<
te
.
rooms
.
Length
;
i
++)
{
if
(
te
.
rooms
[
i
].
mapCoord
.
y
<
0
)
return
false
;
else
if
(
MapManager
.
mapGrid
[(
int
)
te
.
rooms
[
i
].
mapCoord
.
x
,
(
int
)
te
.
rooms
[
i
].
mapCoord
.
y
]
!=
null
)
return
false
;
}
return
true
;
}
/// <summary>
/// Make Tetrimino in right X coordinate.
/// Make Tetrimino in right X coordinate.
/// </summary>
/// </summary>
/// <param name="te">Tetrimino.</param>
/// <param name="te">Tetrimino.</param>
...
@@ -273,12 +289,22 @@ public class MapManager : MonoBehaviour {
...
@@ -273,12 +289,22 @@ public class MapManager : MonoBehaviour {
if
(
te
.
rooms
[
i
].
mapCoord
.
y
<
minY
)
if
(
te
.
rooms
[
i
].
mapCoord
.
y
<
minY
)
minY
=
te
.
rooms
[
i
].
mapCoord
.
y
;
minY
=
te
.
rooms
[
i
].
mapCoord
.
y
;
}
}
te
.
mapCoord
=
new
Vector3
(
te
.
rotatedPosition
[
te
.
rotatedAngle
],
te
.
mapCoord
.
y
,
te
.
mapCoord
.
z
);
for
(
int
i
=
0
;
i
<
te
.
rooms
.
Length
;
i
++)
for
(
int
i
=
0
;
i
<
te
.
rooms
.
Length
;
i
++)
{
{
//te.rooms[i].mapCoord += new Vector3(-(minX - te.mapCoord.x), -(minY - te.mapCoord.y), 0);
te
.
rooms
[
i
].
mapCoord
+=
new
Vector3
(-(
minX
-
te
.
mapCoord
.
x
),
-(
minY
-
te
.
mapCoord
.
y
),
0
);
te
.
rooms
[
i
].
mapCoord
+=
new
Vector3
(-(
minX
-
te
.
mapCoord
.
x
),
-(
minY
-
te
.
mapCoord
.
y
),
0
);
te
.
rooms
[
i
].
transform
.
position
=
(
te
.
rooms
[
i
].
mapCoord
-
te
.
mapCoord
)
*
tetrisMapSize
+
te
.
transform
.
position
;
te
.
rooms
[
i
].
transform
.
position
=
(
te
.
rooms
[
i
].
mapCoord
-
te
.
mapCoord
)
*
tetrisMapSize
+
te
.
transform
.
position
;
}
}
te
.
mapCoord
=
new
Vector3
(
te
.
rotatedPosition
[
te
.
rotatedAngle
],
te
.
mapCoord
.
y
,
te
.
mapCoord
.
z
);
/*for(int i = 0; i < te.rooms.Length; i++)
{
if(te.rooms[i].mapCoord.x > 9)
{
for (int j = 0; j < te.rooms.Length; j++)
te.rooms[i].mapCoord += new Vector3(0, -1, 0);
i = 0;
}
}*/
}
}
/// <summary>
/// <summary>
/// Move tetrimino as the amount of coord.
/// Move tetrimino as the amount of coord.
...
@@ -336,11 +362,29 @@ public class MapManager : MonoBehaviour {
...
@@ -336,11 +362,29 @@ public class MapManager : MonoBehaviour {
yield
return
null
;
yield
return
null
;
}
}
}
}
//완성해야됨
/// <summary>
/// Get ghost down.
/// </summary>
/// <param name="ghost">Which ghost to move.</param>
/// <param name="te">Which tetrimino you'd like to sink with ghost.</param>
public
void
GhostDown
(
Tetrimino
ghost
,
Tetrimino
te
)
{
/*if(ghost.rotatedAngle != te.rotatedAngle)
TetriminoRotate(ghost, te.rotatedAngle - ghost.rotatedAngle);*/
currentGhost
.
mapCoord
=
currentTetrimino
.
mapCoord
;
for
(
int
i
=
0
;
i
<
currentGhost
.
rooms
.
Length
;
i
++)
{
currentGhost
.
rooms
[
i
].
mapCoord
=
currentTetrimino
.
rooms
[
i
].
mapCoord
;
currentGhost
.
rooms
[
i
].
transform
.
position
=
(
currentGhost
.
rooms
[
i
].
mapCoord
-
currentGhost
.
mapCoord
)
*
tetrisMapSize
+
currentGhost
.
transform
.
position
;
}
while
(
IsRightGhost
(
ghost
))
{
MoveTetriminoMapCoord
(
ghost
,
new
Vector3
(
0
,
-
1
,
0
));
}
MoveTetriminoMapCoord
(
ghost
,
new
Vector3
(
0
,
1
,
0
));
}
//완성해야됨
...
@@ -405,6 +449,7 @@ public class MapManager : MonoBehaviour {
...
@@ -405,6 +449,7 @@ public class MapManager : MonoBehaviour {
/*
/*
* Test
* Test
* */
* */
void
Awake
()
void
Awake
()
{
{
Tetrimino
.
rotationInformation
[
0
].
horizontalLength
=
new
int
[
4
]
{
1
,
4
,
1
,
4
};
//I
Tetrimino
.
rotationInformation
[
0
].
horizontalLength
=
new
int
[
4
]
{
1
,
4
,
1
,
4
};
//I
...
@@ -432,7 +477,7 @@ public class MapManager : MonoBehaviour {
...
@@ -432,7 +477,7 @@ public class MapManager : MonoBehaviour {
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);
GhostDown
(
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;
...
...
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