Commit 64e0be2e authored by 18손재민's avatar 18손재민

플레이어가 프레스에 닿거나 플레이어가 있는 방이 삭제될 경우 게임오버됨. 기타 안개 관련 버그 수정함

parent f352e138
......@@ -81,7 +81,7 @@ MonoBehaviour:
- {fileID: 114071400998216906, guid: 7fd2833846bb116479bd74d2a5b75487, type: 2}
- {fileID: 114640962302007900, guid: 8a277fab4c930814a89f83d11e915f3b, type: 2}
- {fileID: 114565175836539902, guid: 5712fafd2b645fe488586143d15320c3, type: 2}
- {fileID: 114367761397601772, guid: e755ae028f96c11478d088a2fbc15284, type: 2}
- {fileID: 114653824325995262, guid: e755ae028f96c11478d088a2fbc15284, type: 2}
- {fileID: 114798299154452666, guid: b2aea3753aeb72e48877392a65019c75, type: 2}
- {fileID: 114392719690591750, guid: 1b7e15c651b43934ba83bf5af546dac8, type: 2}
- {fileID: 114692431959263760, guid: bcdfbba992e4b5c40a05376093119de1, type: 2}
......
......@@ -104,7 +104,6 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 70108dd0bfd72e847b1580dbd0869ce1, type: 3}
m_Name:
m_EditorClassIdentifier:
close: 0
position: 0
enteredPosition: 0
animatorThisRoom: {fileID: 0}
......
......@@ -21,6 +21,7 @@ GameObject:
- component: {fileID: 4390237108358754}
- component: {fileID: 212490318858521944}
- component: {fileID: 114990664041074520}
- component: {fileID: 61335043634374544}
m_Layer: 0
m_Name: Press
m_TagString: Untagged
......@@ -41,6 +42,31 @@ Transform:
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!61 &61335043634374544
BoxCollider2D:
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1842283105111692}
m_Enabled: 1
m_Density: 1
m_Material: {fileID: 0}
m_IsTrigger: 1
m_UsedByEffector: 0
m_UsedByComposite: 0
m_Offset: {x: 3, y: 12}
m_SpriteTilingProperty:
border: {x: 0, y: 0, z: 0, w: 0}
pivot: {x: 0, y: 0}
oldSize: {x: 6, y: 24}
newSize: {x: 0.64, y: 2.56}
adaptiveTilingThreshold: 0.5
drawMode: 0
adaptiveTiling: 0
m_AutoTiling: 0
serializedVersion: 2
m_Size: {x: 6, y: 24}
m_EdgeRadius: 0
--- !u!114 &114990664041074520
MonoBehaviour:
m_ObjectHideFlags: 1
......@@ -52,6 +78,12 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 8de047d1ea5a84a4b90377ec18a40ccd, type: 3}
m_Name:
m_EditorClassIdentifier:
initialCollapseTime: 0
row: 0
bottomRow: 0
createdOrder: 0
simultaneouslyCreatedPressNumber: 0
isLeft: 0
--- !u!212 &212490318858521944
SpriteRenderer:
m_ObjectHideFlags: 1
......
......@@ -51,6 +51,12 @@ public class CameraController : MonoBehaviour {
else if (GameManager.gameState == GameManager.GameState.Tetris)
originPos = tetrisCameraCoord;
}
/// <summary>
/// Shake camera.
/// </summary>
/// <param name="_amount">Amount of shaking camera.</param>
/// <returns></returns>
public IEnumerator CameraShake(float _amount)
{
float amount = _amount;
......@@ -64,24 +70,29 @@ public class CameraController : MonoBehaviour {
transform.localPosition = originPos;
}
public IEnumerator ChangeScene(GameManager.GameState _gameState)
/// <summary>
/// Change scene between tetris and ingame.
/// </summary>
/// <returns></returns>
public IEnumerator ChangeScene()
{
GameObject grid = GameObject.Find("Grid");
float sizeDestination = 0;
isSceneChanging = true;
if (_gameState == GameManager.GameState.Ingame)
if (GameManager.gameState == GameManager.GameState.Ingame)
{
StartCoroutine(mapManager.RoomFadeIn(MapManager.currentRoom));
grid.transform.position = new Vector3(0, 0, 0);
sizeDestination = inGameCameraSize;
}
else if (_gameState == GameManager.GameState.Tetris)
else if (GameManager.gameState == GameManager.GameState.Tetris)
{
StartCoroutine(mapManager.RoomFadeOut(MapManager.currentRoom));
grid.transform.position = new Vector3(0, 0, 2);
sizeDestination = tetrisCameraSize;
}
while ((_gameState == GameManager.GameState.Tetris && GetComponent<Camera>().orthographicSize < sizeDestination - 5) || (_gameState == GameManager.GameState.Ingame && GetComponent<Camera>().orthographicSize > sizeDestination + 0.05))
while ((GameManager.gameState == GameManager.GameState.Tetris && GetComponent<Camera>().orthographicSize < sizeDestination - 5) ||
(GameManager.gameState == GameManager.GameState.Ingame && GetComponent<Camera>().orthographicSize > sizeDestination + 0.05))
{
yield return null;
Vector2 coord = Vector2.Lerp(transform.position, originPos, Mathf.Sqrt(Time.deltaTime));
......
......@@ -4,7 +4,7 @@ using UnityEngine;
public class GameManager : MonoBehaviour {
public enum GameState { MainMenu, Ingame, Tetris, Pause, Inventory }
public enum GameState { MainMenu, Ingame, Tetris, Pause, Inventory, GameOver }
/// <summary>
/// Which state this game is.
......@@ -32,7 +32,7 @@ public class GameManager : MonoBehaviour {
gameState = GameState.Tetris;
else if (gameState == GameState.Tetris)
gameState = GameState.Ingame;
StartCoroutine(FindObjectOfType<Camera>().GetComponent<CameraController>().ChangeScene(gameState));
StartCoroutine(FindObjectOfType<Camera>().GetComponent<CameraController>().ChangeScene());
}
}
}
......@@ -4,37 +4,63 @@ using UnityEngine;
public class Door : MonoBehaviour {
/// <summary>
/// Position of this door.
/// 0 for up, 1 for right, 2 for down, 3 for left.
/// </summary>
public int position;
/// <summary>
/// Entered position of the player. Use this for check if player has entered through this door or not.
/// 0 for up, 1 for right, 2 for down, 3 for left.
/// </summary>
public int enteredPosition;
/// <summary>
/// Animator of this door.
/// </summary>
public Animator animatorThisRoom;
/// <summary>
/// Animator of adjacent door with this door.
/// </summary>
public Animator animatorNextRoom;
private void OnTriggerExit2D(Collider2D collision)
{
if (enteredPosition == position && collision.tag.Equals("Player"))
{
bool a = false;
switch (position)
{
case 0:
if (collision.transform.position.y < GetComponent<PolygonCollider2D>().transform.position.y)
{
Debug.Log("case 0" + position + " " + enteredPosition);
return;
}
enteredPosition = 2;
break;
case 1:
if (collision.transform.position.x < GetComponent<PolygonCollider2D>().transform.position.x)
return;
enteredPosition = 3;
break;
case 2:
if (collision.transform.position.y > GetComponent<PolygonCollider2D>().transform.position.y)
{
Debug.Log("case 2" + position + " " + enteredPosition);
return;
}
enteredPosition = 0;
break;
case 3:
if (collision.transform.position.x > GetComponent<PolygonCollider2D>().transform.position.x)
return;
enteredPosition = 1;
break;
}
StartCoroutine(GameObject.Find("MapManager").GetComponent<MapManager>().RoomFadeOut(MapManager.currentRoom));
MapManager.currentRoom = MapManager.tempRoom;
StartCoroutine(GameObject.Find("MapManager").GetComponent<MapManager>().RoomFadeIn(MapManager.currentRoom));
if (MapManager.currentRoom.isRoomCleared != true)
{
animatorThisRoom.SetBool("isPlayerTouchEnded", true);
......@@ -44,7 +70,6 @@ public class Door : MonoBehaviour {
animatorThisRoom.SetBool("doorClose", true);
animatorNextRoom.SetBool("doorClose", true);
}
}
}
}
......@@ -61,10 +61,6 @@ public class MapManager : MonoBehaviour {
/// </summary>
public static Room[,] mapGrid = new Room[width, height];
/// <summary>
/// Current state of game.
/// </summary>
public bool gameOver;
/// <summary>
/// Check if tetrimino is falling.
/// </summary>
public static bool isTetriminoFalling = false;
......@@ -161,10 +157,6 @@ public class MapManager : MonoBehaviour {
/// Queue that saves rooms waiting for upgrade tetrimino.
/// </summary>
public Queue<SpecialRoomType> roomsWaiting = new Queue<SpecialRoomType>();
/// <summary>
/// Original position of the camera when shaken.
/// </summary>
public static Vector3 originPos;
/*
* functions
......@@ -263,7 +255,8 @@ public class MapManager : MonoBehaviour {
/// <returns></returns>
public IEnumerator TetrisPress(float initialCollapseTime, Press leftPress, Press rightPress)
{
int doorCounter = 0;
int doorCloseCounter = 0;
int roomDestroyCounter = 0;
int row = leftPress.row;
while (Time.time - initialCollapseTime < collapseTime)
{
......@@ -271,13 +264,23 @@ public class MapManager : MonoBehaviour {
float collapseRate = (Time.time - initialCollapseTime) / collapseTime;
leftPress.transform.localScale = new Vector3(collapseRate * 20, 1, 1);
rightPress.transform.localScale = new Vector3(-collapseRate * 20, 1, 1);
if(collapseRate - doorCounter * 0.2f > (float)1 / 12)
if(collapseRate - doorCloseCounter * 0.2f > (float)1 / 12)
{
mapGrid[doorCounter, row].CloseDoor("Up", false);
mapGrid[doorCounter, row].CloseDoor("Down", false);
mapGrid[width - doorCounter - 1, row].CloseDoor("Up", false);
mapGrid[width - doorCounter - 1, row].CloseDoor("Down", false);
doorCounter++;
mapGrid[doorCloseCounter, row].CloseDoor("Up", false);
mapGrid[doorCloseCounter, row].CloseDoor("Down", false);
mapGrid[width - doorCloseCounter - 1, row].CloseDoor("Up", false);
mapGrid[width - doorCloseCounter - 1, row].CloseDoor("Down", false);
doorCloseCounter++;
}
if(collapseRate - roomDestroyCounter * 0.2f > 0.2f)
{
if(mapGrid[roomDestroyCounter, row] == currentRoom || mapGrid[width - roomDestroyCounter - 1, row] == currentRoom)
{
GameManager.gameState = GameManager.GameState.GameOver;
}
//Destroy(mapGrid[roomDestroyCounter, row].gameObject);
//Destroy(mapGrid[width - roomDestroyCounter - 1, row].gameObject);
roomDestroyCounter++;
}
}
for(int i = row + 1; i < realHeight; i++)
......@@ -288,7 +291,7 @@ public class MapManager : MonoBehaviour {
break;
}
}
for (int x = 0; x < width; x++)
for(int x = 0; x < width; x++)
{
Destroy(mapGrid[x, row].gameObject);
mapGrid[x, row] = null;
......@@ -445,8 +448,7 @@ public class MapManager : MonoBehaviour {
{
if ((int)te.rooms[i].mapCoord.y > 19)
{
gameOver = true;
Debug.Log("Game Over");
GameManager.gameState = GameManager.GameState.GameOver;
return;
}
mapGrid[(int)te.rooms[i].mapCoord.x, (int)te.rooms[i].mapCoord.y] = te.rooms[i];
......@@ -728,27 +730,6 @@ public class MapManager : MonoBehaviour {
yield return new WaitForSeconds(1f);
tetriminoSpawner.MakeTetrimino();
}
/*/// <summary>
/// Shake the camera when tetrimino has fallen.
/// </summary>
/// <param name="_amount">Amount you want to shake the camera.</param>
/// <param name="originPos">Original position of the camera.</param>
/// <param name="camera">Camera you want to shake.</param>
/// <returns></returns>
public IEnumerator CameraShake(float _amount, Vector3 _originPos, Camera camera)
{
float amount = _amount;
Vector3 cameraPos = _originPos;
originPos = _originPos;
while (amount > 0)
{
cameraPos = new Vector3(0.2f * Random.insideUnitCircle.x * amount * camera.orthographicSize + originPos.x, Random.insideUnitCircle.y * amount * camera.orthographicSize + originPos.y, originPos.z);
camera.transform.position = cameraPos;
amount -= _amount / 40;
yield return null;
}
camera.transform.localPosition = originPos;
}*/
/// <summary>
/// Make room fade in.
/// </summary>
......@@ -831,6 +812,7 @@ public class MapManager : MonoBehaviour {
}
tetriminoSpawner = GameObject.Find("TetriminoSpawner").GetComponent<TetriminoSpawner>();
}
// Use this for initialization
void Start () {
......@@ -838,20 +820,22 @@ public class MapManager : MonoBehaviour {
// Update is called once per frame
void Update() {
if (!gameOver)
if (GameManager.gameState != GameManager.GameState.GameOver)
{
if(!isTetriminoFalling)
if (!isTetriminoFalling)
{
TetriminoControl(currentTetrimino);
if(!isTetriminoFalling)
if (!isTetriminoFalling)
currentTetrimino.transform.position = new Vector3(currentTetrimino.mapCoord.x * tetrisMapSize, tetrisYCoord[(int)currentTetrimino.mapCoord.y], currentTetrimino.mapCoord.z);
if(currentGhost != null)
if (currentGhost != null)
{
GhostControl(currentGhost, currentTetrimino);
currentGhost.transform.position = new Vector3(currentGhost.mapCoord.x * tetrisMapSize, tetrisYCoord[(int)currentGhost.mapCoord.y], currentGhost.mapCoord.z);
GhostControl(currentGhost, currentTetrimino);
currentGhost.transform.position = new Vector3(currentGhost.mapCoord.x * tetrisMapSize, tetrisYCoord[(int)currentGhost.mapCoord.y], currentGhost.mapCoord.z);
}
}
}
else
Debug.Log("Game Over");
}
}
......@@ -32,6 +32,11 @@ public class Press : MonoBehaviour
/// </summary>
public bool isLeft;
private void OnTriggerEnter2D(Collider2D collision)
{
if(collision.transform.tag.Equals("Player"))
GameManager.gameState = GameManager.GameState.GameOver;
}
// Use this for initialization
void Start () {
......
......@@ -267,7 +267,6 @@ public class Room : MonoBehaviour
}
}
}
/// <summary>
/// Clear the cleared room.
/// Open all the doors and change fog to cleared fog.
......
......@@ -29,7 +29,7 @@ public class TetriminoSpawner : MonoBehaviour {
/// </summary>
public void MakeTetrimino()
{
if (!mapManager.gameOver)
if (GameManager.gameState != GameManager.GameState.GameOver)
{
int randomPosition = Random.Range(0, MapManager.width);
int randomTetrimino;
......@@ -67,7 +67,7 @@ public class TetriminoSpawner : MonoBehaviour {
/// </summary>
public void MakeInitialTetrimino()
{
if (!mapManager.gameOver)
if (GameManager.gameState != GameManager.GameState.GameOver)
{
int randomPosition = Random.Range(0, MapManager.width);
int randomTetrimino = TetriminoRandomizer();
......
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:engine="UnityEngine.Experimental.UIElements" xmlns:editor="UnityEditor.Experimental.UIElements" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:import schemaLocation="UnityEngine.Experimental.UIElements.xsd" namespace="UnityEngine.Experimental.UIElements" />
<xs:import schemaLocation="UnityEditor.PackageManager.UI.xsd" namespace="UnityEditor.PackageManager.UI" />
<xs:import schemaLocation="UnityEditor.Experimental.UIElements.xsd" namespace="UnityEditor.Experimental.UIElements" />
</xs:schema>
\ No newline at end of file
This diff is collapsed.
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:engine="UnityEngine.Experimental.UIElements" xmlns:editor="UnityEditor.Experimental.UIElements" elementFormDefault="qualified" targetNamespace="UnityEditor.PackageManager.UI" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:import schemaLocation="UnityEngine.Experimental.UIElements.xsd" namespace="UnityEngine.Experimental.UIElements" />
<xs:complexType name="AlertType">
<xs:complexContent mixed="false">
<xs:restriction base="engine:VisualElementType">
<xs:sequence minOccurs="0" maxOccurs="unbounded">
<xs:element ref="engine:VisualElement" />
</xs:sequence>
<xs:attribute default="" name="name" type="xs:string" use="optional" />
<xs:attribute default="Position" name="pickingMode" type="engine:VisualElement_pickingMode_Type" use="optional" />
<xs:attribute default="-1" name="focusIndex" type="xs:int" use="optional" />
<xs:anyAttribute processContents="lax" />
</xs:restriction>
</xs:complexContent>
</xs:complexType>
<xs:element name="Alert" substitutionGroup="engine:VisualElement" xmlns:q1="UnityEditor.PackageManager.UI" type="q1:AlertType" />
<xs:complexType name="LoadingSpinnerType">
<xs:complexContent mixed="false">
<xs:restriction base="engine:VisualElementType">
<xs:sequence minOccurs="0" maxOccurs="unbounded">
<xs:element ref="engine:VisualElement" />
</xs:sequence>
<xs:attribute default="" name="name" type="xs:string" use="optional" />
<xs:attribute default="Position" name="pickingMode" type="engine:VisualElement_pickingMode_Type" use="optional" />
<xs:attribute default="-1" name="focusIndex" type="xs:int" use="optional" />
<xs:anyAttribute processContents="lax" />
</xs:restriction>
</xs:complexContent>
</xs:complexType>
<xs:element name="LoadingSpinner" substitutionGroup="engine:VisualElement" xmlns:q2="UnityEditor.PackageManager.UI" type="q2:LoadingSpinnerType" />
<xs:complexType name="PackageDetailsType">
<xs:complexContent mixed="false">
<xs:restriction base="engine:VisualElementType">
<xs:sequence minOccurs="0" maxOccurs="unbounded">
<xs:element ref="engine:VisualElement" />
</xs:sequence>
<xs:attribute default="" name="name" type="xs:string" use="optional" />
<xs:attribute default="Position" name="pickingMode" type="engine:VisualElement_pickingMode_Type" use="optional" />
<xs:attribute default="-1" name="focusIndex" type="xs:int" use="optional" />
<xs:anyAttribute processContents="lax" />
</xs:restriction>
</xs:complexContent>
</xs:complexType>
<xs:element name="PackageDetails" substitutionGroup="engine:VisualElement" xmlns:q3="UnityEditor.PackageManager.UI" type="q3:PackageDetailsType" />
<xs:complexType name="PackageGroupType">
<xs:complexContent mixed="false">
<xs:restriction base="engine:VisualElementType">
<xs:sequence minOccurs="0" maxOccurs="unbounded">
<xs:element ref="engine:VisualElement" />
</xs:sequence>
<xs:attribute default="" name="name" type="xs:string" use="optional" />
<xs:attribute default="Position" name="pickingMode" type="engine:VisualElement_pickingMode_Type" use="optional" />
<xs:attribute default="-1" name="focusIndex" type="xs:int" use="optional" />
<xs:anyAttribute processContents="lax" />
</xs:restriction>
</xs:complexContent>
</xs:complexType>
<xs:element name="PackageGroup" substitutionGroup="engine:VisualElement" xmlns:q4="UnityEditor.PackageManager.UI" type="q4:PackageGroupType" />
<xs:complexType name="PackageItemType">
<xs:complexContent mixed="false">
<xs:restriction base="engine:VisualElementType">
<xs:sequence minOccurs="0" maxOccurs="unbounded">
<xs:element ref="engine:VisualElement" />
</xs:sequence>
<xs:attribute default="" name="name" type="xs:string" use="optional" />
<xs:attribute default="Position" name="pickingMode" type="engine:VisualElement_pickingMode_Type" use="optional" />
<xs:attribute default="-1" name="focusIndex" type="xs:int" use="optional" />
<xs:anyAttribute processContents="lax" />
</xs:restriction>
</xs:complexContent>
</xs:complexType>
<xs:element name="PackageItem" substitutionGroup="engine:VisualElement" xmlns:q5="UnityEditor.PackageManager.UI" type="q5:PackageItemType" />
<xs:complexType name="PackageListType">
<xs:complexContent mixed="false">
<xs:restriction base="engine:VisualElementType">
<xs:sequence minOccurs="0" maxOccurs="unbounded">
<xs:element ref="engine:VisualElement" />
</xs:sequence>
<xs:attribute default="" name="name" type="xs:string" use="optional" />
<xs:attribute default="Position" name="pickingMode" type="engine:VisualElement_pickingMode_Type" use="optional" />
<xs:attribute default="-1" name="focusIndex" type="xs:int" use="optional" />
<xs:anyAttribute processContents="lax" />
</xs:restriction>
</xs:complexContent>
</xs:complexType>
<xs:element name="PackageList" substitutionGroup="engine:VisualElement" xmlns:q6="UnityEditor.PackageManager.UI" type="q6:PackageListType" />
<xs:complexType name="PackageSearchFilterTabsType">
<xs:complexContent mixed="false">
<xs:restriction base="engine:VisualElementType">
<xs:sequence minOccurs="0" maxOccurs="unbounded">
<xs:element ref="engine:VisualElement" />
</xs:sequence>
<xs:attribute default="" name="name" type="xs:string" use="optional" />
<xs:attribute default="Position" name="pickingMode" type="engine:VisualElement_pickingMode_Type" use="optional" />
<xs:attribute default="-1" name="focusIndex" type="xs:int" use="optional" />
<xs:anyAttribute processContents="lax" />
</xs:restriction>
</xs:complexContent>
</xs:complexType>
<xs:element name="PackageSearchFilterTabs" substitutionGroup="engine:VisualElement" xmlns:q7="UnityEditor.PackageManager.UI" type="q7:PackageSearchFilterTabsType" />
<xs:complexType name="PackagesLoadingType">
<xs:complexContent mixed="false">
<xs:restriction base="engine:VisualElementType">
<xs:sequence minOccurs="0" maxOccurs="unbounded">
<xs:element ref="engine:VisualElement" />
</xs:sequence>
<xs:attribute default="" name="name" type="xs:string" use="optional" />
<xs:attribute default="Position" name="pickingMode" type="engine:VisualElement_pickingMode_Type" use="optional" />
<xs:attribute default="-1" name="focusIndex" type="xs:int" use="optional" />
<xs:anyAttribute processContents="lax" />
</xs:restriction>
</xs:complexContent>
</xs:complexType>
<xs:element name="PackagesLoading" substitutionGroup="engine:VisualElement" xmlns:q8="UnityEditor.PackageManager.UI" type="q8:PackagesLoadingType" />
</xs:schema>
\ No newline at end of file
This diff is collapsed.
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