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
f97fea9f
Commit
f97fea9f
authored
Sep 29, 2018
by
18손재민
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
씬까지 다 커밋
parent
4094ea8e
Changes
9
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
804 additions
and
69 deletions
+804
-69
TetriminoSpawner.prefab
Assets/Prefabs/TetrisMap/TetriminoSpawner.prefab
+1
-1
PlayScene.unity
Assets/Scenes/PlayScene.unity
+711
-34
MapManager.cs
Assets/Scripts/TetrisMap/MapManager.cs
+45
-24
Room.cs
Assets/Scripts/TetrisMap/Room.cs
+1
-1
Test.cs
Assets/Scripts/TetrisMap/Test.cs
+31
-0
Test.cs.meta
Assets/Scripts/TetrisMap/Test.cs.meta
+11
-0
Tetrimino.cs
Assets/Scripts/TetrisMap/Tetrimino/Tetrimino.cs
+0
-1
TetriminoSpawner.cs
Assets/Scripts/TetrisMap/TetriminoSpawner.cs
+3
-8
TagManager.asset
ProjectSettings/TagManager.asset
+1
-0
No files found.
Assets/Prefabs/TetrisMap/TetriminoSpawner.prefab
View file @
f97fea9f
...
@@ -22,7 +22,7 @@ GameObject:
...
@@ -22,7 +22,7 @@ GameObject:
-
component
:
{
fileID
:
114524961967938888
}
-
component
:
{
fileID
:
114524961967938888
}
m_Layer
:
0
m_Layer
:
0
m_Name
:
TetriminoSpawner
m_Name
:
TetriminoSpawner
m_TagString
:
Untagged
m_TagString
:
TetriminoSpawner
m_Icon
:
{
fileID
:
0
}
m_Icon
:
{
fileID
:
0
}
m_NavMeshLayer
:
0
m_NavMeshLayer
:
0
m_StaticEditorFlags
:
0
m_StaticEditorFlags
:
0
...
...
Assets/Scenes/PlayScene.unity
View file @
f97fea9f
This diff is collapsed.
Click to expand it.
Assets/Scripts/TetrisMap/MapManager.cs
View file @
f97fea9f
...
@@ -36,7 +36,7 @@ public class MapManager : MonoBehaviour {
...
@@ -36,7 +36,7 @@ public class MapManager : MonoBehaviour {
/// <summary>
/// <summary>
/// Absolute coordinates on tetris map.
/// Absolute coordinates on tetris map.
/// </summary>
/// </summary>
public
static
Room
[,]
map
Coor
d
=
new
Room
[
width
,
height
];
public
static
Room
[,]
map
Gri
d
=
new
Room
[
width
,
height
];
/// <summary>
/// <summary>
/// Tetris Y axis coordinates on Unity.
/// Tetris Y axis coordinates on Unity.
/// </summary>
/// </summary>
...
@@ -84,9 +84,9 @@ public class MapManager : MonoBehaviour {
...
@@ -84,9 +84,9 @@ public class MapManager : MonoBehaviour {
{
{
for
(
int
i
=
0
;
i
<
TE
.
rooms
.
Length
;
i
++)
for
(
int
i
=
0
;
i
<
TE
.
rooms
.
Length
;
i
++)
{
{
if
(
TE
.
rooms
[
i
].
transform
.
position
.
x
<
mapLeftEnd
.
transform
.
position
.
x
)
if
(
TE
.
rooms
[
i
].
mapCoord
.
x
<
0
)
return
-
1
;
return
-
1
;
else
if
(
TE
.
rooms
[
i
].
transform
.
position
.
x
>
mapRightEnd
.
transform
.
position
.
x
)
else
if
(
TE
.
rooms
[
i
].
mapCoord
.
x
>
width
-
1
)
return
1
;
return
1
;
}
}
return
0
;
return
0
;
...
@@ -101,17 +101,16 @@ public class MapManager : MonoBehaviour {
...
@@ -101,17 +101,16 @@ public class MapManager : MonoBehaviour {
{
{
if
(
IsRightTetrimino
(
TE
)
==
1
)
if
(
IsRightTetrimino
(
TE
)
==
1
)
{
{
TE
.
transform
.
position
+=
new
Vector3
(-
tetrisMapSize
,
0
,
0
);
TE
.
mapCoord
+=
new
Vector3
(-
1
,
0
,
0
);
}
}
else
if
(
IsRightTetrimino
(
TE
)
==
-
1
)
else
if
(
IsRightTetrimino
(
TE
)
==
-
1
)
{
{
TE
.
transform
.
position
+=
new
Vector3
(
tetrisMapSize
,
0
,
0
);
TE
.
mapCoord
+=
new
Vector3
(
1
,
0
,
0
);
}
}
else
else
break
;
break
;
}
}
}
}
/// <summary>
/// <summary>
/// Delete one row.
/// Delete one row.
/// </summary>
/// </summary>
...
@@ -120,8 +119,8 @@ public class MapManager : MonoBehaviour {
...
@@ -120,8 +119,8 @@ public class MapManager : MonoBehaviour {
{
{
for
(
int
x
=
0
;
x
<
width
;
x
++)
for
(
int
x
=
0
;
x
<
width
;
x
++)
{
{
Destroy
(
map
Coor
d
[
x
,
row
].
gameObject
);
Destroy
(
map
Gri
d
[
x
,
row
].
gameObject
);
map
Coor
d
[
x
,
row
]
=
null
;
map
Gri
d
[
x
,
row
]
=
null
;
}
}
}
}
/// <summary>
/// <summary>
...
@@ -134,8 +133,8 @@ public class MapManager : MonoBehaviour {
...
@@ -134,8 +133,8 @@ public class MapManager : MonoBehaviour {
{
{
for
(
int
x
=
0
;
x
<
width
;
x
++)
for
(
int
x
=
0
;
x
<
width
;
x
++)
{
{
map
Coord
[
x
,
y
-
1
]
=
mapCoor
d
[
x
,
y
];
map
Grid
[
x
,
y
-
1
]
=
mapGri
d
[
x
,
y
];
map
Coor
d
[
x
,
y
]
=
null
;
map
Gri
d
[
x
,
y
]
=
null
;
}
}
}
}
}
}
...
@@ -147,7 +146,7 @@ public class MapManager : MonoBehaviour {
...
@@ -147,7 +146,7 @@ public class MapManager : MonoBehaviour {
public
static
bool
IsRowFull
(
int
row
)
public
static
bool
IsRowFull
(
int
row
)
{
{
for
(
int
x
=
0
;
x
<
width
;
x
++)
for
(
int
x
=
0
;
x
<
width
;
x
++)
if
(
map
Coord
[
x
,
row
]
!=
null
&&
mapCoor
d
[
x
,
row
].
specialRoomType
==
Room
.
SpecialRoomType
.
Boss
)
if
(
map
Grid
[
x
,
row
]
!=
null
&&
mapGri
d
[
x
,
row
].
specialRoomType
==
Room
.
SpecialRoomType
.
Boss
)
return
false
;
return
false
;
return
true
;
return
true
;
}
}
...
@@ -190,24 +189,49 @@ public class MapManager : MonoBehaviour {
...
@@ -190,24 +189,49 @@ public class MapManager : MonoBehaviour {
{
{
}
}
public
void
TetriminoMove
(
Tetrimino
TE
)
/*
public void TetriminoMove(Tetrimino TE)
{
{
if
(
Input
.
GetKeyDown
(
KeyCode
.
LeftArrow
)
&&
inTetris
)
if
(Input.GetKeyDown(KeyCode.LeftArrow) && inTetris)
{
{
TE.transform.position += new Vector3(-tetrisMapSize, 0, 0);
TE.transform.position += new Vector3(-tetrisMapSize, 0, 0);
if
(
IsRightTetrimino
(
TE
)
!=
0
)
if
(IsRightTetrimino(TE) != 0)
TE.transform.position += new Vector3(tetrisMapSize, 0, 0);
TE.transform.position += new Vector3(tetrisMapSize, 0, 0);
}
}
else
if
(
Input
.
GetKeyDown
(
KeyCode
.
RightArrow
)
&&
inTetris
)
else if
(Input.GetKeyDown(KeyCode.RightArrow) && inTetris)
{
{
TE.transform.position += new Vector3(tetrisMapSize, 0, 0);
TE.transform.position += new Vector3(tetrisMapSize, 0, 0);
if (IsRightTetrimino(TE) != 0)
if (IsRightTetrimino(TE) != 0)
TE.transform.position += new Vector3(-tetrisMapSize, 0, 0);
TE.transform.position += new Vector3(-tetrisMapSize, 0, 0);
}
}
}*/
public
void
TetriminoMove
(
Tetrimino
TE
)
{
if
(
Input
.
GetKeyDown
(
KeyCode
.
LeftArrow
)
&&
inTetris
)
{
TE
.
mapCoord
+=
new
Vector3
(-
1
,
0
,
0
);
SetRoomMapCoord
(
currentTetrimino
);
if
(
IsRightTetrimino
(
TE
)
!=
0
)
TE
.
mapCoord
+=
new
Vector3
(
1
,
0
,
0
);
}
else
if
(
Input
.
GetKeyDown
(
KeyCode
.
RightArrow
)
&&
inTetris
)
{
TE
.
mapCoord
+=
new
Vector3
(
1
,
0
,
0
);
SetRoomMapCoord
(
currentTetrimino
);
if
(
IsRightTetrimino
(
TE
)
!=
0
)
TE
.
mapCoord
+=
new
Vector3
(-
1
,
0
,
0
);
}
SetRoomMapCoord
(
currentTetrimino
);
}
}
public
void
TetriminoRotate
(
Tetrimino
TE
)
public
void
TetriminoRotate
(
Tetrimino
TE
)
{
{
}
public
void
SetRoomMapCoord
(
Tetrimino
TE
)
{
for
(
int
i
=
0
;
i
<
TE
.
rooms
.
Length
;
i
++)
{
TE
.
rooms
[
i
].
mapCoord
=
TE
.
mapCoord
+
TE
.
rooms
[
i
].
transform
.
localPosition
;
}
}
}
public
void
InitiateTetrimino
()
public
void
InitiateTetrimino
()
{
{
...
@@ -217,18 +241,15 @@ public class MapManager : MonoBehaviour {
...
@@ -217,18 +241,15 @@ public class MapManager : MonoBehaviour {
/*
/*
* Test
* Test
* */
* */
public
void
SpawnBossTetrimino
()
{
spawnBossTetrimino
=
true
;
}
// Use this for initialization
// Use this for initialization
void
Start
()
{
void
Start
()
{
inTetris
=
true
;
inTetris
=
true
;
}
}
// Update is called once per frame
void
Update
()
{
TetriminoMove
(
currentTetrimino
);
}
// Update is called once per frame
void
Update
()
{
TetriminoMove
(
currentTetrimino
);
currentTetrimino
.
transform
.
position
=
currentTetrimino
.
mapCoord
*
tetrisMapSize
+
tetrisMapCoord
;
}
}
}
Assets/Scripts/TetrisMap/Room.cs
View file @
f97fea9f
...
@@ -11,7 +11,7 @@ public class Room : MonoBehaviour
...
@@ -11,7 +11,7 @@ public class Room : MonoBehaviour
/// Room's Location on tetris map.
/// Room's Location on tetris map.
/// Not related to real location.
/// Not related to real location.
/// </summary>
/// </summary>
public
Vector3
map
Location
;
public
Vector3
map
Coord
;
/// <summary>
/// <summary>
/// Door info per rooms.
/// Door info per rooms.
/// 0 for up, 1 for down.
/// 0 for up, 1 for down.
...
...
Assets/Scripts/TetrisMap/Test.cs
0 → 100644
View file @
f97fea9f
using
System.Collections
;
using
System.Collections.Generic
;
using
UnityEngine
;
public
class
Test
:
MonoBehaviour
{
public
void
ChangeTetrimino
()
{
var
MM
=
GameObject
.
FindGameObjectWithTag
(
"MapManager"
).
GetComponent
<
MapManager
>();
var
TS
=
GameObject
.
FindGameObjectWithTag
(
"TetriminoSpawner"
).
GetComponent
<
TetriminoSpawner
>();
Destroy
(
MM
.
currentTetrimino
.
gameObject
);
TS
.
MakeTetrimino
();
}
public
void
SpawnBossTetrimino
()
{
var
MM
=
GameObject
.
FindGameObjectWithTag
(
"MapManager"
).
GetComponent
<
MapManager
>();
MM
.
spawnBossTetrimino
=
true
;
}
// Use this for initialization
void
Start
()
{
}
// Update is called once per frame
void
Update
()
{
}
}
Assets/Scripts/TetrisMap/Test.cs.meta
0 → 100644
View file @
f97fea9f
fileFormatVersion: 2
guid: 4f70662cea9642244afe9d8a44fa3211
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
Assets/Scripts/TetrisMap/Tetrimino/Tetrimino.cs
View file @
f97fea9f
...
@@ -49,5 +49,4 @@ public class Tetrimino : MonoBehaviour {
...
@@ -49,5 +49,4 @@ public class Tetrimino : MonoBehaviour {
}
}
Assets/Scripts/TetrisMap/TetriminoSpawner.cs
View file @
f97fea9f
...
@@ -39,6 +39,8 @@ public class TetriminoSpawner : MonoBehaviour {
...
@@ -39,6 +39,8 @@ public class TetriminoSpawner : MonoBehaviour {
randomTetrimino
=
TetriminoRandomizer
();
randomTetrimino
=
TetriminoRandomizer
();
MM
.
currentTetrimino
=
Instantiate
(
tetriminoes
[
randomTetrimino
],
MM
.
tetrisMapCoord
+
MM
.
tetrisMapSize
*
new
Vector3
(
randomPosition
,
MapManager
.
realHeight
+
1
,
MM
.
tetrisMapCoord
.
z
),
Quaternion
.
identity
);
MM
.
currentTetrimino
=
Instantiate
(
tetriminoes
[
randomTetrimino
],
MM
.
tetrisMapCoord
+
MM
.
tetrisMapSize
*
new
Vector3
(
randomPosition
,
MapManager
.
realHeight
+
1
,
MM
.
tetrisMapCoord
.
z
),
Quaternion
.
identity
);
MM
.
MakeTetriminoRightPlace
(
MM
.
currentTetrimino
);
MM
.
MakeTetriminoRightPlace
(
MM
.
currentTetrimino
);
MM
.
currentTetrimino
.
mapCoord
=
(
MM
.
currentTetrimino
.
transform
.
position
-
MM
.
tetrisMapCoord
)
/
MM
.
tetrisMapSize
;
MM
.
SetRoomMapCoord
(
MM
.
currentTetrimino
);
}
}
}
}
/// <summary>
/// <summary>
...
@@ -65,17 +67,10 @@ public class TetriminoSpawner : MonoBehaviour {
...
@@ -65,17 +67,10 @@ public class TetriminoSpawner : MonoBehaviour {
return
count
;
return
count
;
}
}
/*
/*
* Test
* Test
* */
* */
public
void
ChangeTetrimino
()
{
var
MM
=
GameObject
.
FindGameObjectWithTag
(
"MapManager"
).
GetComponent
<
MapManager
>();
Destroy
(
MM
.
currentTetrimino
.
gameObject
);
MakeTetrimino
();
}
// Use this for initialization
// Use this for initialization
void
Start
()
{
void
Start
()
{
MakeTetrimino
();
MakeTetrimino
();
...
...
ProjectSettings/TagManager.asset
View file @
f97fea9f
...
@@ -6,6 +6,7 @@ TagManager:
...
@@ -6,6 +6,7 @@ TagManager:
tags
:
tags
:
-
MapManager
-
MapManager
-
Tetrimino
-
Tetrimino
-
TetriminoSpawner
layers
:
layers
:
-
Default
-
Default
-
TransparentFX
-
TransparentFX
...
...
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