Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
man-in-the-mirror
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
4
Issues
4
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MIM
man-in-the-mirror
Commits
185da338
Commit
185da338
authored
Jul 03, 2019
by
18손재민
Committed by
18손재민
Jul 03, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
게임 오버 및 게임 재시작 구현
parent
5c8e1c1c
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
32 additions
and
13 deletions
+32
-13
CameraTurret.cs
Assets/Scripts/Interactors/CameraTurret.cs
+1
-1
GameManager.cs
Assets/Scripts/Managers/GameManager.cs
+24
-9
MapManager.cs
Assets/Scripts/Managers/MapManager.cs
+3
-1
Map.cs
Assets/Scripts/Map/Map.cs
+4
-2
No files found.
Assets/Scripts/Interactors/CameraTurret.cs
View file @
185da338
...
...
@@ -33,7 +33,7 @@ public class CameraTurret : MonoBehaviour, IObject, IBreakable, IPlayerInteracto
{
if
(
Position
.
IsInAdjacentArea
(
pos
,
1
)
&&
MapManager
.
inst
.
currentMap
.
GetWallAtPos
((
Vector2
)(
Position
+
pos
)
/
2
)
==
null
)
{
StartCoroutine
(
GameManager
.
inst
.
GameOver
());
StartCoroutine
(
GameManager
.
inst
.
RestartStage
());
//TODO : Restart Level
}
...
...
Assets/Scripts/Managers/GameManager.cs
View file @
185da338
...
...
@@ -12,6 +12,18 @@ public class GameManager : SingletonBehaviour<GameManager>
public
int
clearCounter
=
0
;
public
static
int
nFloor
,
nTurret
,
nCase
,
nPlayer
,
aFloor
,
aTurret
,
aCase
,
white
,
black
;
/// <summary>
/// The index of the current stage.
/// </summary>
public
int
currentStage
;
public
void
ResetClearIndex
()
{
//Reset clear index to -1.
for
(
int
i
=
0
;
i
<
clearIndex
.
Length
;
i
++)
clearIndex
[
i
]
=
-
1
;
nFloor
=
nTurret
=
nCase
=
nPlayer
=
aFloor
=
aTurret
=
aCase
=
white
=
black
=
-
1
;
}
//Find and set the index of clear conditions of the map to clear type.
public
void
SetClearIndex
(
Map
map
)
{
...
...
@@ -36,35 +48,38 @@ public class GameManager : SingletonBehaviour<GameManager>
Debug
.
Log
(
"Stage Clear!"
);
}
public
IEnumerator
GameOver
()
public
void
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
()
public
IEnumerator
RestartStage
()
{
Debug
.
Log
(
"Game Restart!"
);
yield
return
new
WaitForSeconds
(
0.5f
);
GameOver
();
MapManager
.
inst
.
LoadMap
(
MapManager
.
inst
.
stage
[
0
]);
MapManager
.
inst
.
LoadMap
(
MapManager
.
inst
.
stage
[
currentStage
]);
}
void
Awake
()
{
//Reset clear index to -1.
for
(
int
i
=
0
;
i
<
clearIndex
.
Length
;
i
++)
clearIndex
[
i
]
=
-
1
;
nFloor
=
nTurret
=
nCase
=
nPlayer
=
aFloor
=
aTurret
=
aCase
=
white
=
black
=
-
1
;
}
// Start is called before the first frame update
void
Start
()
{
if
(!
MapManager
.
inst
.
isMapEditingOn
)
MapManager
.
inst
.
LoadMap
(
MapManager
.
inst
.
stage
[
0
]);
currentStage
=
0
;
MapManager
.
inst
.
LoadMap
(
MapManager
.
inst
.
stage
[
currentStage
]);
if
(
MapManager
.
inst
.
isMapEditingOn
)
{
//Reset clear index to -1.
ResetClearIndex
();
}
}
}
Assets/Scripts/Managers/MapManager.cs
View file @
185da338
...
...
@@ -34,6 +34,9 @@ public class MapManager : SingletonBehaviour<MapManager>
var
loadedMapData
=
JsonConvert
.
DeserializeObject
<
MapEditor
.
MapSaveData
>(
_newMap
.
ToString
());
currentMap
=
Instantiate
(
emptyMap
,
new
Vector3
(
0
,
0
,
0
),
Quaternion
.
identity
);
currentMap
.
InitiateMap
();
GameManager
.
inst
.
ResetClearIndex
();
PlayerController
.
inst
.
bulletList
.
Clear
();
players
.
Clear
();
currentMap
.
maxMapSize
=
(
int
)
loadedMapData
.
objects
[
0
].
xPos
;
int
casesIndex
=
0
;
for
(
int
i
=
1
;
i
<
loadedMapData
.
objects
.
Count
;
i
++)
...
...
@@ -93,7 +96,6 @@ public class MapManager : SingletonBehaviour<MapManager>
private
void
Awake
()
{
players
=
new
List
<
GameObject
>();
bulletFactory
=
new
BulletFactory
(
truthBullet
,
fakeBullet
,
mirrorBullet
);
}
...
...
Assets/Scripts/Map/Map.cs
View file @
185da338
...
...
@@ -222,7 +222,7 @@ public class Map : MonoBehaviour
switch
(
objType
)
{
case
ObjType
.
Briefcase
:
objectGrid
.
Add
(
pos
,
Instantiate
(
MapManager
.
inst
.
briefCase
,
new
Vector3
(
pos
.
x
,
0.
3
5f
,
pos
.
y
),
Quaternion
.
identity
,
objects
.
transform
).
GetComponent
<
IObject
>());
objectGrid
.
Add
(
pos
,
Instantiate
(
MapManager
.
inst
.
briefCase
,
new
Vector3
(
pos
.
x
,
0.5f
,
pos
.
y
),
Quaternion
.
identity
,
objects
.
transform
).
GetComponent
<
IObject
>());
if
(
GameManager
.
aCase
>=
0
)
clearConditions
[
GameManager
.
aCase
].
IsDone
(
0
,
1
);
break
;
...
...
@@ -245,7 +245,7 @@ public class Map : MonoBehaviour
public
void
CreateObject
(
Vector2Int
pos
,
ObjType
objType
,
BulletCode
_dropBullet
)
{
CreateObject
(
pos
,
objType
);
GetObjectAtPos
(
pos
).
GetObject
().
GetComponent
<
Briefcase
>().
dropBullet
=
_dropBullet
;
GetObjectAtPos
(
pos
).
GetObject
().
GetComponent
<
Briefcase
>().
SetBullet
(
_dropBullet
)
;
}
/// <summary>
/// Remove Object at position.
...
...
@@ -266,6 +266,8 @@ public class Map : MonoBehaviour
else
if
(!
objectGrid
[
pos
].
GetObject
().
GetComponent
<
Mannequin
>().
isWhite
&&
GameManager
.
black
>=
0
)
clearConditions
[
GameManager
.
black
].
IsDone
(
0
,
-
1
);
}
if
(
objectGrid
[
pos
].
GetType
()
!=
ObjType
.
Mannequin
)
PlayerController
.
inst
.
OnPlayerMove
-=
objectGrid
[
pos
].
GetObject
().
GetComponent
<
IPlayerInteractor
>().
Interact
;
Destroy
(
objectGrid
[
pos
].
GetObject
());
objectGrid
.
Remove
(
pos
);
StartCoroutine
(
MapManager
.
inst
.
Rebaker
());
...
...
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