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

맵 세이브 JSON으로 변환 WIP

parent b4394627
fileFormatVersion: 2
guid: 936182e5c24ea3e4499b01d2029823eb
guid: 47baf9abe59c90a4d914127b0527c24f
folderAsset: yes
DefaultImporter:
externalObjects: {}
......
......@@ -1290,7 +1290,7 @@ Transform:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1549724121}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 125, y: 995, z: 0}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 1444571408780882984}
......@@ -2679,7 +2679,6 @@ MonoBehaviour:
mapSizeSetter: {fileID: 8774990006778924709}
mapEditorTiles: {fileID: 1549724121}
editNormalMat: {fileID: 2100000, guid: c741ce421701e7c43b7a48c4045a116b, type: 2}
realNormalMat: {fileID: 2100000, guid: 9274dfd686c38aa4f91d973c6de1c8e9, type: 2}
--- !u!1 &1444571408998523813
GameObject:
m_ObjectHideFlags: 0
......
......@@ -1413,7 +1413,7 @@ CapsuleCollider:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 494213313239918027}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_IsTrigger: 1
m_Enabled: 1
m_Radius: 0.3
m_Height: 2
......@@ -1435,6 +1435,7 @@ MonoBehaviour:
shootingArm: {fileID: 7838800661811206189}
shootingFinger: {fileID: 494213313239918045}
armRotation: {x: 0, y: 0, z: 0, w: 0}
anim: {fileID: 0}
currentFloor: {fileID: 0}
--- !u!1 &494213313239918029
GameObject:
......
......@@ -11,6 +11,7 @@ GameObject:
- component: {fileID: 2534561534465045041}
- component: {fileID: 2534561534464242193}
- component: {fileID: 2534561534463275217}
- component: {fileID: -2850530927027858165}
- component: {fileID: -4559840392902712278}
m_Layer: 0
m_Name: case
......@@ -81,6 +82,19 @@ MeshRenderer:
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
--- !u!65 &-2850530927027858165
BoxCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2534561534465535505}
m_Material: {fileID: 0}
m_IsTrigger: 1
m_Enabled: 1
serializedVersion: 2
m_Size: {x: 0.52, y: 0.44944128, z: 0.1252539}
m_Center: {x: 0, y: 0.030357078, z: 0}
--- !u!114 &-4559840392902712278
MonoBehaviour:
m_ObjectHideFlags: 0
......
......@@ -346,18 +346,6 @@ Transform:
m_Father: {fileID: 0}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0}
--- !u!114 &950340631 stripped
MonoBehaviour:
m_CorrespondingSourceObject: {fileID: 7277015661519863741, guid: 20dee07e28273f049a9093ae4453912f,
type: 3}
m_PrefabInstance: {fileID: 1046587609}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 7a5ac11cc976e418e8d13136b07e1f52, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1001 &977620025
PrefabInstance:
m_ObjectHideFlags: 0
......@@ -429,7 +417,7 @@ PrefabInstance:
type: 3}
propertyPath: surface
value:
objectReference: {fileID: 950340631}
objectReference: {fileID: 1382512383}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 11285456de5f1854d947bea83275646f, type: 3}
--- !u!1001 &1046587609
......@@ -501,75 +489,6 @@ PrefabInstance:
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 20dee07e28273f049a9093ae4453912f, type: 3}
--- !u!1001 &1133429038
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 52444459818764334, guid: 42247a938bb6e554eb00dc08303a72d6,
type: 3}
propertyPath: m_Name
value: GameManager
objectReference: {fileID: 0}
- target: {fileID: 52444459818764335, guid: 42247a938bb6e554eb00dc08303a72d6,
type: 3}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 52444459818764335, guid: 42247a938bb6e554eb00dc08303a72d6,
type: 3}
propertyPath: m_LocalPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 52444459818764335, guid: 42247a938bb6e554eb00dc08303a72d6,
type: 3}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 52444459818764335, guid: 42247a938bb6e554eb00dc08303a72d6,
type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 52444459818764335, guid: 42247a938bb6e554eb00dc08303a72d6,
type: 3}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 52444459818764335, guid: 42247a938bb6e554eb00dc08303a72d6,
type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 52444459818764335, guid: 42247a938bb6e554eb00dc08303a72d6,
type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 52444459818764335, guid: 42247a938bb6e554eb00dc08303a72d6,
type: 3}
propertyPath: m_RootOrder
value: 6
objectReference: {fileID: 0}
- target: {fileID: 52444459818764335, guid: 42247a938bb6e554eb00dc08303a72d6,
type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 52444459818764335, guid: 42247a938bb6e554eb00dc08303a72d6,
type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 52444459818764335, guid: 42247a938bb6e554eb00dc08303a72d6,
type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 42247a938bb6e554eb00dc08303a72d6, type: 3}
--- !u!1 &1295796961
GameObject:
m_ObjectHideFlags: 0
......@@ -666,3 +585,15 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 33643b4d19b5aba4294f4b5894d3404b, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!114 &1382512383 stripped
MonoBehaviour:
m_CorrespondingSourceObject: {fileID: 7277015661519863741, guid: 20dee07e28273f049a9093ae4453912f,
type: 3}
m_PrefabInstance: {fileID: 1046587609}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 7a5ac11cc976e418e8d13136b07e1f52, type: 3}
m_Name:
m_EditorClassIdentifier:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using UnityEngine.UI;
using System.IO;
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 Map currentMap;
public Map[] stage;
public MapEditorTile tile;
public enum TileMode { None, Floor, Normal, Mirror, StartFloor, Briefcase, Camera, WMannequin, BMannequin, goalFloor };
TileMode currentMode;
public Text modeSign;
public GameObject startSign, goalSign, mapSizeSetter, mapEditorTiles;
public Dictionary<Floor, GameObject> startSigns, goalSigns;
public Material editNormalMat, realNormalMat;
public Material editNormalMat;
bool isEditorStarted;
bool isCreateMode;
......@@ -35,22 +46,57 @@ public class MapEditor : SingletonBehaviour<MapEditor>
public void SaveMap(Map _newMap)
{
System.DateTime time = System.DateTime.Now;
string localPath = "Assets/SavedMap_" + time.ToShortDateString() + "-" + time.Hour + "-" + time.Minute + "-" + time.Second + ".prefab";
if (AssetDatabase.LoadAssetAtPath(localPath, typeof(GameObject)))
Debug.Log("Object with same name already exists.");
else if(currentMap.startFloors.Count == 0)
string localPath = Application.dataPath + time.ToShortDateString() + "-" + time.Hour + "-" + time.Minute + "-" + time.Second + ".json";
if(currentMap.startFloors.Count == 0)
Debug.Log("There is no start floor.");
else
{
foreach (Transform child in currentMap.walls.transform)
if (child.GetComponent<Wall>() is NormalWall)
child.gameObject.GetComponent<MeshRenderer>().material = realNormalMat;
PrefabUtility.SaveAsPrefabAsset(_newMap.gameObject, localPath);
Debug.Log("Map saved at " + localPath);
foreach (Transform child in currentMap.walls.transform)
if (child.GetComponent<Wall>() is NormalWall)
child.gameObject.GetComponent<MeshRenderer>().material = editNormalMat;
}
List<MapSaveData> mapSaveData = new List<MapSaveData>();
mapSaveData.Add(new MapSaveData(TileMode.None, new Vector2(currentMap.maxMapSize, currentMap.maxMapSize)));
foreach(Transform child in currentMap.walls.transform)
{
Wall temp = child.GetComponent<Wall>();
if (temp is NormalWall)
mapSaveData.Add(new MapSaveData(TileMode.Normal, temp.mapPos));
else
mapSaveData.Add(new MapSaveData(TileMode.Mirror, temp.mapPos));
}
foreach(Transform child in currentMap.floors.transform)
{
Debug.Log("dD");
Floor temp = child.GetComponent<Floor>();
mapSaveData.Add(new MapSaveData(TileMode.Floor, temp.mapPos));
if (child.GetComponent<Floor>().isGoalFloor)
mapSaveData.Add(new MapSaveData(TileMode.goalFloor, temp.mapPos));
}
foreach(Floor child in currentMap.startFloors)
{
Floor temp = child.GetComponent<Floor>();
mapSaveData.Add(new MapSaveData(TileMode.StartFloor, temp.mapPos));
}
foreach (Transform child in currentMap.objects.transform)
{
IObject temp = child.GetComponent<IObject>();
if (temp.GetType() == ObjType.Briefcase)
mapSaveData.Add(new MapSaveData(TileMode.Briefcase, temp.GetPos()));
else if(temp.GetType() == ObjType.Camera)
mapSaveData.Add(new MapSaveData(TileMode.Camera, temp.GetPos()));
else if (temp.GetType() == ObjType.Mannequin)
{
if (temp.GetObject().GetComponent<Mannequin>().isWhite)
mapSaveData.Add(new MapSaveData(TileMode.WMannequin, temp.GetPos()));
else
mapSaveData.Add(new MapSaveData(TileMode.BMannequin, temp.GetPos()));
}
}
List<MapSaveData> a = new List<MapSaveData>();
a.Add(new MapSaveData(TileMode.None, new Vector2(2, 3)));
string mapSaveJson = JsonUtility.ToJson(a);
Debug.Log(mapSaveJson);
File.WriteAllText(localPath, mapSaveJson);
Debug.Log("Map saved at " + localPath);}
}
public void SaveCurrentMap()
{
......
......@@ -108,6 +108,14 @@ public class Player : MonoBehaviour
newBullet.Init(shootingArm.transform.forward);
}
private void OnTriggerEnter(Collider other)
{
if (other.GetComponent<IPlayerInteractor>() != null)
{
other.GetComponent<IPlayerInteractor>().Interact(currentFloor.mapPos);
}
}
// Start is called before the first frame update
void Start()
{
......
{}
\ No newline at end of file
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