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
410e7a47
Commit
410e7a47
authored
Jul 02, 2019
by
18손재민
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
json 파일로부터 맵 로드 기능 구현 완료, 오류 수정 중
parent
ebe702c7
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
147 additions
and
50 deletions
+147
-50
MapManager.prefab
Assets/Prefabs/MapManager.prefab
+2
-1
SampleScene.unity
Assets/Scenes/SampleScene.unity
+11
-6
Enums.cs
Assets/Scripts/Generals/Enums.cs
+33
-0
Enums.cs.meta
Assets/Scripts/Generals/Enums.cs.meta
+11
-0
IObject.cs
Assets/Scripts/Interactors/Interfaces/IObject.cs
+0
-8
GameManager.cs
Assets/Scripts/Managers/GameManager.cs
+7
-1
MapManager.cs
Assets/Scripts/Managers/MapManager.cs
+62
-5
ClearCondition.cs
Assets/Scripts/Map/ClearCondition.cs
+2
-14
Map.cs
Assets/Scripts/Map/Map.cs
+1
-1
Wall.cs
Assets/Scripts/Map/Wall.cs
+0
-7
MapEditor.cs
Assets/Scripts/MapEditor.cs
+18
-2
TestTools.cs
Assets/Scripts/TestTools.cs
+0
-4
Assets2019-07-02-1-0-46.json
Assets2019-07-02-1-0-46.json
+0
-1
No files found.
Assets/Prefabs/MapManager.prefab
View file @
410e7a47
...
...
@@ -46,6 +46,7 @@ MonoBehaviour:
isMapEditingOn
:
0
surface
:
{
fileID
:
0
}
currentMap
:
{
fileID
:
0
}
emptyMap
:
{
fileID
:
630498074781569474
,
guid
:
759f352c81f1b5a40b2d8d241cdf273b
,
type
:
3
}
floor
:
{
fileID
:
19711883686801522
,
guid
:
71931eea896a59a4683986cfd369b8ee
,
type
:
3
}
normalWall
:
{
fileID
:
2953616027608884528
,
guid
:
a4dcd71ec9f819f4e88c7b5ac24f4b0d
,
type
:
3
}
...
...
@@ -69,4 +70,4 @@ MonoBehaviour:
players
:
[]
player
:
{
fileID
:
494213313239918027
,
guid
:
449b2ca4d925da541bb45c84b63aab98
,
type
:
3
}
stage
:
-
{
fileID
:
2496973653136699540
,
guid
:
dbb2e09c19fe5ad49b11a6b95e5ac9e
8
,
type
:
3
}
-
{
fileID
:
4900000
,
guid
:
b6ac683d8d1b9b44699880e1c2bf982
8
,
type
:
3
}
Assets/Scenes/SampleScene.unity
View file @
410e7a47
...
...
@@ -1138,7 +1138,12 @@ PrefabInstance:
type
:
3
}
propertyPath
:
stage.Array.data[0]
value
:
objectReference
:
{
fileID
:
3529117415661273963
,
guid
:
3d35fd3e6a494bc42921ce1cd03fc637
,
objectReference
:
{
fileID
:
4900000
,
guid
:
9bcb1c6d3d1a47046806d043fdde78d7
,
type
:
3
}
-
target
:
{
fileID
:
3268100033343711389
,
guid
:
11285456de5f1854d947bea83275646f
,
type
:
3
}
propertyPath
:
emptyMap
value
:
objectReference
:
{
fileID
:
630498074781569474
,
guid
:
759f352c81f1b5a40b2d8d241cdf273b
,
type
:
3
}
m_RemovedComponents
:
[]
m_SourcePrefab
:
{
fileID
:
100100000
,
guid
:
11285456de5f1854d947bea83275646f
,
type
:
3
}
...
...
@@ -1149,11 +1154,6 @@ PrefabInstance:
m_Modification
:
m_TransformParent
:
{
fileID
:
0
}
m_Modifications
:
-
target
:
{
fileID
:
7277015661519863741
,
guid
:
20dee07e28273f049a9093ae4453912f
,
type
:
3
}
propertyPath
:
m_NavMeshData
value
:
objectReference
:
{
fileID
:
0
}
-
target
:
{
fileID
:
7277015661519863740
,
guid
:
20dee07e28273f049a9093ae4453912f
,
type
:
3
}
propertyPath
:
m_Name
...
...
@@ -1219,5 +1219,10 @@ PrefabInstance:
propertyPath
:
m_LocalEulerAnglesHint.z
value
:
0
objectReference
:
{
fileID
:
0
}
-
target
:
{
fileID
:
7277015661519863741
,
guid
:
20dee07e28273f049a9093ae4453912f
,
type
:
3
}
propertyPath
:
m_NavMeshData
value
:
objectReference
:
{
fileID
:
0
}
m_RemovedComponents
:
[]
m_SourcePrefab
:
{
fileID
:
100100000
,
guid
:
20dee07e28273f049a9093ae4453912f
,
type
:
3
}
Assets/Scripts/Generals/Enums.cs
0 → 100644
View file @
410e7a47
public
enum
TileMode
{
None
,
Floor
,
Normal
,
Mirror
,
StartFloor
,
Briefcase
,
Camera
,
WMannequin
,
BMannequin
,
goalFloor
}
public
enum
ClearType
{
NFloor
,
NTurret
,
NCase
,
NPlayer
,
AllFloor
,
AllTurret
,
AllCase
,
White
,
Black
}
public
enum
WallType
{
NULL
,
Normal
,
Mirror
}
public
enum
ObjType
{
NULL
,
Briefcase
,
Camera
,
Mannequin
}
\ No newline at end of file
Assets/Scripts/Generals/Enums.cs.meta
0 → 100644
View file @
410e7a47
fileFormatVersion: 2
guid: e65075a85c136f94082fa7468adae02f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
Assets/Scripts/Interactors/Interfaces/IObject.cs
View file @
410e7a47
...
...
@@ -2,14 +2,6 @@
using
System.Collections.Generic
;
using
UnityEngine
;
public
enum
ObjType
{
NULL
,
Briefcase
,
Camera
,
Mannequin
}
public
interface
IObject
{
void
Init
(
Floor
floor
);
...
...
Assets/Scripts/Managers/GameManager.cs
View file @
410e7a47
...
...
@@ -12,9 +12,15 @@ public class GameManager : SingletonBehaviour<GameManager>
public
int
clearCounter
=
0
;
public
static
int
nFloor
,
nTurret
,
nCase
,
nPlayer
,
aFloor
,
aTurret
,
aCase
,
white
,
black
;
//Reset clear index to -1.
public
void
ResetClearIndex
()
{
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
)
{
for
(
int
i
=
0
;
i
<
9
;
i
++)
clearIndex
[
i
]
=
-
1
;
foreach
(
var
child
in
map
.
clearConditions
)
{
clearIndex
[(
int
)
child
.
type
]
=
map
.
clearConditions
.
IndexOf
(
child
);
...
...
Assets/Scripts/Managers/MapManager.cs
View file @
410e7a47
...
...
@@ -8,7 +8,7 @@ public class MapManager : SingletonBehaviour<MapManager>
{
public
bool
isMapEditingOn
;
public
NavMeshSurface
surface
;
public
Map
currentMap
;
public
Map
currentMap
,
emptyMap
;
[
Header
(
"Instances"
)]
public
Floor
floor
;
public
NormalWall
normalWall
;
...
...
@@ -20,13 +20,70 @@ public class MapManager : SingletonBehaviour<MapManager>
public
GameObject
[]
mannequins
;
public
List
<
GameObject
>
players
;
public
GameObject
player
;
public
Map
[]
stage
;
public
TextAsset
[]
stage
;
public
BulletFactory
bulletFactory
;
public
void
LoadMap
(
Map
_newMap
)
/// <summary>
/// Load and make a map by map data json file.
/// </summary>
/// <param name="_newMap">The json file of the map data to be created.</param>
public
void
LoadMap
(
TextAsset
_newMap
)
{
//var loadedMapData = JsonConvert.DeserializeObject<MapEditor.MapSaveData>(_newMap.ToString());
//loadedMapData.
if
(
currentMap
!=
null
)
Destroy
(
currentMap
.
gameObject
);
var
loadedMapData
=
JsonConvert
.
DeserializeObject
<
MapEditor
.
MapSaveData
>(
_newMap
.
ToString
());
currentMap
=
Instantiate
(
emptyMap
,
new
Vector3
(
0
,
0
,
0
),
Quaternion
.
identity
);
GameManager
.
inst
.
ResetClearIndex
();
currentMap
.
InitiateMap
();
currentMap
.
maxMapSize
=
(
int
)
loadedMapData
.
objects
[
0
].
xPos
;
for
(
int
i
=
1
;
i
<
loadedMapData
.
objects
.
Count
;
i
++)
{
var
temp
=
loadedMapData
.
objects
[
i
];
switch
(
temp
.
tag
)
{
case
TileMode
.
Floor
:
currentMap
.
CreateFloor
(
new
Vector2Int
((
int
)
temp
.
xPos
,
(
int
)
temp
.
yPos
));
break
;
case
TileMode
.
Normal
:
currentMap
.
CreateWall
(
new
Vector2
(
temp
.
xPos
,
temp
.
yPos
),
WallType
.
Normal
);
break
;
case
TileMode
.
Mirror
:
currentMap
.
CreateWall
(
new
Vector2
(
temp
.
xPos
,
temp
.
yPos
),
WallType
.
Mirror
);
break
;
case
TileMode
.
StartFloor
:
currentMap
.
startFloors
.
Add
(
currentMap
.
GetFloorAtPos
(
new
Vector2Int
((
int
)
temp
.
xPos
,
(
int
)
temp
.
yPos
)));
break
;
case
TileMode
.
Briefcase
:
currentMap
.
CreateObject
(
new
Vector2Int
((
int
)
temp
.
xPos
,
(
int
)
temp
.
yPos
),
ObjType
.
Briefcase
);
break
;
case
TileMode
.
Camera
:
currentMap
.
CreateObject
(
new
Vector2Int
((
int
)
temp
.
xPos
,
(
int
)
temp
.
yPos
),
ObjType
.
Camera
);
break
;
case
TileMode
.
WMannequin
:
currentMap
.
CreateObject
(
new
Vector2Int
((
int
)
temp
.
xPos
,
(
int
)
temp
.
yPos
),
ObjType
.
Mannequin
,
true
);
break
;
case
TileMode
.
BMannequin
:
currentMap
.
CreateObject
(
new
Vector2Int
((
int
)
temp
.
xPos
,
(
int
)
temp
.
yPos
),
ObjType
.
Mannequin
,
false
);
break
;
case
TileMode
.
goalFloor
:
currentMap
.
GetFloorAtPos
(
new
Vector2Int
((
int
)
temp
.
xPos
,
(
int
)
temp
.
yPos
)).
isGoalFloor
=
true
;
break
;
default
:
break
;
}
}
for
(
int
i
=
0
;
i
<
loadedMapData
.
clears
.
Count
;
i
++)
{
var
temp
=
loadedMapData
.
clears
[
i
];
currentMap
.
clearConditions
.
Add
(
new
ClearCondition
(
temp
.
type
,
temp
.
goal
));
}
GameManager
.
inst
.
SetClearIndex
(
currentMap
);
surface
.
BuildNavMesh
();
GameManager
.
inst
.
uiGenerator
.
GenerateAllClearUI
();
for
(
int
i
=
0
;
i
<
currentMap
.
startFloors
.
Count
;
i
++)
PlayerController
.
inst
.
CreatePlayer
(
currentMap
.
startFloors
[
i
]);
for
(
int
i
=
0
;
i
<
currentMap
.
initialBullets
.
Count
;
i
++)
PlayerController
.
inst
.
bulletList
.
Add
(
currentMap
.
initialBullets
[
i
]);
/*if (currentMap != null)
...
...
Assets/Scripts/Map/ClearCondition.cs
View file @
410e7a47
...
...
@@ -2,18 +2,6 @@
using
System.Collections.Generic
;
using
UnityEngine
;
public
enum
ClearType
{
NFloor
,
NTurret
,
NCase
,
NPlayer
,
AllFloor
,
AllTurret
,
AllCase
,
White
,
Black
}
[
System
.
Serializable
]
public
class
ClearCondition
...
...
@@ -24,12 +12,12 @@ public class ClearCondition
public
bool
isDone
=
false
;
public
ClearStatusUI
assignedClearUI
;
/*
public ClearCondition(ClearType _type, int _goal)
public
ClearCondition
(
ClearType
_type
,
int
_goal
)
{
type
=
_type
;
goal
=
_goal
;
count
=
0
;
}
*/
}
public
void
IsDone
(
int
_count
=
0
,
int
_goal
=
0
)
{
...
...
Assets/Scripts/Map/Map.cs
View file @
410e7a47
...
...
@@ -297,7 +297,7 @@ public class Map : MonoBehaviour
private
void
Awake
()
{
LoadObjects
();
//
LoadObjects();
}
// Start is called before the first frame update
...
...
Assets/Scripts/Map/Wall.cs
View file @
410e7a47
...
...
@@ -2,13 +2,6 @@
using
System.Collections.Generic
;
using
UnityEngine
;
public
enum
WallType
{
NULL
,
Normal
,
Mirror
}
public
class
Wall
:
MonoBehaviour
{
/// <summary>
...
...
Assets/Scripts/MapEditor.cs
View file @
410e7a47
...
...
@@ -16,19 +16,33 @@ public class MapEditor : SingletonBehaviour<MapEditor>
tag
=
_tag
;
xPos
=
_pos
.
x
;
yPos
=
_pos
.
y
;
}
}
public
class
clearData
{
public
ClearType
type
;
public
int
goal
;
public
clearData
(
ClearType
_type
,
int
_goal
)
{
type
=
_type
;
goal
=
_goal
;
}
}
public
class
MapSaveData
{
public
List
<
objectData
>
objects
;
public
List
<
clearData
>
clears
;
public
MapSaveData
()
{
objects
=
new
List
<
objectData
>();
clears
=
new
List
<
clearData
>();
}
public
void
AddObject
(
TileMode
_tag
,
Vector2
_pos
)
{
objects
.
Add
(
new
objectData
(
_tag
,
_pos
));
}
public
void
AddClears
(
ClearType
_type
,
int
_goal
)
{
clears
.
Add
(
new
clearData
(
_type
,
_goal
));
}
}
public
enum
TileMode
{
None
,
Floor
,
Normal
,
Mirror
,
StartFloor
,
Briefcase
,
Camera
,
WMannequin
,
BMannequin
,
goalFloor
};
public
Map
currentMap
;
public
Map
[]
stage
;
public
MapEditorTile
tile
;
...
...
@@ -57,7 +71,7 @@ public class MapEditor : SingletonBehaviour<MapEditor>
public
void
SaveMap
(
Map
_newMap
)
{
System
.
DateTime
time
=
System
.
DateTime
.
Now
;
string
localPath
=
Application
.
dataPath
+
time
.
ToShortDateString
()
+
"-"
+
time
.
Hour
+
"-"
+
time
.
Minute
+
"-"
+
time
.
Second
+
".json"
;
string
localPath
=
"Assets/"
+
time
.
ToShortDateString
()
+
"-"
+
time
.
Hour
+
"-"
+
time
.
Minute
+
"-"
+
time
.
Second
+
".json"
;
if
(
currentMap
.
startFloors
.
Count
==
0
)
Debug
.
Log
(
"There is no start floor."
);
else
...
...
@@ -99,6 +113,8 @@ public class MapEditor : SingletonBehaviour<MapEditor>
mapSaveData
.
AddObject
(
TileMode
.
BMannequin
,
temp
.
GetPos
());
}
}
for
(
int
i
=
0
;
i
<
currentMap
.
clearConditions
.
Count
;
i
++)
mapSaveData
.
AddClears
(
currentMap
.
clearConditions
[
i
].
type
,
currentMap
.
clearConditions
[
i
].
goal
);
File
.
WriteAllText
(
localPath
,
JsonConvert
.
SerializeObject
(
mapSaveData
));
Debug
.
Log
(
"Map saved at "
+
localPath
);}
}
...
...
Assets/Scripts/TestTools.cs
View file @
410e7a47
...
...
@@ -44,10 +44,6 @@ public class TestTools : MonoBehaviour
{
MapManager
.
inst
.
currentMap
.
RemoveObject
(
new
Vector2Int
(
int
.
Parse
(
xInput
.
text
),
int
.
Parse
(
yInput
.
text
)));
}
public
void
LoadMap
()
{
MapManager
.
inst
.
LoadMap
(
MapManager
.
inst
.
stage
[
1
]);
}
// Start is called before the first frame update
void
Start
()
...
...
Assets2019-07-02-1-0-46.json
deleted
100644 → 0
View file @
ebe702c7
{
"objects"
:[{
"tag"
:
0
,
"xPos"
:
25.0
,
"yPos"
:
0.0
},{
"tag"
:
1
,
"xPos"
:
-1.0
,
"yPos"
:
0.0
},{
"tag"
:
1
,
"xPos"
:
-1.0
,
"yPos"
:
1.0
},{
"tag"
:
1
,
"xPos"
:
0.0
,
"yPos"
:
0.0
},{
"tag"
:
1
,
"xPos"
:
-1.0
,
"yPos"
:
-1.0
},{
"tag"
:
1
,
"xPos"
:
0.0
,
"yPos"
:
-1.0
},{
"tag"
:
1
,
"xPos"
:
2.0
,
"yPos"
:
2.0
},{
"tag"
:
1
,
"xPos"
:
-2.0
,
"yPos"
:
-2.0
},{
"tag"
:
1
,
"xPos"
:
-2.0
,
"yPos"
:
2.0
},{
"tag"
:
1
,
"xPos"
:
2.0
,
"yPos"
:
-2.0
},{
"tag"
:
4
,
"xPos"
:
-1.0
,
"yPos"
:
0.0
}]}
\ No newline at end of file
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