Commit be57d90b authored by 18손재민's avatar 18손재민

방 이동할 때 버그 수정, 이제 포탈을 사용할 땐 테트리미노가 떨어지거나 프레스가 작동하는등의 기능이 정지함. 또 프레스가 생성된 줄의 포탈은 즉시 삭제됨

parent cd735704
......@@ -51,4 +51,5 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 97912f0a2214a8a4f8023ed30629bb30, type: 3}
m_Name:
m_EditorClassIdentifier:
gameOverScreen: {fileID: 0}
gameOverScreen: {fileID: 223237664237935382, guid: 692aad2449e06054799ea4706578fb23,
type: 2}
This diff is collapsed.
fileFormatVersion: 2
guid: 692aad2449e06054799ea4706578fb23
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 100100000
userData:
assetBundleName:
assetBundleVariant:
......@@ -93,18 +93,6 @@ public class CameraController : MonoBehaviour {
else if(gameState == GameState.Portal)
{
GameManager.gameState = GameState.Portal;
for (int x = 0; x < MapManager.width; x++)
MapManager.portalDistributedHorizontal[x].Clear();
for (int y = 0; y <= MapManager.realHeight; y++)
MapManager.portalDistributedVertical[y].Clear();
for (int x = 0; x < MapManager.width; x++)
for (int y = 0; y <= MapManager.realHeight; y++)
if (MapManager.mapGrid[x, y] != null && MapManager.mapGrid[x, y].isPortal == true)
{
MapManager.portalGrid[x, y] = true;
MapManager.portalDistributedHorizontal[x].Add(y);
MapManager.portalDistributedVertical[y].Add(x);
}
MapManager.portalDestination = MapManager.currentRoom.mapCoord;
MapManager.mapGrid[(int)MapManager.portalDestination.x, (int)MapManager.portalDestination.y].portalSurface.GetComponent<SpriteRenderer>().sprite =
GameObject.Find("MapManager").GetComponent<MapManager>().portalSelected;
......
......@@ -8,8 +8,6 @@ public class Player : MonoBehaviour {
public static float X=0.7f, Y=1.6f;
public int ttx;
public int tty;
Coroutine roomEnterFadeIn;
Coroutine roomExitFadeOut;
// Use this for initialization
void Start () {
......
......@@ -85,7 +85,7 @@ public class PlayerController : MonoBehaviour
{
isGrounded = IsGrounded();
if (GameManager.gameState == GameState.Ingame)
if (GameManager.gameState == GameState.Ingame && MapManager.isDoorClosing != true)
{
if (isGrounded)
......
......@@ -32,7 +32,9 @@ public class GameManager : MonoBehaviour {
// Update is called once per frame
void Update ()
{
if (Input.GetKeyDown(KeyCode.Tab) && CameraController.isSceneChanging != true)
if(CameraController.isSceneChanging != true)
{
if (Input.GetKeyDown(KeyCode.Tab))
{
if (gameState == GameState.Ingame)
{
......@@ -43,9 +45,9 @@ public class GameManager : MonoBehaviour {
StartCoroutine(GameObject.FindGameObjectWithTag("MainCamera").GetComponent<CameraController>().ChangeScene(GameState.Ingame));
}
}
if (Input.GetKeyDown(KeyCode.Escape) && CameraController.isSceneChanging != true)
if (Input.GetKeyDown(KeyCode.F))
{
if (gameState == GameState.Portal)
if (gameState == GameState.Portal && MapManager.currentRoom != MapManager.mapGrid[(int)MapManager.portalDestination.x, (int)MapManager.portalDestination.y])
{
GameObject.Find("Player").transform.position = MapManager.mapGrid[(int)MapManager.portalDestination.x, (int)MapManager.portalDestination.y].portal.transform.position + new Vector3(2, 1, 0);
GameObject.Find("MapManager").GetComponent<MapManager>().ChangeRoom(MapManager.mapGrid[(int)MapManager.portalDestination.x, (int)MapManager.portalDestination.y]);
......@@ -54,6 +56,13 @@ public class GameManager : MonoBehaviour {
StartCoroutine(GameObject.FindGameObjectWithTag("MainCamera").GetComponent<CameraController>().ChangeScene(GameState.Ingame));
}
}
if (Input.GetKeyDown(KeyCode.Escape))
{
MapManager.mapGrid[(int)MapManager.currentRoom.mapCoord.x, (int)MapManager.currentRoom.mapCoord.y].portalSurface.GetComponent<SpriteRenderer>().sprite =
GameObject.Find("MapManager").GetComponent<MapManager>().portalExist;
StartCoroutine(GameObject.FindGameObjectWithTag("MainCamera").GetComponent<CameraController>().ChangeScene(GameState.Ingame));
}
}
if(gameState == GameState.GameOver)
{
if(gameOverScreen.isActiveAndEnabled == false)
......
......@@ -5,7 +5,6 @@ using UnityEngine;
public class MapManager : MonoBehaviour {
public static bool isDoorClosing = false;
/*
* variables
* */
......@@ -82,6 +81,10 @@ public class MapManager : MonoBehaviour {
/// </summary>
public static bool isRoomFalling = false;
/// <summary>
/// Check if door is closing or not.
/// </summary>
public static bool isDoorClosing = false;
/// <summary>
/// Check if this row is being deleted.
/// </summary>
public static bool[] isRowDeleting = new bool[20];
......@@ -303,12 +306,26 @@ public class MapManager : MonoBehaviour {
int roomDestroyCounter = 0;
int row = leftPress.row;
float collapseSpeed = (float)20 / collapseTime * Time.deltaTime;
portalDistributedVertical[row].Clear();
for(int i = 0; i < portalDistributedHorizontal.Length; i++)
portalDistributedHorizontal[i].Remove(row);
for(int i = 0; i < width; i++)
if (mapGrid[i, row].isPortal == true)
{
mapGrid[i, row].isPortal = false;
Destroy(mapGrid[i, row].portalSurface);
mapGrid[i, row].portal.SetActive(false);
}
leftPress.transform.localScale = new Vector3(0, 1, 1);
rightPress.transform.localScale = new Vector3(0, 1, 1);
float collapseRate = leftPress.transform.localScale.x;
while (collapseRate < 20)
{
while (GameManager.gameState == GameState.Portal)
{
yield return null;
}
yield return null;
if (currentRoom.mapCoord.y == row)
collapseSpeed = (float)2 / collapseTime * Time.deltaTime;
else
......@@ -427,6 +444,10 @@ public class MapManager : MonoBehaviour {
Vector3 previousPlayerRelativePosition = player.transform.position - currentRoom.transform.position;
while (tetrisYCoord[top + 1] > bottom * tetrisMapSize)
{
while (GameManager.gameState == GameState.Portal)
{
yield return null;
}
yield return new WaitForSeconds(0.01f);
if (isRowDeleting[top + 1])
{
......@@ -513,6 +534,11 @@ public class MapManager : MonoBehaviour {
{
while (!isTetriminoFalling)
{
while (GameManager.gameState == GameState.Portal)
{
tetriminoCreatedTime += Time.deltaTime;
yield return null;
}
yield return new WaitForSeconds(0.1f);
tetriminoWaitedTime = Time.time - tetriminoCreatedTime;
}
......@@ -636,6 +662,10 @@ public class MapManager : MonoBehaviour {
{
while(te.transform.position.y > tetrisYCoord[(int)te.mapCoord.y])
{
while (GameManager.gameState == GameState.Portal)
{
yield return null;
}
yield return new WaitForSeconds(0.01f);
fallTime = Time.time - initialFallTime;
fallSpeed += gravity * fallTime * fallTime;
......@@ -819,6 +849,8 @@ public class MapManager : MonoBehaviour {
float alpha = 1;
for (int i = 0; i < 20; i++)
{
if(i == 6)
isDoorClosing = false;
yield return new WaitForSeconds(0.01f);
room.leftTetrisDoor.GetComponent<SpriteRenderer>().color = new Color(1, 1, 1, alpha);
room.rightTetrisDoor.GetComponent<SpriteRenderer>().color = new Color(1, 1, 1, alpha);
......@@ -828,7 +860,6 @@ public class MapManager : MonoBehaviour {
room.leftTetrisDoor.GetComponent<SpriteRenderer>().color = new Color(1, 1, 1, 0);
room.rightTetrisDoor.GetComponent<SpriteRenderer>().color = new Color(1, 1, 1, 0);
room.fog.GetComponent<SpriteRenderer>().color = new Color(1, 1, 1, 0);
isDoorClosing = false;
}
/// <summary>
/// Make room fade out.
......@@ -850,10 +881,9 @@ public class MapManager : MonoBehaviour {
room.rightTetrisDoor.GetComponent<SpriteRenderer>().color = new Color(1, 1, 1, 1);
room.fog.GetComponent<SpriteRenderer>().color = new Color(1, 1, 1, 1);
}
/// <summary>
/// Control portal's move.
/// </summary>
public void PortalControl()
{
int minDifference = 100;
......
......@@ -7,8 +7,10 @@ public class Portal : MonoBehaviour {
private void OnTriggerStay2D(Collider2D collision)
{
if (collision.tag.Equals("Player") && Input.GetKeyDown(KeyCode.F))
{
StartCoroutine(GameObject.FindGameObjectWithTag("MainCamera").GetComponent<CameraController>().ChangeScene(GameState.Portal));
}
}
// Use this for initialization
void Start () {
......
......@@ -384,7 +384,21 @@ public class Room : MonoBehaviour
fog.GetComponent<SpriteRenderer>().color = new Color(1, 1, 1, 0);
CreatePortal();
if (isPortal == true)
{
for (int x = 0; x < MapManager.width; x++)
MapManager.portalDistributedHorizontal[x].Clear();
for (int y = 0; y <= MapManager.realHeight; y++)
MapManager.portalDistributedVertical[y].Clear();
for (int x = 0; x < MapManager.width; x++)
for (int y = 0; y <= MapManager.realHeight; y++)
if (MapManager.mapGrid[x, y] != null && MapManager.mapGrid[x, y].isPortal == true)
{
MapManager.portalGrid[x, y] = true;
MapManager.portalDistributedHorizontal[x].Add(y);
MapManager.portalDistributedVertical[y].Add(x);
}
portalSurface = Instantiate(GameObject.Find("MapManager").GetComponent<MapManager>().portalSurface, transform.position + new Vector3(12, 12, 0), Quaternion.identity, transform);
}
isRoomCleared = true;
if (specialRoomType == RoomType.Boss)
MapManager.currentStage += 1;
......
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