Commit 169ed9bf authored by 18손재민's avatar 18손재민

오브젝트 생성 기능 구현

parent 3637db00
...@@ -66,19 +66,19 @@ AnimatorController: ...@@ -66,19 +66,19 @@ AnimatorController:
m_DefaultFloat: 0 m_DefaultFloat: 0
m_DefaultInt: 0 m_DefaultInt: 0
m_DefaultBool: 0 m_DefaultBool: 0
m_Controller: {fileID: 0} m_Controller: {fileID: 9100000}
- m_Name: shoot - m_Name: shoot
m_Type: 9 m_Type: 9
m_DefaultFloat: 0 m_DefaultFloat: 0
m_DefaultInt: 0 m_DefaultInt: 0
m_DefaultBool: 0 m_DefaultBool: 0
m_Controller: {fileID: 0} m_Controller: {fileID: 9100000}
- m_Name: isShooting - m_Name: isShooting
m_Type: 4 m_Type: 4
m_DefaultFloat: 0 m_DefaultFloat: 0
m_DefaultInt: 0 m_DefaultInt: 0
m_DefaultBool: 0 m_DefaultBool: 0
m_Controller: {fileID: 0} m_Controller: {fileID: 9100000}
m_AnimatorLayers: m_AnimatorLayers:
- serializedVersion: 5 - serializedVersion: 5
m_Name: Base Layer m_Name: Base Layer
......
...@@ -48,9 +48,13 @@ MonoBehaviour: ...@@ -48,9 +48,13 @@ MonoBehaviour:
normalWall: {fileID: 2953616027608884528, guid: a4dcd71ec9f819f4e88c7b5ac24f4b0d, normalWall: {fileID: 2953616027608884528, guid: a4dcd71ec9f819f4e88c7b5ac24f4b0d,
type: 3} type: 3}
mirror: {fileID: 17874052963739924, guid: 90282f1c82fff7545962b5ca66f1a102, type: 3} mirror: {fileID: 17874052963739924, guid: 90282f1c82fff7545962b5ca66f1a102, type: 3}
objects:
- {fileID: 2534561534465535505, guid: 0b323beb318071144aef94132be66541, type: 3}
- {fileID: 6001025753464815805, guid: df6f1d8b9377ec346af4255abe290fbb, type: 3}
- {fileID: 33432975985984805, guid: ec20e06c4a993924791d02d7a4c9375c, type: 3}
players: [] players: []
player: {fileID: 8862060874303168220, guid: 6ba287375b5ad4b458a7b7b99c6d6a08, type: 3} player: {fileID: 494213313239918027, guid: 449b2ca4d925da541bb45c84b63aab98, type: 3}
currentMap: {fileID: 0} currentMap: {fileID: 0}
surface: {fileID: 0} surface: {fileID: 0}
stage: stage:
- {fileID: 7116745361094357555, guid: 32ff564f49869bf40a53d07394eb081b, type: 3} - {fileID: 2496973653136699540, guid: dbb2e09c19fe5ad49b11a6b95e5ac9e8, type: 3}
...@@ -26,7 +26,7 @@ Transform: ...@@ -26,7 +26,7 @@ Transform:
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6001025753464815801} m_GameObject: {fileID: 6001025753464815801}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalPosition: {x: 0, y: 0.3, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: [] m_Children: []
m_Father: {fileID: 6001025753464593565} m_Father: {fileID: 6001025753464593565}
...@@ -65,6 +65,7 @@ MeshRenderer: ...@@ -65,6 +65,7 @@ MeshRenderer:
m_ProbeAnchor: {fileID: 0} m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0} m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1 m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 0 m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0 m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0 m_ImportantGI: 0
...@@ -155,7 +156,7 @@ Transform: ...@@ -155,7 +156,7 @@ Transform:
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6001025753464815807} m_GameObject: {fileID: 6001025753464815807}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalPosition: {x: 0, y: 0.3, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: [] m_Children: []
m_Father: {fileID: 6001025753464593565} m_Father: {fileID: 6001025753464593565}
...@@ -195,6 +196,7 @@ MeshRenderer: ...@@ -195,6 +196,7 @@ MeshRenderer:
m_ProbeAnchor: {fileID: 0} m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0} m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1 m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 0 m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0 m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0 m_ImportantGI: 0
......
...@@ -43,7 +43,7 @@ public class Mannequin : MonoBehaviour, IObject, IBulletInteractor ...@@ -43,7 +43,7 @@ public class Mannequin : MonoBehaviour, IObject, IBulletInteractor
Color = Color.black; Color = Color.black;
} }
} }
public void Init(bool isWhite) public void Init(bool isWhite)
{ {
Color = isWhite ? Color.white : Color.black; Color = isWhite ? Color.white : Color.black;
......
...@@ -22,11 +22,6 @@ public class Map : MonoBehaviour ...@@ -22,11 +22,6 @@ public class Map : MonoBehaviour
/// <returns></returns> /// <returns></returns>
public Floor GetFloorAtPos(Vector2Int pos) public Floor GetFloorAtPos(Vector2Int pos)
{ {
if ((pos.x >= 0 ? (pos.x > maxMapSize / 2) : (pos.x < -maxMapSize / 2)) || (pos.y >= 0 ? (pos.y > maxMapSize / 2) : (pos.y < -maxMapSize / 2)))
{
Debug.Log("Input size exceeds map's max size.");
return null;
}
return floorGrid.ContainsKey(pos) ? floorGrid[pos] : null; return floorGrid.ContainsKey(pos) ? floorGrid[pos] : null;
} }
/// <summary> /// <summary>
...@@ -39,6 +34,15 @@ public class Map : MonoBehaviour ...@@ -39,6 +34,15 @@ public class Map : MonoBehaviour
return wallGrid.ContainsKey(pos) ? wallGrid[pos] : null; return wallGrid.ContainsKey(pos) ? wallGrid[pos] : null;
} }
/// <summary> /// <summary>
/// Get object at position.
/// </summary>
/// <param name="pos">Position of object.</param>
/// <returns></returns>
public IObject GetObjectAtPos(Vector2Int pos)
{
return objectGrid.ContainsKey(pos) ? objectGrid[pos] : null;
}
/// <summary>
/// Create floor at position. /// Create floor at position.
/// </summary> /// </summary>
/// <param name="pos">Position of floor.</param> /// <param name="pos">Position of floor.</param>
...@@ -97,7 +101,7 @@ public class Map : MonoBehaviour ...@@ -97,7 +101,7 @@ public class Map : MonoBehaviour
/// Create wall at position. /// Create wall at position.
/// </summary> /// </summary>
/// <param name="pos">Position of wall.</param> /// <param name="pos">Position of wall.</param>
/// <param name="wallType">Type of walls.</param> /// <param name="wallType">Type of wall.</param>
public void CreateWall(Vector2 pos, WallType wallType) public void CreateWall(Vector2 pos, WallType wallType)
{ {
if (((int)pos.x >= 0 ? ((int)pos.x > maxMapSize / 2) : ((int)pos.x < -maxMapSize / 2)) || ((int)pos.y >= 0 ? ((int)pos.y > maxMapSize / 2) : ((int)pos.y < -maxMapSize / 2))) if (((int)pos.x >= 0 ? ((int)pos.x > maxMapSize / 2) : ((int)pos.x < -maxMapSize / 2)) || ((int)pos.y >= 0 ? ((int)pos.y > maxMapSize / 2) : ((int)pos.y < -maxMapSize / 2)))
...@@ -158,6 +162,54 @@ public class Map : MonoBehaviour ...@@ -158,6 +162,54 @@ public class Map : MonoBehaviour
else else
Debug.Log("Wall doesn't exists between : " + pos); Debug.Log("Wall doesn't exists between : " + pos);
} }
/// <summary>
/// Create object at position.
/// </summary>
/// <param name="pos">Position of object.</param>
/// <param name="objType">Type of object.</param>
public void CreateObject(Vector2Int pos, ObjType objType)
{
if ((pos.x >= 0 ? (pos.x > maxMapSize / 2) : (pos.x < -maxMapSize / 2)) || (pos.y >= 0 ? (pos.y > maxMapSize / 2) : (pos.y < -maxMapSize / 2)))
{
Debug.Log("Input size exceeds map's max size.");
return;
}
if (!objectGrid.ContainsKey(pos))
{
objectGrid.Add(pos, Instantiate(MapManager.inst.objects[(int)objType - 1], new Vector3(pos.x, 0, pos.y), Quaternion.identity, objects.transform).GetComponent<IObject>());
switch (objType)
{
case ObjType.Briefcase:
objectGrid[pos].GetObject().GetComponent<Briefcase>().Init(GetFloorAtPos(pos));
return;
case ObjType.Camera:
objectGrid[pos].GetObject().GetComponent<CameraTurret>().Init(GetFloorAtPos(pos));
return;
//Need to make mannequin init
/*case ObjType.Mannequin:
objectGrid[pos].GetObject().GetComponent<Mannequin>().Init(GetFloorAtPos(pos));
return;*/
}
StartCoroutine(MapManager.inst.Rebaker());
}
else
Debug.Log("Object already exists at : (" + pos.x + ", " + pos.y + ")");
}
/// <summary>
/// Remove Object at position.
/// </summary>
/// <param name="pos">Position of object.</param>
public void RemoveObject(Vector2Int pos)
{
if (objectGrid.ContainsKey(pos))
{
Destroy(objectGrid[pos].GetObject());
objectGrid.Remove(pos);
StartCoroutine(MapManager.inst.Rebaker());
}
else
Debug.Log("Object doesn't exists between : " + pos);
}
private void LoadObjects() private void LoadObjects()
{ {
...@@ -185,6 +237,7 @@ public class Map : MonoBehaviour ...@@ -185,6 +237,7 @@ public class Map : MonoBehaviour
{ {
floorGrid = new Dictionary<Vector2Int, Floor>(); floorGrid = new Dictionary<Vector2Int, Floor>();
wallGrid = new Dictionary<Vector2, Wall>(); wallGrid = new Dictionary<Vector2, Wall>();
objectGrid = new Dictionary<Vector2Int, IObject>();
startFloors = new List<Floor>(); startFloors = new List<Floor>();
} }
...@@ -196,7 +249,7 @@ public class Map : MonoBehaviour ...@@ -196,7 +249,7 @@ public class Map : MonoBehaviour
// Start is called before the first frame update // Start is called before the first frame update
void Start() void Start()
{ {
Debug.Log((-0.5 * 10) % 10);
} }
// Update is called once per frame // Update is called once per frame
......
...@@ -10,6 +10,7 @@ public class MapManager : SingletonBehaviour<MapManager> ...@@ -10,6 +10,7 @@ public class MapManager : SingletonBehaviour<MapManager>
public Floor floor; public Floor floor;
public NormalWall normalWall; public NormalWall normalWall;
public Mirror mirror; public Mirror mirror;
public GameObject[] objects;
public List<GameObject> players; public List<GameObject> players;
public GameObject player; public GameObject player;
public Map currentMap; public Map currentMap;
......
...@@ -84,7 +84,7 @@ public class Player : MonoBehaviour ...@@ -84,7 +84,7 @@ public class Player : MonoBehaviour
{ {
float time = Time.time; float time = Time.time;
float endTime = startTime + 2; float endTime = startTime + 2;
while(time <= endTime) while (time <= endTime)
{ {
yield return null; yield return null;
time = Time.time; time = Time.time;
......
...@@ -9,7 +9,7 @@ public class TestTools : MonoBehaviour ...@@ -9,7 +9,7 @@ public class TestTools : MonoBehaviour
public InputField wallXInput, wallYInput; public InputField wallXInput, wallYInput;
/*public void AddFloor() public void AddFloor()
{ {
MapManager.inst.currentMap.CreateFloor(new Vector2Int(int.Parse(floorXInput.text), int.Parse(floorYInput.text))); MapManager.inst.currentMap.CreateFloor(new Vector2Int(int.Parse(floorXInput.text), int.Parse(floorYInput.text)));
} }
...@@ -19,12 +19,20 @@ public class TestTools : MonoBehaviour ...@@ -19,12 +19,20 @@ public class TestTools : MonoBehaviour
} }
public void AddWall() public void AddWall()
{ {
MapManager.inst.currentMap.CreateWall(new Vector2(float.Parse(wallXInput.text), float.Parse(wallYInput.text))); MapManager.inst.currentMap.CreateWall(new Vector2(float.Parse(wallXInput.text), float.Parse(wallYInput.text)), WallType.Normal);
} }
public void RemoveWall() public void RemoveWall()
{ {
MapManager.inst.currentMap.RemoveWall(new Vector2(float.Parse(wallXInput.text), float.Parse(wallYInput.text))); MapManager.inst.currentMap.RemoveWall(new Vector2(float.Parse(wallXInput.text), float.Parse(wallYInput.text)));
} }
public void AddTurret()
{
MapManager.inst.currentMap.CreateObject(new Vector2Int(int.Parse(floorXInput.text), int.Parse(floorYInput.text)), ObjType.Camera);
}
public void RemoveTurret()
{
MapManager.inst.currentMap.RemoveObject(new Vector2Int(int.Parse(floorXInput.text), int.Parse(floorYInput.text)));
}
public void SaveMap() public void SaveMap()
{ {
...@@ -33,7 +41,7 @@ public class TestTools : MonoBehaviour ...@@ -33,7 +41,7 @@ public class TestTools : MonoBehaviour
public void LoadMap() public void LoadMap()
{ {
MapManager.inst.LoadMap(MapManager.inst.stage[1]); MapManager.inst.LoadMap(MapManager.inst.stage[1]);
}*/ }
// Start is called before the first frame update // Start is called before the first frame update
void Start() 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