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
7861051d
Commit
7861051d
authored
Aug 02, 2019
by
18신대성
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
플레이어가 클리어했었는지 여부를 저장하게 만듬
parent
81c4870a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
56 additions
and
9 deletions
+56
-9
.gitignore
.gitignore
+2
-1
GameManager.cs
Assets/Scripts/Managers/GameManager.cs
+53
-8
StageSelector.cs
Assets/Scripts/StageSelector.cs
+1
-0
No files found.
.gitignore
View file @
7861051d
...
...
@@ -51,4 +51,5 @@ sysinfo.txt
*.unitypackage
# Crashlytics generated file
crashlytics-build.properties
\ No newline at end of file
crashlytics-build.properties
saveData.json
Assets/Scripts/Managers/GameManager.cs
View file @
7861051d
using
System.Collections
;
using
System.Collections.Generic
;
using
System.IO
;
using
UnityEngine
;
using
UnityEngine.SceneManagement
;
using
UnityEngine.UI
;
using
Newtonsoft.Json
;
public
class
GameManager
:
SingletonBehaviour
<
GameManager
>
{
[
Space
(
10
)]
[
Header
(
"Saved Data"
)]
public
ClearData
playerData
;
/// <summary>
/// The index of the current stage.
/// </summary>
public
TextAsset
currentStage
;
public
int
stageIdx
;
[
Header
(
"UIs in Scene"
)]
public
ClearUIGenerator
uiGenerator
;
public
BulletUIGenerator
bulletUIGenerator
;
public
CommentUIGenerator
commentUIGenerator
;
public
Image
whiteout
;
[
Space
(
10
)]
[
Header
(
"Stage Data"
)]
public
bool
isGameOver
=
false
;
public
bool
isPlayerMoving
,
isPlayerShooting
,
isZooming
,
isBulletFlying
;
...
...
@@ -20,11 +30,6 @@ 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
TextAsset
currentStage
;
public
void
ResetClearIndex
()
{
//Reset clear index to -1.
...
...
@@ -89,6 +94,7 @@ public class GameManager : SingletonBehaviour<GameManager>
Debug
.
Log
(
"Stage Clear!"
);
Cursor
.
visible
=
true
;
Cursor
.
lockState
=
CursorLockMode
.
None
;
SaveClearData
(
stageIdx
,
true
);
yield
return
new
WaitForSeconds
(
3
);
BackToStageSelect
();
...
...
@@ -97,6 +103,7 @@ public class GameManager : SingletonBehaviour<GameManager>
public
void
GameOver
()
{
Debug
.
Log
(
"Game Over!"
);
SaveClearData
(
stageIdx
,
false
);
isGameOver
=
true
;
StopAllCoroutines
();
StartCoroutine
(
RestartStage
());
...
...
@@ -117,14 +124,52 @@ public class GameManager : SingletonBehaviour<GameManager>
SceneManager
.
LoadScene
(
"SelectStage"
);
}
public
void
SaveClearData
(
int
stage
=
-
1
,
bool
isClear
=
false
)
{
if
(
stage
!=
-
1
)
{
if
(
playerData
.
isCleared
.
ContainsKey
(
stage
))
{
playerData
.
isCleared
[
stage
]
=
isClear
;
}
else
playerData
.
isCleared
.
Add
(
stage
,
isClear
);
}
string
jsonData
=
JsonConvert
.
SerializeObject
(
playerData
);
File
.
WriteAllText
(
"./saveData.json"
,
jsonData
);
}
public
void
LoadClearData
()
{
if
(
File
.
Exists
(
"./saveData.json"
))
{
Debug
.
Log
(
"data Load"
);
string
strData
=
File
.
ReadAllText
(
"./saveData.json"
);
playerData
=
JsonConvert
.
DeserializeObject
<
ClearData
>(
strData
);
}
else
{
Debug
.
Log
(
"generate New Data"
);
playerData
=
new
ClearData
();
SaveClearData
();
}
}
public
class
ClearData
{
public
Dictionary
<
int
,
bool
>
isCleared
=
new
Dictionary
<
int
,
bool
>();
}
// Start is called before the first frame update
void
Start
()
{
GameManager
.
inst
.
LoadClearData
();
if
(!
MapManager
.
inst
.
isMapEditingOn
)
{
isGameOver
=
false
;
stageIdx
=
StageSelector
.
selectedStage
+
1
;
currentStage
=
Resources
.
Load
<
TextAsset
>(
"Stages/"
+
"stage"
+
(
StageSelector
.
selectedStage
+
1
));
StartStage
();
if
(
MapManager
.
inst
.
emptyMap
!=
null
)
StartStage
();
//Destroy(FindObjectOfType<StageSelector>().gameObject);
}
}
...
...
Assets/Scripts/StageSelector.cs
View file @
7861051d
...
...
@@ -33,6 +33,7 @@ public class StageSelector : MonoBehaviour
// Start is called before the first frame update
void
Start
()
{
GameManager
.
inst
.
LoadClearData
();
selectedStage
=
0
;
totalStageCount
=
stage
.
Length
;
}
...
...
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