Commit f52a29d6 authored by 18손재민's avatar 18손재민

맵 세이브 방식 수정

parent 41c1d2da
...@@ -418,6 +418,11 @@ PrefabInstance: ...@@ -418,6 +418,11 @@ PrefabInstance:
propertyPath: surface propertyPath: surface
value: value:
objectReference: {fileID: 1382512383} objectReference: {fileID: 1382512383}
- target: {fileID: 3268100033343711389, guid: 11285456de5f1854d947bea83275646f,
type: 3}
propertyPath: asd
value:
objectReference: {fileID: 4900000, guid: c4865e9602e96b54b89d9ecb0d3e6d1c, type: 3}
m_RemovedComponents: [] m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 11285456de5f1854d947bea83275646f, type: 3} m_SourcePrefab: {fileID: 100100000, guid: 11285456de5f1854d947bea83275646f, type: 3}
--- !u!1001 &1046587609 --- !u!1001 &1046587609
......
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using UnityEngine; using UnityEngine;
using UnityEditor;
using UnityEngine.AI; using UnityEngine.AI;
using System.Text; using Newtonsoft.Json;
public class MapManager : SingletonBehaviour<MapManager> public class MapManager : SingletonBehaviour<MapManager>
{ {
...@@ -24,12 +23,10 @@ public class MapManager : SingletonBehaviour<MapManager> ...@@ -24,12 +23,10 @@ public class MapManager : SingletonBehaviour<MapManager>
public Map[] stage; public Map[] stage;
public BulletFactory bulletFactory; public BulletFactory bulletFactory;
public TextAsset asd;
public void LoadMap(Map _newMap) public void LoadMap(Map _newMap)
{ {
//var loadedMapData = JsonConvert.DeserializeObject<MapEditor.MapSaveData>(_newMap.ToString());
//loadedMapData.
/*if (currentMap != null) /*if (currentMap != null)
......
...@@ -7,17 +7,6 @@ using System.IO; ...@@ -7,17 +7,6 @@ using System.IO;
public class MapEditor : SingletonBehaviour<MapEditor> public class MapEditor : SingletonBehaviour<MapEditor>
{ {
class MapSaveData
{
public TileMode tag;
public float xPos, yPos;
public MapSaveData(TileMode _tag, Vector2 _pos)
{
tag = _tag;
xPos = _pos.x;
yPos = _pos.y;
}
}
public enum TileMode { None, Floor, Normal, Mirror, StartFloor, Briefcase, Camera, WMannequin, BMannequin, goalFloor }; public enum TileMode { None, Floor, Normal, Mirror, StartFloor, Briefcase, Camera, WMannequin, BMannequin, goalFloor };
public Map currentMap; public Map currentMap;
public Map[] stage; public Map[] stage;
...@@ -52,41 +41,41 @@ public class MapEditor : SingletonBehaviour<MapEditor> ...@@ -52,41 +41,41 @@ public class MapEditor : SingletonBehaviour<MapEditor>
Debug.Log("There is no start floor."); Debug.Log("There is no start floor.");
else else
{ {
List<MapSaveData> mapSaveData = new List<MapSaveData>(); MapSaveData mapSaveData = new MapSaveData();
mapSaveData.Add(new MapSaveData(TileMode.None, new Vector2(currentMap.maxMapSize, currentMap.maxMapSize))); mapSaveData.AddObject(TileMode.None, new Vector2(currentMap.maxMapSize, 0));
foreach(Transform child in currentMap.walls.transform) foreach(Transform child in currentMap.walls.transform)
{ {
Wall temp = child.GetComponent<Wall>(); Wall temp = child.GetComponent<Wall>();
if (temp is NormalWall) if (temp is NormalWall)
mapSaveData.Add(new MapSaveData(TileMode.Normal, temp.mapPos)); mapSaveData.AddObject(TileMode.Normal, temp.mapPos);
else else
mapSaveData.Add(new MapSaveData(TileMode.Mirror, temp.mapPos)); mapSaveData.AddObject(TileMode.Mirror, temp.mapPos);
} }
foreach(Transform child in currentMap.floors.transform) foreach(Transform child in currentMap.floors.transform)
{ {
Floor temp = child.GetComponent<Floor>(); Floor temp = child.GetComponent<Floor>();
mapSaveData.Add(new MapSaveData(TileMode.Floor, temp.mapPos)); mapSaveData.AddObject(TileMode.Floor, temp.mapPos);
if (child.GetComponent<Floor>().isGoalFloor) if (child.GetComponent<Floor>().isGoalFloor)
mapSaveData.Add(new MapSaveData(TileMode.goalFloor, temp.mapPos)); mapSaveData.AddObject(TileMode.goalFloor, temp.mapPos);
} }
foreach(Floor child in currentMap.startFloors) foreach(Floor child in currentMap.startFloors)
{ {
Floor temp = child.GetComponent<Floor>(); Floor temp = child.GetComponent<Floor>();
mapSaveData.Add(new MapSaveData(TileMode.StartFloor, temp.mapPos)); mapSaveData.AddObject(TileMode.StartFloor, temp.mapPos);
} }
foreach (Transform child in currentMap.objects.transform) foreach (Transform child in currentMap.objects.transform)
{ {
IObject temp = child.GetComponent<IObject>(); IObject temp = child.GetComponent<IObject>();
if (temp.GetType() == ObjType.Briefcase) if (temp.GetType() == ObjType.Briefcase)
mapSaveData.Add(new MapSaveData(TileMode.Briefcase, temp.GetPos())); mapSaveData.AddObject(TileMode.Briefcase, temp.GetPos());
else if(temp.GetType() == ObjType.Camera) else if(temp.GetType() == ObjType.Camera)
mapSaveData.Add(new MapSaveData(TileMode.Camera, temp.GetPos())); mapSaveData.AddObject(TileMode.Camera, temp.GetPos());
else if (temp.GetType() == ObjType.Mannequin) else if (temp.GetType() == ObjType.Mannequin)
{ {
if (temp.GetObject().GetComponent<Mannequin>().isWhite) if (temp.GetObject().GetComponent<Mannequin>().isWhite)
mapSaveData.Add(new MapSaveData(TileMode.WMannequin, temp.GetPos())); mapSaveData.AddObject(TileMode.WMannequin, temp.GetPos());
else else
mapSaveData.Add(new MapSaveData(TileMode.BMannequin, temp.GetPos())); mapSaveData.AddObject(TileMode.BMannequin, temp.GetPos());
} }
} }
File.WriteAllText(localPath, JsonConvert.SerializeObject(mapSaveData)); File.WriteAllText(localPath, JsonConvert.SerializeObject(mapSaveData));
......
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