Commit 7ac7f5c2 authored by 18류지석's avatar 18류지석

맵에디터 수정중; 플레이 가능, 세이브로드 개선

parent 6d231f9f
...@@ -38,7 +38,7 @@ RenderSettings: ...@@ -38,7 +38,7 @@ RenderSettings:
m_ReflectionIntensity: 1 m_ReflectionIntensity: 1
m_CustomReflection: {fileID: 0} m_CustomReflection: {fileID: 0}
m_Sun: {fileID: 0} m_Sun: {fileID: 0}
m_IndirectSpecularColor: {r: 0.18028378, g: 0.22571412, b: 0.30692285, a: 1} m_IndirectSpecularColor: {r: 0.18028334, g: 0.22571328, b: 0.3069217, a: 1}
m_UseRadianceAmbientProbe: 0 m_UseRadianceAmbientProbe: 0
--- !u!157 &3 --- !u!157 &3
LightmapSettings: LightmapSettings:
......
...@@ -4,6 +4,7 @@ using UnityEngine; ...@@ -4,6 +4,7 @@ using UnityEngine;
using UnityEngine.UI; using UnityEngine.UI;
using Newtonsoft.Json; using Newtonsoft.Json;
using System.IO; using System.IO;
using UnityEngine.SceneManagement;
public class MapEditor : SingletonBehaviour<MapEditor> public class MapEditor : SingletonBehaviour<MapEditor>
{ {
...@@ -53,14 +54,16 @@ public class MapEditor : SingletonBehaviour<MapEditor> ...@@ -53,14 +54,16 @@ public class MapEditor : SingletonBehaviour<MapEditor>
TileMode currentMode; TileMode currentMode;
BulletCode bulletMode; BulletCode bulletMode;
public Text modeSign; public Text modeSign;
public GameObject startSign, goalSign, mapSizeSetter, loadMapSelector, mapEditorTiles; public GameObject startSign, goalSign, mapSizeSetter, saveMapSelector, loadMapSelector, mapEditorTiles;
public Dictionary<Floor, GameObject> startSigns, goalSigns; public Dictionary<Floor, GameObject> startSigns, goalSigns;
public Material editNormalMat; public Material editNormalMat;
bool isEditorStarted; public bool isEditorStarted;
bool isCreateMode; bool isCreateMode;
public string mapName;
public void StartMap(Map _newMap) public void StartMap(Map _newMap)
{ {
currentMap = Instantiate(_newMap); currentMap = Instantiate(_newMap);
...@@ -73,13 +76,18 @@ public class MapEditor : SingletonBehaviour<MapEditor> ...@@ -73,13 +76,18 @@ public class MapEditor : SingletonBehaviour<MapEditor>
/// <param name="_newMap"></param> /// <param name="_newMap"></param>
public void SaveMap() public void SaveMap()
{ {
saveMapSelector.SetActive(false);
Map _newMap = currentMap; Map _newMap = currentMap;
/* 맵 저장 시 반드시 승리 조건 작성할 것 /* 맵 저장 시 반드시 승리 조건 작성할 것
* 목표가 '모든'일 경우 승리 목표는 초기 맵 기준으로 작성 * 목표가 '모든'일 경우 승리 목표는 초기 맵 기준으로 작성
*/ */
System.DateTime time = System.DateTime.Now; var x = saveMapSelector.transform.Find("x").GetComponent<InputField>();
string localPath = "Assets/" + time.ToShortDateString() + "-" + time.Hour + "-" + time.Minute + "-" + time.Second + ".json"; var y = saveMapSelector.transform.Find("y").GetComponent<InputField>();
if(currentMap.startFloors.Count == 0) mapName = x.text + "_" + y.text;
//System.DateTime time = System.DateTime.Now;
//string localPath = "Assets/" + time.ToShortDateString() + "-" + time.Hour + "-" + time.Minute + "-" + time.Second + ".json";
string localPath = "Assets/Resources/Stages/stage" + mapName + ".json";
if (currentMap.startFloors.Count == 0)
Debug.Log("There is no start floor."); Debug.Log("There is no start floor.");
else else
{ {
...@@ -129,6 +137,9 @@ public class MapEditor : SingletonBehaviour<MapEditor> ...@@ -129,6 +137,9 @@ public class MapEditor : SingletonBehaviour<MapEditor>
mapSaveData.bullets.Add(currentMap.initialBullets[i]); mapSaveData.bullets.Add(currentMap.initialBullets[i]);
mapSaveData.comments = currentMap.comments; mapSaveData.comments = currentMap.comments;
if(File.Exists(localPath)) File.Delete(localPath);
File.WriteAllText(localPath, JsonConvert.SerializeObject(mapSaveData)); File.WriteAllText(localPath, JsonConvert.SerializeObject(mapSaveData));
Debug.Log("Map saved at " + localPath);} Debug.Log("Map saved at " + localPath);}
} }
...@@ -138,7 +149,8 @@ public class MapEditor : SingletonBehaviour<MapEditor> ...@@ -138,7 +149,8 @@ public class MapEditor : SingletonBehaviour<MapEditor>
loadMapSelector.SetActive(false); loadMapSelector.SetActive(false);
var x = loadMapSelector.transform.Find("x").GetComponent<InputField>(); var x = loadMapSelector.transform.Find("x").GetComponent<InputField>();
var y = loadMapSelector.transform.Find("y").GetComponent<InputField>(); var y = loadMapSelector.transform.Find("y").GetComponent<InputField>();
TextAsset _newMap = Resources.Load("Stages/stage" + x.text + "_" + y.text) as TextAsset; mapName = x.text + "_" + y.text;
TextAsset _newMap = Resources.Load("Stages/stage" + mapName) as TextAsset;
if(_newMap != null) if(_newMap != null)
{ {
var loadedMapData = JsonConvert.DeserializeObject<MapEditor.MapSaveData>(_newMap.ToString()); var loadedMapData = JsonConvert.DeserializeObject<MapEditor.MapSaveData>(_newMap.ToString());
...@@ -220,6 +232,22 @@ public class MapEditor : SingletonBehaviour<MapEditor> ...@@ -220,6 +232,22 @@ public class MapEditor : SingletonBehaviour<MapEditor>
public void ResizeMap() public void ResizeMap()
{ {
mapSizeSetter.SetActive(true); mapSizeSetter.SetActive(true);
saveMapSelector.SetActive(false);
loadMapSelector.SetActive(false);
isEditorStarted = false;
}
public void LoadMapButton()
{
mapSizeSetter.SetActive(false);
saveMapSelector.SetActive(false);
loadMapSelector.SetActive(true);
isEditorStarted = false;
}
public void SaveMapButton()
{
mapSizeSetter.SetActive(false);
saveMapSelector.SetActive(true);
loadMapSelector.SetActive(false);
isEditorStarted = false; isEditorStarted = false;
} }
public void SwitchMode(int _tileMode) public void SwitchMode(int _tileMode)
...@@ -247,7 +275,21 @@ public class MapEditor : SingletonBehaviour<MapEditor> ...@@ -247,7 +275,21 @@ public class MapEditor : SingletonBehaviour<MapEditor>
} }
public void AddBulletToPlayer(int bulletMode) public void AddBulletToPlayer(int bulletMode)
{ {
currentMap.initialBullets.Add((BulletCode)bulletMode); if (bulletMode < 0) currentMap.initialBullets.Clear();
else currentMap.initialBullets.Add((BulletCode)bulletMode);
}
public void TestMapStart()
{
if(mapName != "")
{
StageSelector.selectedStage = mapName;
SceneManager.LoadScene("PlayStage");
}
else
{
Debug.Log("Save Your Map!");
}
} }
private void Awake() private void Awake()
......
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