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

현재 맵 정보 세이브 및 로드 기능 구현

parent 200e72d7
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &738553008
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 738553009}
- component: {fileID: 738553011}
- component: {fileID: 738553010}
m_Layer: 5
m_Name: Text
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &738553009
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 738553008}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 1397994405}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &738553011
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 738553008}
m_CullTransparentMesh: 0
--- !u!114 &738553010
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 738553008}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 708705254, guid: f70555f144d8491a825f0804e09c671c, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1}
m_RaycastTarget: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
m_FontData:
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
m_FontSize: 14
m_FontStyle: 0
m_BestFit: 0
m_MinSize: 10
m_MaxSize: 40
m_Alignment: 4
m_AlignByGeometry: 0
m_RichText: 1
m_HorizontalOverflow: 0
m_VerticalOverflow: 0
m_LineSpacing: 1
m_Text: Save current map
--- !u!1 &1397994404
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1397994405}
- component: {fileID: 1397994408}
- component: {fileID: 1397994407}
- component: {fileID: 1397994406}
m_Layer: 5
m_Name: Save
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &1397994405
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1397994404}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 738553009}
m_Father: {fileID: 1444571407667829093}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 123, y: -611}
m_SizeDelta: {x: 160, y: 30}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &1397994408
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1397994404}
m_CullTransparentMesh: 0
--- !u!114 &1397994407
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1397994404}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: -765806418, guid: f70555f144d8491a825f0804e09c671c, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
m_Sprite: {fileID: 10905, guid: 0000000000000000f000000000000000, type: 0}
m_Type: 1
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
m_UseSpriteMesh: 0
--- !u!114 &1397994406
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1397994404}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 1392445389, guid: f70555f144d8491a825f0804e09c671c, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Navigation:
m_Mode: 3
m_SelectOnUp: {fileID: 0}
m_SelectOnDown: {fileID: 0}
m_SelectOnLeft: {fileID: 0}
m_SelectOnRight: {fileID: 0}
m_Transition: 1
m_Colors:
m_NormalColor: {r: 1, g: 1, b: 1, a: 1}
m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1}
m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608}
m_ColorMultiplier: 1
m_FadeDuration: 0.1
m_SpriteState:
m_HighlightedSprite: {fileID: 0}
m_PressedSprite: {fileID: 0}
m_DisabledSprite: {fileID: 0}
m_AnimationTriggers:
m_NormalTrigger: Normal
m_HighlightedTrigger: Highlighted
m_PressedTrigger: Pressed
m_DisabledTrigger: Disabled
m_Interactable: 1
m_TargetGraphic: {fileID: 1397994407}
m_OnClick:
m_PersistentCalls:
m_Calls:
- m_Target: {fileID: 1615184088}
m_MethodName: SaveMap
m_Mode: 1
m_Arguments:
m_ObjectArgument: {fileID: 0}
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
m_IntArgument: 0
m_FloatArgument: 0
m_StringArgument:
m_BoolArgument: 0
m_CallState: 2
m_TypeName: UnityEngine.UI.Button+ButtonClickedEvent, UnityEngine.UI, Version=1.0.0.0,
Culture=neutral, PublicKeyToken=null
--- !u!1 &356685241964599882
GameObject:
m_ObjectHideFlags: 0
......@@ -652,6 +860,7 @@ RectTransform:
m_Children:
- {fileID: 4609862474233688060}
- {fileID: 3620727262082854988}
- {fileID: 1397994405}
m_Father: {fileID: 1444571408780882984}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
......@@ -994,8 +1203,8 @@ MonoBehaviour:
m_OnClick:
m_PersistentCalls:
m_Calls:
- m_Target: {fileID: 0}
m_MethodName: AddTile
- m_Target: {fileID: 1615184088}
m_MethodName: AddFloor
m_Mode: 1
m_Arguments:
m_ObjectArgument: {fileID: 0}
......@@ -1314,8 +1523,8 @@ MonoBehaviour:
m_OnClick:
m_PersistentCalls:
m_Calls:
- m_Target: {fileID: 0}
m_MethodName: RemoveTile
- m_Target: {fileID: 1615184088}
m_MethodName: RemoveFloor
m_Mode: 1
m_Arguments:
m_ObjectArgument: {fileID: 0}
......
......@@ -181,81 +181,6 @@ Transform:
m_Father: {fileID: 0}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0}
--- !u!1 &170803409 stripped
GameObject:
m_CorrespondingSourceObject: {fileID: 8862060874303168220, guid: 6ba287375b5ad4b458a7b7b99c6d6a08,
type: 3}
m_PrefabInstance: {fileID: 8862060874401324557}
m_PrefabAsset: {fileID: 0}
--- !u!1001 &238520940
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 630498074781569472, guid: 759f352c81f1b5a40b2d8d241cdf273b,
type: 3}
propertyPath: m_Name
value: TestStage
objectReference: {fileID: 0}
- target: {fileID: 630498074781569475, guid: 759f352c81f1b5a40b2d8d241cdf273b,
type: 3}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 630498074781569475, guid: 759f352c81f1b5a40b2d8d241cdf273b,
type: 3}
propertyPath: m_LocalPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 630498074781569475, guid: 759f352c81f1b5a40b2d8d241cdf273b,
type: 3}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 630498074781569475, guid: 759f352c81f1b5a40b2d8d241cdf273b,
type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 630498074781569475, guid: 759f352c81f1b5a40b2d8d241cdf273b,
type: 3}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 630498074781569475, guid: 759f352c81f1b5a40b2d8d241cdf273b,
type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 630498074781569475, guid: 759f352c81f1b5a40b2d8d241cdf273b,
type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 630498074781569475, guid: 759f352c81f1b5a40b2d8d241cdf273b,
type: 3}
propertyPath: m_RootOrder
value: 8
objectReference: {fileID: 0}
- target: {fileID: 630498074781569475, guid: 759f352c81f1b5a40b2d8d241cdf273b,
type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 630498074781569475, guid: 759f352c81f1b5a40b2d8d241cdf273b,
type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 630498074781569475, guid: 759f352c81f1b5a40b2d8d241cdf273b,
type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 759f352c81f1b5a40b2d8d241cdf273b, type: 3}
--- !u!1 &534669902
GameObject:
m_ObjectHideFlags: 0
......@@ -351,30 +276,6 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: c7d507df55441f7438f6f059e9d2587c, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!114 &1615184088 stripped
MonoBehaviour:
m_CorrespondingSourceObject: {fileID: 1615184088, guid: 0b18400fb62a12d4e9cb5fbb8ecbb53f,
type: 3}
m_PrefabInstance: {fileID: 1444571407246859822}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 9b8e1e408cd84db4583dba90a6a06169, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!114 &1908494592 stripped
MonoBehaviour:
m_CorrespondingSourceObject: {fileID: 6014610519130626207, guid: 11285456de5f1854d947bea83275646f,
type: 3}
m_PrefabInstance: {fileID: 6014610517247297951}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 9c46ee6a780f2c3428a79748eadabea8, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!114 &2102809461 stripped
MonoBehaviour:
m_CorrespondingSourceObject: {fileID: 7277015661519863741, guid: 20dee07e28273f049a9093ae4453912f,
......@@ -534,6 +435,11 @@ PrefabInstance:
propertyPath: m_Name
value: TestTools
objectReference: {fileID: 0}
- target: {fileID: 1444571407667829093, guid: 0b18400fb62a12d4e9cb5fbb8ecbb53f,
type: 3}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1444571408780882984, guid: 0b18400fb62a12d4e9cb5fbb8ecbb53f,
type: 3}
propertyPath: m_LocalPosition.x
......@@ -589,36 +495,6 @@ PrefabInstance:
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1444571407947569431, guid: 0b18400fb62a12d4e9cb5fbb8ecbb53f,
type: 3}
propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[0].m_Target
value:
objectReference: {fileID: 1615184088}
- target: {fileID: 1444571407947569431, guid: 0b18400fb62a12d4e9cb5fbb8ecbb53f,
type: 3}
propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[0].m_MethodName
value: AddFloor
objectReference: {fileID: 0}
- target: {fileID: 1444571408874085628, guid: 0b18400fb62a12d4e9cb5fbb8ecbb53f,
type: 3}
propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[0].m_Target
value:
objectReference: {fileID: 1615184088}
- target: {fileID: 1444571408874085628, guid: 0b18400fb62a12d4e9cb5fbb8ecbb53f,
type: 3}
propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[0].m_MethodName
value: RemoveFloor
objectReference: {fileID: 0}
- target: {fileID: 1444571407667829093, guid: 0b18400fb62a12d4e9cb5fbb8ecbb53f,
type: 3}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1828251375556061743, guid: 0b18400fb62a12d4e9cb5fbb8ecbb53f,
type: 3}
propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[0].m_Target
value:
objectReference: {fileID: 1908494592}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 0b18400fb62a12d4e9cb5fbb8ecbb53f, type: 3}
--- !u!1001 &6014610517247297951
......@@ -633,16 +509,38 @@ PrefabInstance:
propertyPath: m_Name
value: MapManager
objectReference: {fileID: 0}
- target: {fileID: 6014610519130626207, guid: 11285456de5f1854d947bea83275646f,
type: 3}
propertyPath: stage.Array.size
value: 1
objectReference: {fileID: 0}
- target: {fileID: 6014610519130626207, guid: 11285456de5f1854d947bea83275646f,
type: 3}
propertyPath: player
value:
objectReference: {fileID: 170803409}
objectReference: {fileID: 0}
- target: {fileID: 6014610519130626207, guid: 11285456de5f1854d947bea83275646f,
type: 3}
propertyPath: surface
value:
objectReference: {fileID: 2102809461}
- target: {fileID: 6014610519130626207, guid: 11285456de5f1854d947bea83275646f,
type: 3}
propertyPath: stage.Array.data[1]
value:
objectReference: {fileID: 791563843738455658, guid: d023f0193ec85eb4abdc3e04bb4d7778,
type: 3}
- target: {fileID: 6014610519130626207, guid: 11285456de5f1854d947bea83275646f,
type: 3}
propertyPath: stage.Array.data[0]
value:
objectReference: {fileID: 5554172594464001467, guid: 20fb0f72e3df40c488f15711aa30ac6e,
type: 3}
- target: {fileID: 6014610519130626207, guid: 11285456de5f1854d947bea83275646f,
type: 3}
propertyPath: currentMap
value:
objectReference: {fileID: 0}
- target: {fileID: 6014610519130626206, guid: 11285456de5f1854d947bea83275646f,
type: 3}
propertyPath: m_LocalPosition.x
......
......@@ -7,11 +7,11 @@ public class Floor : MonoBehaviour
/// <summary>
/// Position of this floor at the map.
/// </summary>
public Vector2Int MapPos { get; private set; }
public Vector2Int mapPos;
public void SetMapPos(Vector2Int pos)
public void SetmapPos(Vector2Int pos)
{
MapPos = pos;
mapPos = pos;
}
// Start is called before the first frame update
......
......@@ -11,6 +11,7 @@ public class Map : MonoBehaviour
private Dictionary<Vector2, Wall> wallGrid;
public GameObject floors;
public GameObject walls;
public Floor startFloor;
/// <summary>
/// Get floor at position.
......@@ -45,7 +46,7 @@ public class Map : MonoBehaviour
/// <returns></returns>
public Wall GetWallAtPos(Floor floor1, Floor floor2)
{
Vector2 wallPos = (Vector2)(floor1.MapPos + floor2.MapPos) / 2;
Vector2 wallPos = (Vector2)(floor1.mapPos + floor2.mapPos) / 2;
return wallGrid.ContainsKey(wallPos) ? wallGrid[wallPos] : null;
}
/// <summary>
......@@ -64,7 +65,7 @@ public class Map : MonoBehaviour
if (!floorGrid.ContainsKey(floorPos))
{
floorGrid.Add(floorPos, Instantiate(MapManager.inst.floor, new Vector3(floorPos.x, 0, floorPos.y), Quaternion.identity, floors.transform).GetComponent<Floor>());
floorGrid[floorPos].SetMapPos(floorPos);
floorGrid[floorPos].SetmapPos(floorPos);
StartCoroutine(MapManager.inst.Rebaker());
}
else
......@@ -130,16 +131,16 @@ public class Map : MonoBehaviour
/// <param name="floor2"></param>
public void CreateWall(Floor floor1, Floor floor2)
{
Vector2 wallPos = (Vector2)(floor1.MapPos + floor2.MapPos) / 2;
Vector2 wallPos = (Vector2)(floor1.mapPos + floor2.mapPos) / 2;
if (!wallGrid.ContainsKey(wallPos))
{
wallGrid.Add(wallPos, Instantiate(MapManager.inst.wall, new Vector3(wallPos.x, 0, wallPos.y), Quaternion.identity, walls.transform).GetComponent<Wall>());
wallGrid[wallPos].SetMapPos(wallPos);
wallGrid[wallPos].SetmapPos(wallPos);
wallGrid[wallPos].transform.LookAt(floor1.transform);
StartCoroutine(MapManager.inst.Rebaker());
}
else
Debug.Log("Wall already exists between : " + floor1.MapPos + ", " + floor2.MapPos);
Debug.Log("Wall already exists between : " + floor1.mapPos + ", " + floor2.mapPos);
}
/// <summary>
/// Create walls from two floors, toward dir's direction.
......@@ -150,8 +151,8 @@ public class Map : MonoBehaviour
/// <param name="length">Amount of walls you want to create.</param>
public void CreateWall(Floor floor1, Floor floor2, Vector2 dir, int length)
{
Vector2Int floor1Pos = floor1.MapPos;
Vector2Int floor2Pos = floor2.MapPos;
Vector2Int floor1Pos = floor1.mapPos;
Vector2Int floor2Pos = floor2.mapPos;
for (int i = 0; i < length; i++)
{
if(GetFloorAtPos(floor1Pos) == null || GetFloorAtPos(floor2Pos) == null)
......@@ -171,7 +172,7 @@ public class Map : MonoBehaviour
/// <param name="floor2"></param>
public void RemoveWall(Floor floor1, Floor floor2)
{
Vector2 wallPos = (Vector2)(floor1.MapPos + floor2.MapPos) / 2;
Vector2 wallPos = (Vector2)(floor1.mapPos + floor2.mapPos) / 2;
if (wallGrid.ContainsKey(wallPos))
{
Destroy(wallGrid[wallPos].gameObject);
......@@ -179,16 +180,31 @@ public class Map : MonoBehaviour
StartCoroutine(MapManager.inst.Rebaker());
}
else
Debug.Log("Wall doesn't exists between : " + floor1.MapPos + ", " + floor2.MapPos);
Debug.Log("Wall doesn't exists between : " + floor1.mapPos + ", " + floor2.mapPos);
}
private void LoadObjects()
{
Debug.Log(floors.transform.childCount);
for(int i = 0; i < floors.transform.childCount; i++)
{
Floor floor = floors.transform.GetChild(i).GetComponent<Floor>();
floorGrid.Add(floor.mapPos, floor);
}
for (int i = 0; i < walls.transform.childCount; i++)
{
Wall wall = walls.transform.GetChild(i).GetComponent<Wall>();
wallGrid.Add(wall.mapPos, wall);
}
}
private void Awake()
{
floorGrid = new Dictionary<Vector2Int, Floor>();
wallGrid = new Dictionary<Vector2, Wall>();
//LoadObjects();
maxMapSize = 5 * Mathf.Max(testInputSizeX, testInputSizeY);
CreateFloor(new Vector2Int(0, 0), new Vector2Int(9, 9));
CreateWall(GetFloorAtPos(0, 2), GetFloorAtPos(0, 3), Vector2.right, 5);
MapManager.inst.surface.BuildNavMesh();
}
......
......@@ -7,11 +7,11 @@ public class Wall : MonoBehaviour
/// <summary>
/// Position of this floor at the map.
/// </summary>
public Vector2 MapPos { get; private set; }
public Vector2 mapPos;
public void SetMapPos(Vector2 pos)
public void SetmapPos(Vector2 pos)
{
MapPos = pos;
mapPos = pos;
}
// Start is called before the first frame update
......
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using UnityEngine.AI;
public class MapManager : SingletonBehaviour<MapManager>
......@@ -14,19 +15,37 @@ public class MapManager : SingletonBehaviour<MapManager>
public void LoadMap(Map _newMap)
{
if(currentMap != null)
Destroy(currentMap.gameObject);
currentMap = Instantiate(_newMap);
currentMap.transform.position = new Vector3(0, 0, 0);
player.transform.position = currentMap.GetFloorAtPos(0, 0).transform.position + new Vector3(0, 1.5f, 0);
player.transform.position = currentMap.startFloor.transform.position + new Vector3(0, 1.5f, 0);
}
public IEnumerator Rebaker()
{
yield return null;
surface.BuildNavMesh();
}
/// <summary>
/// Saves map to Assets folder.
/// </summary>
/// <param name="_newMap"></param>
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
{
PrefabUtility.SaveAsPrefabAsset(_newMap.gameObject, localPath);
Debug.Log("Map saved at " + localPath);
}
}
private void Awake()
{
player = GameObject.Find("Player");
}
// Start is called before the first frame update
......
......@@ -21,7 +21,7 @@ public class PlayerController : MonoBehaviour
if (Physics.Raycast(mouseRay, out hit) && hit.collider.gameObject.tag.Equals("floor"))
{
GetComponent<NavMeshAgent>().SetDestination(hit.collider.gameObject.transform.position);
Debug.Log(hit.collider.gameObject.GetComponent<Floor>().MapPos);
Debug.Log(hit.collider.gameObject.GetComponent<Floor>().mapPos);
Debug.Log(hit.collider.gameObject.tag);
}
}
......
......@@ -30,6 +30,15 @@ public class TestTools : MonoBehaviour
MapManager.inst.currentMap.GetFloorAtPos(int.Parse(wall2XInput.text), int.Parse(wall2YInput.text)));
}
public void SaveMap()
{
MapManager.inst.SaveMap(MapManager.inst.currentMap);
}
public void LoadMap()
{
MapManager.inst.LoadMap(MapManager.inst.stage[1]);
}
// Start is called before the first frame update
void Start()
{
......
This diff is collapsed.
fileFormatVersion: 2
guid: f6226b2548447a54486acfc694a44e4d
folderAsset: yes
DefaultImporter:
guid: 20fb0f72e3df40c488f15711aa30ac6e
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
......
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