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
25d8e581
Commit
25d8e581
authored
Nov 25, 2018
by
18손재민
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
카메라 매니저 만듬. 탭키 누르면 화면 전환됩니다.
parent
3dfa41f9
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
37 additions
and
12 deletions
+37
-12
CameraController.cs
Assets/Scripts/CameraController.cs
+31
-8
GameManager.cs
Assets/Scripts/GameManager.cs
+2
-2
MapManager.cs
Assets/Scripts/TetrisMap/MapManager.cs
+2
-0
Test.cs
Assets/Scripts/TetrisMap/Test.cs
+2
-2
No files found.
Assets/Scripts/CameraController.cs
View file @
25d8e581
...
@@ -5,12 +5,16 @@ using UnityEngine;
...
@@ -5,12 +5,16 @@ using UnityEngine;
public
class
CameraController
:
MonoBehaviour
{
public
class
CameraController
:
MonoBehaviour
{
public
LayerMask
roomLayer
;
public
LayerMask
roomLayer
;
public
GameObject
player
;
public
GameObject
player
;
public
GameObject
mainCamera
;
public
GameObject
tetrisCamera
;
/*
/*
* If camera is in Tetris view, ideal position is (108, 240, -1)
* If camera is in Tetris view, ideal position is (108, 240, -1)
* size 300
* size 300
* */
* */
readonly
float
camX
=
9.5f
;
readonly
float
camX
=
9.5f
;
readonly
float
camY
=
4f
;
readonly
float
camY
=
4f
;
private
Vector3
cameraTetrisCoord
=
new
Vector3
(
108
,
240
,
-
1
);
private
float
cameraTetrisSize
=
300f
;
GameManager
.
GameState
lastGameState
;
GameManager
.
GameState
lastGameState
;
...
@@ -23,12 +27,17 @@ public class CameraController : MonoBehaviour {
...
@@ -23,12 +27,17 @@ public class CameraController : MonoBehaviour {
{
{
lastGameState
=
GameManager
.
GameState
.
Ingame
;
lastGameState
=
GameManager
.
GameState
.
Ingame
;
destination
=
transform
.
position
;
destination
=
transform
.
position
;
/*mainCamera = GameObject.Find("Main Camera").GetComponent<Camera>();
tetrisCamera = GameObject.Find("Tetris Camera").GetComponent<Camera>();*/
tetrisCamera
.
transform
.
position
=
cameraTetrisCoord
;
tetrisCamera
.
transform
.
localScale
=
new
Vector3
(
cameraTetrisSize
,
cameraTetrisSize
,
1
);
tetrisCamera
.
GetComponent
<
Camera
>().
enabled
=
false
;
}
}
// Update is called once per frame
// Update is called once per frame
void
Update
()
void
Update
()
{
{
if
(
lastGameState
!=
GameManager
.
gameState
)
/*
if (lastGameState != GameManager.gameState)
{
{
StartCoroutine("ChangeScene");
StartCoroutine("ChangeScene");
lastGameState = GameManager.gameState;
lastGameState = GameManager.gameState;
...
@@ -36,9 +45,9 @@ public class CameraController : MonoBehaviour {
...
@@ -36,9 +45,9 @@ public class CameraController : MonoBehaviour {
else if (lastGameState == GameManager.GameState.Ingame)
else if (lastGameState == GameManager.GameState.Ingame)
{
{
SetDestination();
SetDestination();
}
}
*/
ChangeState
();
GotoDestination
();
//
GotoDestination();
}
}
...
@@ -100,7 +109,7 @@ public class CameraController : MonoBehaviour {
...
@@ -100,7 +109,7 @@ public class CameraController : MonoBehaviour {
if
(
Camera
.
main
!=
null
)
if
(
Camera
.
main
!=
null
)
{
{
Camera
.
main
.
transform
.
position
=
Vector3
.
Lerp
(
Camera
.
main
.
transform
.
position
,
new
Vector3
(
posx
,
posy
,
0
),
2f
*
Time
.
deltaTime
);
Camera
.
main
.
transform
.
position
=
Vector3
.
Lerp
(
Camera
.
main
.
transform
.
position
,
new
Vector3
(
posx
,
posy
,
0
),
2f
*
Time
.
deltaTime
);
Camera
.
main
.
transform
.
position
=
new
Vector3
(
Camera
.
main
.
transform
.
position
.
x
,
Camera
.
main
.
transform
.
position
.
y
,
-
1
0
);
//카메라를 원래 z축으로 이동
Camera
.
main
.
transform
.
position
=
new
Vector3
(
Camera
.
main
.
transform
.
position
.
x
,
Camera
.
main
.
transform
.
position
.
y
,
-
1
);
//카메라를 원래 z축으로 이동
}
}
// Camera.main.transform.position = new Vector3(posx, posy, -10);
// Camera.main.transform.position = new Vector3(posx, posy, -10);
...
@@ -152,6 +161,20 @@ public class CameraController : MonoBehaviour {
...
@@ -152,6 +161,20 @@ public class CameraController : MonoBehaviour {
return
-
1
;
return
-
1
;
}
}
public
void
ChangeState
()
{
}
if
(
Input
.
GetKeyDown
(
KeyCode
.
Tab
)
&&
GameManager
.
gameState
==
GameManager
.
GameState
.
Ingame
)
{
GameManager
.
gameState
=
GameManager
.
GameState
.
Tetris
;
tetrisCamera
.
GetComponent
<
Camera
>().
enabled
=
true
;
mainCamera
.
GetComponent
<
Camera
>().
enabled
=
false
;
}
else
if
(
Input
.
GetKeyDown
(
KeyCode
.
Tab
)
&&
GameManager
.
gameState
==
GameManager
.
GameState
.
Tetris
)
{
GameManager
.
gameState
=
GameManager
.
GameState
.
Ingame
;
tetrisCamera
.
GetComponent
<
Camera
>().
enabled
=
false
;
mainCamera
.
GetComponent
<
Camera
>().
enabled
=
true
;
GotoDestination
();
}
}
}
\ No newline at end of file
Assets/Scripts/GameManager.cs
View file @
25d8e581
...
@@ -14,12 +14,12 @@ public class GameManager : MonoBehaviour {
...
@@ -14,12 +14,12 @@ public class GameManager : MonoBehaviour {
// Use this for initialization
// Use this for initialization
void
Start
()
{
void
Start
()
{
gameState
=
GameState
.
Tetris
;
var
TS
=
GameObject
.
Find
(
"TetriminoSpawner"
).
GetComponent
<
TetriminoSpawner
>();
var
TS
=
GameObject
.
Find
(
"TetriminoSpawner"
).
GetComponent
<
TetriminoSpawner
>();
gameState
=
GameState
.
Ingame
;
TS
.
MakeInitialTetrimino
();
TS
.
MakeInitialTetrimino
();
Vector2
coord
=
GameObject
.
Find
(
"MapManager"
).
GetComponent
<
MapManager
>().
startRoom
.
transform
.
position
;
Vector2
coord
=
GameObject
.
Find
(
"MapManager"
).
GetComponent
<
MapManager
>().
startRoom
.
transform
.
position
;
//
GameObject.Find("Player").transform.position = new Vector2(coord.x, coord.y) + new Vector2(3, 3);
GameObject
.
Find
(
"Player"
).
transform
.
position
=
new
Vector2
(
coord
.
x
,
coord
.
y
)
+
new
Vector2
(
3
,
3
);
}
}
...
...
Assets/Scripts/TetrisMap/MapManager.cs
View file @
25d8e581
...
@@ -454,7 +454,9 @@ public class MapManager : MonoBehaviour {
...
@@ -454,7 +454,9 @@ public class MapManager : MonoBehaviour {
Instantiate
(
specialRoomList
[(
int
)
te
.
rooms
[
i
].
specialRoomType
],
te
.
rooms
[
i
].
transform
.
position
+
new
Vector3
(
0
,
0
,
2
),
Quaternion
.
identity
,
te
.
rooms
[
i
].
transform
);
Instantiate
(
specialRoomList
[(
int
)
te
.
rooms
[
i
].
specialRoomType
],
te
.
rooms
[
i
].
transform
.
position
+
new
Vector3
(
0
,
0
,
2
),
Quaternion
.
identity
,
te
.
rooms
[
i
].
transform
);
}
}
else
else
{
Instantiate
(
normalRoomList
[
Random
.
Range
(
0
,
normalRoomList
.
Length
)],
te
.
rooms
[
i
].
transform
.
position
+
new
Vector3
(
0
,
0
,
2
),
Quaternion
.
identity
,
te
.
rooms
[
i
].
transform
);
Instantiate
(
normalRoomList
[
Random
.
Range
(
0
,
normalRoomList
.
Length
)],
te
.
rooms
[
i
].
transform
.
position
+
new
Vector3
(
0
,
0
,
2
),
Quaternion
.
identity
,
te
.
rooms
[
i
].
transform
);
}
}
}
Destroy
(
te
.
gameObject
);
Destroy
(
te
.
gameObject
);
}
}
...
...
Assets/Scripts/TetrisMap/Test.cs
View file @
25d8e581
...
@@ -36,13 +36,13 @@ public class Test : MonoBehaviour {
...
@@ -36,13 +36,13 @@ public class Test : MonoBehaviour {
ChangeTetrimino
();
ChangeTetrimino
();
if
(
Input
.
GetKeyDown
(
KeyCode
.
Alpha2
))
if
(
Input
.
GetKeyDown
(
KeyCode
.
Alpha2
))
SpawnBossTetrimino
();
SpawnBossTetrimino
();
if
(
Input
.
GetKeyDown
(
KeyCode
.
Tab
)
&&
GameManager
.
gameState
!=
GameManager
.
GameState
.
Tetris
)
/*
if (Input.GetKeyDown(KeyCode.Tab) && GameManager.gameState != GameManager.GameState.Tetris)
{
{
GameManager.gameState = GameManager.GameState.Tetris;
GameManager.gameState = GameManager.GameState.Tetris;
GameObject.Find("Main Camera").transform.position = tetrisCameraCoord;
GameObject.Find("Main Camera").transform.position = tetrisCameraCoord;
GameObject.Find("Main Camera").GetComponent<Camera>().orthographicSize = tetrisMapSize;
GameObject.Find("Main Camera").GetComponent<Camera>().orthographicSize = tetrisMapSize;
}
}
else if (Input.GetKeyDown(KeyCode.Tab) && GameManager.gameState == GameManager.GameState.Tetris)
else if (Input.GetKeyDown(KeyCode.Tab) && GameManager.gameState == GameManager.GameState.Tetris)
GameManager
.
gameState
=
GameManager
.
GameState
.
Ingame
;
GameManager.gameState = GameManager.GameState.Ingame;
*/
}
}
}
}
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