Commit 6f0aa517 authored by 18손재민's avatar 18손재민

Merge branch 'map'

parents b7acf6d1 fc955810
{"objects":[{"tag":0,"xPos":20.0,"yPos":0.0},{"tag":2,"xPos":-2.0,"yPos":0.5},{"tag":3,"xPos":-1.0,"yPos":0.5},{"tag":1,"xPos":-2.0,"yPos":1.0},{"tag":1,"xPos":-1.0,"yPos":1.0},{"tag":1,"xPos":0.0,"yPos":1.0},{"tag":1,"xPos":1.0,"yPos":1.0},{"tag":1,"xPos":1.0,"yPos":0.0},{"tag":1,"xPos":0.0,"yPos":0.0},{"tag":1,"xPos":-1.0,"yPos":0.0},{"tag":1,"xPos":-2.0,"yPos":0.0},{"tag":1,"xPos":-2.0,"yPos":-1.0},{"tag":1,"xPos":0.0,"yPos":-1.0},{"tag":9,"xPos":0.0,"yPos":-1.0},{"tag":1,"xPos":-1.0,"yPos":-1.0},{"tag":9,"xPos":-1.0,"yPos":-1.0},{"tag":1,"xPos":1.0,"yPos":-1.0},{"tag":1,"xPos":1.0,"yPos":-2.0},{"tag":1,"xPos":0.0,"yPos":-2.0},{"tag":1,"xPos":-1.0,"yPos":-2.0},{"tag":1,"xPos":-2.0,"yPos":-2.0},{"tag":4,"xPos":-2.0,"yPos":-2.0},{"tag":4,"xPos":-1.0,"yPos":-2.0},{"tag":5,"xPos":-2.0,"yPos":1.0},{"tag":6,"xPos":-1.0,"yPos":1.0},{"tag":7,"xPos":0.0,"yPos":1.0},{"tag":8,"xPos":1.0,"yPos":1.0}],"clears":[{"type":2,"goal":1},{"type":5,"goal":1}],"bullets":[0,1,2]}
\ No newline at end of file
fileFormatVersion: 2
guid: 936182e5c24ea3e4499b01d2029823eb
folderAsset: yes
DefaultImporter:
guid: 801379ac94c79b24cb6c73e213b0854d
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
......
fileFormatVersion: 2
guid: ef75a379c7ec93a4d85966c580bcc286
guid: 47baf9abe59c90a4d914127b0527c24f
folderAsset: yes
DefaultImporter:
externalObjects: {}
......
fileFormatVersion: 2
guid: 2a181461c3622c14b804bb5eabec750c
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Any:
second:
enabled: 1
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
- first:
Windows Store Apps: WindowsStoreApps
second:
enabled: 0
settings:
CPU: AnyCPU
userData:
assetBundleName:
assetBundleVariant:
......@@ -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}
......@@ -2668,9 +2668,8 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 5ad2f39c48d82964f86cd2d6e1e94641, type: 3}
m_Name:
m_EditorClassIdentifier:
currentMap: {fileID: 0}
stage:
- {fileID: 630498074781569474, guid: 759f352c81f1b5a40b2d8d241cdf273b, type: 3}
currentMap: {fileID: 630498074781569474, guid: 759f352c81f1b5a40b2d8d241cdf273b,
type: 3}
tile: {fileID: 7449840556337937162, guid: 90d0ab9f40a0ddc4c871130319d86cd5, type: 3}
modeSign: {fileID: 153720729}
startSign: {fileID: 1215997560627761150, guid: 106914c4661964b47ad09efcc4bfba69,
......@@ -2679,7 +2678,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
......
......@@ -45,7 +45,8 @@ MonoBehaviour:
m_EditorClassIdentifier:
isMapEditingOn: 0
surface: {fileID: 0}
currentMap: {fileID: 0}
currentMap: {fileID: 630498074781569474, guid: 759f352c81f1b5a40b2d8d241cdf273b,
type: 3}
floor: {fileID: 19711883686801522, guid: 71931eea896a59a4683986cfd369b8ee, type: 3}
normalWall: {fileID: 2953616027608884528, guid: a4dcd71ec9f819f4e88c7b5ac24f4b0d,
type: 3}
......@@ -66,7 +67,7 @@ MonoBehaviour:
- {fileID: 6840018466224391531, guid: d7070c786deaa3a4082f9339da091b46, type: 3}
- {fileID: 6169104080419908266, guid: 420a4f921e52a4141b80a3eefcd511e6, type: 3}
- {fileID: 87051754405567689, guid: 2a2831d520acdd3408d8a04673423e2a, type: 3}
players: []
player: {fileID: 494213313239918027, guid: 449b2ca4d925da541bb45c84b63aab98, type: 3}
players: []
stage:
- {fileID: 2496973653136699540, guid: dbb2e09c19fe5ad49b11a6b95e5ac9e8, type: 3}
- {fileID: 4900000, guid: 801379ac94c79b24cb6c73e213b0854d, type: 3}
......@@ -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,12 @@ PrefabInstance:
type: 3}
propertyPath: surface
value:
objectReference: {fileID: 950340631}
objectReference: {fileID: 1382512383}
- target: {fileID: 3268100033343711389, guid: 11285456de5f1854d947bea83275646f,
type: 3}
propertyPath: asd
value:
objectReference: {fileID: 4900000, guid: c4865e9602e96b54b89d9ecb0d3e6d1c, type: 3}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 11285456de5f1854d947bea83275646f, type: 3}
--- !u!1001 &1046587609
......@@ -501,75 +494,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 +590,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:
......@@ -1134,12 +1134,6 @@ PrefabInstance:
propertyPath: surface
value:
objectReference: {fileID: 2102809461}
- target: {fileID: 3268100033343711389, guid: 11285456de5f1854d947bea83275646f,
type: 3}
propertyPath: stage.Array.data[0]
value:
objectReference: {fileID: 3529117415661273963, guid: 3d35fd3e6a494bc42921ce1cd03fc637,
type: 3}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 11285456de5f1854d947bea83275646f, type: 3}
--- !u!1001 &7277015660625800392
......@@ -1149,11 +1143,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 +1208,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}
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
fileFormatVersion: 2
guid: e65075a85c136f94082fa7468adae02f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
......@@ -2,14 +2,6 @@
using System.Collections.Generic;
using UnityEngine;
public enum ObjType
{
NULL,
Briefcase,
Camera,
Mannequin
}
public interface IObject
{
void Init(Floor floor);
......
......@@ -12,9 +12,9 @@ public class GameManager : SingletonBehaviour<GameManager>
public int clearCounter = 0;
public static int nFloor, nTurret, nCase, nPlayer, aFloor, aTurret, aCase, white, black;
//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);
......@@ -36,23 +36,17 @@ public class GameManager : SingletonBehaviour<GameManager>
Debug.Log("Stage Clear!");
}
void Awake()
{
//Reset clear index to -1.
for (int i = 0; i < clearIndex.Length; i++) clearIndex[i] = -1;
nFloor = nTurret = nCase = nPlayer = aFloor = aTurret = aCase = white = black = -1;
}
// Start is called before the first frame update
void Start()
{
if (!MapManager.inst.isMapEditingOn)
MapManager.inst.LoadMap(MapManager.inst.stage[0]);
else
{
for (int i = 0; i < 9; i++) clearIndex[i] = -1;
nFloor = clearIndex[(int)ClearType.NFloor];
nTurret = clearIndex[(int)ClearType.NTurret];
nCase = clearIndex[(int)ClearType.NCase];
nPlayer = clearIndex[(int)ClearType.NPlayer];
aFloor = clearIndex[(int)ClearType.AllFloor];
aTurret = clearIndex[(int)ClearType.AllTurret];
aCase = clearIndex[(int)ClearType.AllCase];
white = clearIndex[(int)ClearType.White];
black = clearIndex[(int)ClearType.Black];
}
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using UnityEngine.AI;
using Newtonsoft.Json;
public class MapManager : SingletonBehaviour<MapManager>
{
......@@ -14,28 +14,74 @@ public class MapManager : SingletonBehaviour<MapManager>
public NormalWall normalWall;
public Mirror mirror;
public GameObject truthBullet, fakeBullet, mirrorBullet;
[Tooltip("Objects without mannequin.")]
public GameObject briefCase;
public GameObject cameraTurret;
public GameObject[] mannequins;
public List<GameObject> players;
public GameObject player;
public Map[] stage;
[Header("All players")]
public List<GameObject> players;
[Header("All stages")]
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)
{
if (currentMap != null)
Destroy(currentMap.gameObject);
currentMap = Instantiate(_newMap);
currentMap.transform.position = new Vector3(0, 0, 0);
surface.BuildNavMesh();
var loadedMapData = JsonConvert.DeserializeObject<MapEditor.MapSaveData>(_newMap.ToString());
currentMap = Instantiate(currentMap, new Vector3(0, 0, 0), Quaternion.identity);
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]);
for (int i = 0; i < loadedMapData.bullets.Count; i++)
PlayerController.inst.bulletList.Add(loadedMapData.bullets[i]);
}
public IEnumerator Rebaker()
{
......
......@@ -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)
{
......
......@@ -269,28 +269,6 @@ public class Map : MonoBehaviour
Debug.Log("Object doesn't exists between : " + pos);
}
private void LoadObjects()
{
floorGrid = new Dictionary<Vector2Int, Floor>();
wallGrid = new Dictionary<Vector2, Wall>();
objectGrid = new Dictionary<Vector2Int, IObject>();
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);
}
for (int i = 0; i < objects.transform.childCount; i++)
{
IObject iObject = objects.transform.GetChild(i).GetComponent<IObject>();
objectGrid.Add(iObject.GetPos(), iObject);
}
}
public void InitiateMap()
{
floorGrid = new Dictionary<Vector2Int, Floor>();
......@@ -299,11 +277,6 @@ public class Map : MonoBehaviour
startFloors = new List<Floor>();
}
private void Awake()
{
LoadObjects();
}
// Start is called before the first frame update
void Start()
{
......
......@@ -2,13 +2,6 @@
using System.Collections.Generic;
using UnityEngine;
public enum WallType
{
NULL,
Normal,
Mirror
}
public class Wall : MonoBehaviour
{
/// <summary>
......
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using UnityEngine.UI;
using Newtonsoft.Json;
using System.IO;
public class MapEditor : SingletonBehaviour<MapEditor>
{
public class objectData
{
public TileMode tag;
public float xPos, yPos;
public objectData(TileMode _tag, Vector2 _pos)
{
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 List<BulletCode> bullets;
public MapSaveData()
{
objects = new List<objectData>();
clears = new List<clearData>();
bullets = new List<BulletCode>();
}
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 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;
public void StartMap(Map _newMap)
{
if (currentMap != null)
Destroy(currentMap.gameObject);
currentMap = Instantiate(_newMap);
currentMap.transform.position = new Vector3(0, 0, 0);
currentMap.InitiateMap();
......@@ -35,22 +70,54 @@ 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 = "Assets/" + 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;
}
MapSaveData mapSaveData = new MapSaveData();
mapSaveData.AddObject(TileMode.None, new Vector2(currentMap.maxMapSize, 0));
foreach(Transform child in currentMap.walls.transform)
{
Wall temp = child.GetComponent<Wall>();
if (temp is NormalWall)
mapSaveData.AddObject(TileMode.Normal, temp.mapPos);
else
mapSaveData.AddObject(TileMode.Mirror, temp.mapPos);
}
foreach(Transform child in currentMap.floors.transform)
{
Floor temp = child.GetComponent<Floor>();
mapSaveData.AddObject(TileMode.Floor, temp.mapPos);
if (child.GetComponent<Floor>().isGoalFloor)
mapSaveData.AddObject(TileMode.goalFloor, temp.mapPos);
}
foreach(Floor child in currentMap.startFloors)
{
Floor temp = child.GetComponent<Floor>();
mapSaveData.AddObject(TileMode.StartFloor, temp.mapPos);
}
foreach (Transform child in currentMap.objects.transform)
{
IObject temp = child.GetComponent<IObject>();
if (temp.GetType() == ObjType.Briefcase)
mapSaveData.AddObject(TileMode.Briefcase, temp.GetPos());
else if(temp.GetType() == ObjType.Camera)
mapSaveData.AddObject(TileMode.Camera, temp.GetPos());
else if (temp.GetType() == ObjType.Mannequin)
{
if (temp.GetObject().GetComponent<Mannequin>().isWhite)
mapSaveData.AddObject(TileMode.WMannequin, temp.GetPos());
else
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);
for (int i = 0; i < currentMap.initialBullets.Count; i++)
mapSaveData.bullets.Add(currentMap.initialBullets[i]);
File.WriteAllText(localPath, JsonConvert.SerializeObject(mapSaveData));
Debug.Log("Map saved at " + localPath);}
}
public void SaveCurrentMap()
{
......@@ -114,7 +181,7 @@ public class MapEditor : SingletonBehaviour<MapEditor>
// Start is called before the first frame update
void Start()
{
StartMap(stage[0]);
StartMap(currentMap);
SwitchMode(0);
}
......
......@@ -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()
{
......
......@@ -33,7 +33,7 @@ public class PlayerController : SingletonBehaviour<PlayerController>
{
if (obj.GetComponent<Player>().currentFloor == floor)
{
Debug.Log("there are player on that floor.");
Debug.Log("Player already exists on that floor.");
return;
}
}
......@@ -50,13 +50,9 @@ public class PlayerController : SingletonBehaviour<PlayerController>
public void CreatePlayer(Vector2Int floorPos)
{
if (MapManager.inst.currentMap.floorGrid.TryGetValue(floorPos, out Floor floor))
{
CreatePlayer(floor);
}
else
{
Debug.Log("there are no floor");
}
}
public void RemovePlayer(Floor floor)
......
......@@ -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()
......
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