Commit 5c8e1c1c authored by 18손재민's avatar 18손재민

게임 오버 및 재시작 wip, 현재 게임 오버 되면 맵이 그냥 삭제됨

parent d37db3d0
fileFormatVersion: 2
guid: 782c2a74f38e2544797cc7d82d6e01d5
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
...@@ -45,8 +45,8 @@ MonoBehaviour: ...@@ -45,8 +45,8 @@ MonoBehaviour:
m_EditorClassIdentifier: m_EditorClassIdentifier:
isMapEditingOn: 0 isMapEditingOn: 0
surface: {fileID: 0} surface: {fileID: 0}
currentMap: {fileID: 630498074781569474, guid: 759f352c81f1b5a40b2d8d241cdf273b, currentMap: {fileID: 0}
type: 3} emptyMap: {fileID: 630498074781569474, guid: 759f352c81f1b5a40b2d8d241cdf273b, type: 3}
floor: {fileID: 19711883686801522, guid: 71931eea896a59a4683986cfd369b8ee, type: 3} floor: {fileID: 19711883686801522, guid: 71931eea896a59a4683986cfd369b8ee, type: 3}
normalWall: {fileID: 2953616027608884528, guid: a4dcd71ec9f819f4e88c7b5ac24f4b0d, normalWall: {fileID: 2953616027608884528, guid: a4dcd71ec9f819f4e88c7b5ac24f4b0d,
type: 3} type: 3}
......
...@@ -33,7 +33,8 @@ public class CameraTurret : MonoBehaviour, IObject, IBreakable, IPlayerInteracto ...@@ -33,7 +33,8 @@ public class CameraTurret : MonoBehaviour, IObject, IBreakable, IPlayerInteracto
{ {
if (Position.IsInAdjacentArea(pos, 1) && MapManager.inst.currentMap.GetWallAtPos((Vector2)(Position + pos) / 2) == null) if (Position.IsInAdjacentArea(pos, 1) && MapManager.inst.currentMap.GetWallAtPos((Vector2)(Position + pos) / 2) == null)
{ {
Debug.Log(Position.x + " " + Position.y + " Stage Restart!"); StartCoroutine(GameManager.inst.GameOver());
//TODO : Restart Level //TODO : Restart Level
} }
} }
......
...@@ -36,6 +36,24 @@ public class GameManager : SingletonBehaviour<GameManager> ...@@ -36,6 +36,24 @@ public class GameManager : SingletonBehaviour<GameManager>
Debug.Log("Stage Clear!"); Debug.Log("Stage Clear!");
} }
public IEnumerator GameOver()
{
Debug.Log("Game Over!");
StopAllCoroutines();
yield return new WaitForSeconds(1);
foreach (GameObject child in MapManager.inst.players)
Destroy(child);
Destroy(MapManager.inst.currentMap.gameObject);
}
public void StageRestart()
{
Debug.Log("Game Restart!");
GameOver();
MapManager.inst.LoadMap(MapManager.inst.stage[0]);
}
void Awake() void Awake()
{ {
//Reset clear index to -1. //Reset clear index to -1.
......
...@@ -9,6 +9,7 @@ public class MapManager : SingletonBehaviour<MapManager> ...@@ -9,6 +9,7 @@ public class MapManager : SingletonBehaviour<MapManager>
public bool isMapEditingOn; public bool isMapEditingOn;
public NavMeshSurface surface; public NavMeshSurface surface;
public Map currentMap; public Map currentMap;
public Map emptyMap;
[Header("Instances")] [Header("Instances")]
public Floor floor; public Floor floor;
public NormalWall normalWall; public NormalWall normalWall;
...@@ -31,7 +32,7 @@ public class MapManager : SingletonBehaviour<MapManager> ...@@ -31,7 +32,7 @@ public class MapManager : SingletonBehaviour<MapManager>
public void LoadMap(TextAsset _newMap) public void LoadMap(TextAsset _newMap)
{ {
var loadedMapData = JsonConvert.DeserializeObject<MapEditor.MapSaveData>(_newMap.ToString()); var loadedMapData = JsonConvert.DeserializeObject<MapEditor.MapSaveData>(_newMap.ToString());
currentMap = Instantiate(currentMap, new Vector3(0, 0, 0), Quaternion.identity); currentMap = Instantiate(emptyMap, new Vector3(0, 0, 0), Quaternion.identity);
currentMap.InitiateMap(); currentMap.InitiateMap();
currentMap.maxMapSize = (int)loadedMapData.objects[0].xPos; currentMap.maxMapSize = (int)loadedMapData.objects[0].xPos;
int casesIndex = 0; int casesIndex = 0;
......
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