Commit 25d8e581 authored by 18손재민's avatar 18손재민

카메라 매니저 만듬. 탭키 누르면 화면 전환됩니다.

parent 3dfa41f9
...@@ -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, -10); //카메라를 원래 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
...@@ -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);
} }
......
...@@ -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);
} }
......
...@@ -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;*/
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment