Commit 5ac41704 authored by 18손재민's avatar 18손재민

머지 반정도함. 거울을 맵에 연결함

parent 238ad08b
fileFormatVersion: 2 fileFormatVersion: 2
guid: a32ca40f7f255ea47ac7ee9d558755ce guid: f6226b2548447a54486acfc694a44e4d
folderAsset: yes folderAsset: yes
DefaultImporter: DefaultImporter:
externalObjects: {} externalObjects: {}
......
This diff is collapsed.
fileFormatVersion: 2
guid: bec0ce48aa2c7d14abcf504346360066
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2 fileFormatVersion: 2
guid: 49597164dd7e7454ca5a790c491a214e guid: efdd0a8c7422a444aaf46a97886b9674
PrefabImporter: PrefabImporter:
externalObjects: {} externalObjects: {}
userData: userData:
......
...@@ -60,6 +60,8 @@ Transform: ...@@ -60,6 +60,8 @@ Transform:
m_Children: m_Children:
- {fileID: 630498074586648373} - {fileID: 630498074586648373}
- {fileID: 630498075143909937} - {fileID: 630498075143909937}
- {fileID: 3826732887261846405}
- {fileID: 529438060023616287}
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 0 m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
...@@ -79,8 +81,10 @@ MonoBehaviour: ...@@ -79,8 +81,10 @@ MonoBehaviour:
testInputSizeY: 0 testInputSizeY: 0
maxMapSize: 0 maxMapSize: 0
floors: {fileID: 630498074586648370} floors: {fileID: 630498074586648370}
walls: {fileID: 630498075143909950} normalWalls: {fileID: 630498075143909950}
startFloor: {fileID: 0} mirrors: {fileID: 7511194446601115184}
objects: {fileID: 4632550998073714819}
startFloors: []
--- !u!1 &630498075143909950 --- !u!1 &630498075143909950
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
...@@ -91,7 +95,7 @@ GameObject: ...@@ -91,7 +95,7 @@ GameObject:
m_Component: m_Component:
- component: {fileID: 630498075143909937} - component: {fileID: 630498075143909937}
m_Layer: 0 m_Layer: 0
m_Name: Walls m_Name: NormalWalls
m_TagString: Untagged m_TagString: Untagged
m_Icon: {fileID: 0} m_Icon: {fileID: 0}
m_NavMeshLayer: 0 m_NavMeshLayer: 0
...@@ -111,3 +115,63 @@ Transform: ...@@ -111,3 +115,63 @@ Transform:
m_Father: {fileID: 630498074781569475} m_Father: {fileID: 630498074781569475}
m_RootOrder: 1 m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &4632550998073714819
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 529438060023616287}
m_Layer: 0
m_Name: Objects
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &529438060023616287
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4632550998073714819}
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: 630498074781569475}
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &7511194446601115184
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 3826732887261846405}
m_Layer: 0
m_Name: Mirrors
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &3826732887261846405
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7511194446601115184}
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: 630498074781569475}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
...@@ -2000,13 +2000,12 @@ MonoBehaviour: ...@@ -2000,13 +2000,12 @@ MonoBehaviour:
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
floor: {fileID: 19711883686801522, guid: 71931eea896a59a4683986cfd369b8ee, type: 3} floor: {fileID: 19711883686801522, guid: 71931eea896a59a4683986cfd369b8ee, type: 3}
wall: {fileID: 3736402816908646744, guid: a4dcd71ec9f819f4e88c7b5ac24f4b0d, type: 3} wall: {fileID: 2953616027608884528, guid: a4dcd71ec9f819f4e88c7b5ac24f4b0d, type: 3}
currentMap: {fileID: 0} currentMap: {fileID: 0}
stage: stage:
- {fileID: 630498074781569474, guid: 759f352c81f1b5a40b2d8d241cdf273b, type: 3} - {fileID: 630498074781569474, guid: 759f352c81f1b5a40b2d8d241cdf273b, type: 3}
tile: {fileID: 7449840556337937162, guid: 90d0ab9f40a0ddc4c871130319d86cd5, type: 3} tile: {fileID: 7449840556337937162, guid: 90d0ab9f40a0ddc4c871130319d86cd5, type: 3}
modeSign: {fileID: 153720729} modeSign: {fileID: 153720729}
clickSign: {fileID: 0}
startSign: {fileID: 1215997560627761150, guid: 106914c4661964b47ad09efcc4bfba69, startSign: {fileID: 1215997560627761150, guid: 106914c4661964b47ad09efcc4bfba69,
type: 3} type: 3}
mapSizeSetter: {fileID: 8774990006778924709} mapSizeSetter: {fileID: 8774990006778924709}
......
...@@ -45,7 +45,8 @@ MonoBehaviour: ...@@ -45,7 +45,8 @@ MonoBehaviour:
m_EditorClassIdentifier: m_EditorClassIdentifier:
isMapEditingOn: 0 isMapEditingOn: 0
floor: {fileID: 19711883686801522, guid: 71931eea896a59a4683986cfd369b8ee, type: 3} floor: {fileID: 19711883686801522, guid: 71931eea896a59a4683986cfd369b8ee, type: 3}
wall: {fileID: 3736402816908646744, guid: a4dcd71ec9f819f4e88c7b5ac24f4b0d, type: 3} normalWall: {fileID: 2953616027608884528, guid: a4dcd71ec9f819f4e88c7b5ac24f4b0d,
type: 3}
players: [] players: []
player: {fileID: 8862060874303168220, guid: 6ba287375b5ad4b458a7b7b99c6d6a08, type: 3} player: {fileID: 8862060874303168220, guid: 6ba287375b5ad4b458a7b7b99c6d6a08, type: 3}
currentMap: {fileID: 0} currentMap: {fileID: 0}
......
...@@ -13,7 +13,7 @@ GameObject: ...@@ -13,7 +13,7 @@ GameObject:
- component: {fileID: 337530617402888144} - component: {fileID: 337530617402888144}
- component: {fileID: 5992419591198202452} - component: {fileID: 5992419591198202452}
- component: {fileID: 1788580750165913660} - component: {fileID: 1788580750165913660}
- component: {fileID: 3736402816908646744} - component: {fileID: 2953616027608884528}
m_Layer: 0 m_Layer: 0
m_Name: wall m_Name: wall
m_TagString: wall m_TagString: wall
...@@ -109,7 +109,7 @@ NavMeshObstacle: ...@@ -109,7 +109,7 @@ NavMeshObstacle:
m_CarveOnlyStationary: 1 m_CarveOnlyStationary: 1
m_Center: {x: 0, y: 0.6, z: 0} m_Center: {x: 0, y: 0.6, z: 0}
m_TimeToStationary: 0.5 m_TimeToStationary: 0.5
--- !u!114 &3736402816908646744 --- !u!114 &2953616027608884528
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0} m_CorrespondingSourceObject: {fileID: 0}
...@@ -118,6 +118,9 @@ MonoBehaviour: ...@@ -118,6 +118,9 @@ MonoBehaviour:
m_GameObject: {fileID: 337530617404887312} m_GameObject: {fileID: 337530617404887312}
m_Enabled: 1 m_Enabled: 1
m_EditorHideFlags: 0 m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 12e6eb2c47d8fa6439494493e8238a81, type: 3} m_Script: {fileID: 11500000, guid: a6d2b4a608022ae47a6546f7b81357da, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
mapPos: {x: 0, y: 0}
len: 1
type: 1
...@@ -232,8 +232,8 @@ Camera: ...@@ -232,8 +232,8 @@ Camera:
height: 1 height: 1
near clip plane: 0.3 near clip plane: 0.3
far clip plane: 1000 far clip plane: 1000
field of view: 60 field of view: 40
orthographic: 1 orthographic: 0
orthographic size: 5 orthographic size: 5
m_Depth: -1 m_Depth: -1
m_CullingMask: m_CullingMask:
...@@ -257,13 +257,13 @@ Transform: ...@@ -257,13 +257,13 @@ Transform:
m_PrefabInstance: {fileID: 0} m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 534669902} m_GameObject: {fileID: 534669902}
m_LocalRotation: {x: 0.22350667, y: 0.3713161, z: -0.09257949, w: 0.8964364} m_LocalRotation: {x: 0.23911765, y: 0.3696438, z: -0.09904577, w: 0.89239913}
m_LocalPosition: {x: -12, y: 10, z: -12} m_LocalPosition: {x: -12, y: 10, z: -12}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: [] m_Children: []
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 4 m_RootOrder: 4
m_LocalEulerAnglesHint: {x: 28, y: 45, z: 0} m_LocalEulerAnglesHint: {x: 30, y: 45, z: 0}
--- !u!114 &534669906 --- !u!114 &534669906
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
...@@ -639,6 +639,12 @@ PrefabInstance: ...@@ -639,6 +639,12 @@ PrefabInstance:
propertyPath: surface propertyPath: surface
value: value:
objectReference: {fileID: 2102809461} objectReference: {fileID: 2102809461}
- target: {fileID: 3268100033343711389, guid: 11285456de5f1854d947bea83275646f,
type: 3}
propertyPath: stage.Array.data[0]
value:
objectReference: {fileID: 1662066324165145400, guid: efdd0a8c7422a444aaf46a97886b9674,
type: 3}
m_RemovedComponents: [] m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 11285456de5f1854d947bea83275646f, type: 3} m_SourcePrefab: {fileID: 100100000, guid: 11285456de5f1854d947bea83275646f, type: 3}
--- !u!1001 &7277015660625800392 --- !u!1001 &7277015660625800392
......
...@@ -7,6 +7,10 @@ public class CameraController : MonoBehaviour ...@@ -7,6 +7,10 @@ public class CameraController : MonoBehaviour
Vector3 dragOrigin; Vector3 dragOrigin;
public float dragSpeed; public float dragSpeed;
Vector3 previousPos; Vector3 previousPos;
float shootingFov = 60f;
float mapFov = 40f;
Vector3 centerPos = new Vector3(0, 0, 0);
bool isZooming = false; bool isZooming = false;
/// <summary> /// <summary>
/// Move camera. /// Move camera.
...@@ -31,14 +35,15 @@ public class CameraController : MonoBehaviour ...@@ -31,14 +35,15 @@ public class CameraController : MonoBehaviour
if (!Input.GetMouseButton(1)) return; if (!Input.GetMouseButton(1)) return;
float deg = Mathf.Atan2(transform.position.z, transform.position.x); float deg = Mathf.Atan2(transform.position.z - centerPos.z, transform.position.x - centerPos.x);
float dis = Vector3.Distance(Vector3.zero, transform.position - new Vector3(0, transform.position.y, 0)); float dis = Vector3.Distance(centerPos, transform.position - new Vector3(0, transform.position.y - centerPos.y, 0));
float dif = Camera.main.ScreenToViewportPoint(Input.mousePosition - dragOrigin).x * dragSpeed; float dif = Camera.main.ScreenToViewportPoint(Input.mousePosition - dragOrigin).x * dragSpeed;
transform.position = new Vector3(Mathf.Cos(deg + dif) * dis, transform.position.y, Mathf.Sin(deg + dif) * dis); transform.position = new Vector3(Mathf.Cos(deg - dif) * dis + centerPos.x, transform.position.y, Mathf.Sin(deg - dif) * dis + centerPos.z);
transform.LookAt(new Vector3(0, 1, 0)); transform.LookAt(centerPos);
dragOrigin = Input.mousePosition; dragOrigin = Input.mousePosition;
transform.eulerAngles = new Vector3(30, transform.eulerAngles.y, transform.eulerAngles.z);
} }
/// <summary> /// <summary>
/// Zoom in at player. /// Zoom in at player.
...@@ -48,15 +53,16 @@ public class CameraController : MonoBehaviour ...@@ -48,15 +53,16 @@ public class CameraController : MonoBehaviour
public IEnumerator ZoomInAtPlayer(Player player) public IEnumerator ZoomInAtPlayer(Player player)
{ {
float startTime = Time.time; float startTime = Time.time;
Vector3 posDiff = (player.head.transform.position - transform.position) / 50; Vector3 posDiff = (player.head.transform.position - transform.position) / 40;
Vector3 angleDiff = (new Vector3(0, transform.eulerAngles.y, 0) - transform.eulerAngles) / 50; Vector3 angleDiff = (new Vector3(0, transform.eulerAngles.y, 0) - transform.eulerAngles) / 40;
float fovDiff = (shootingFov - mapFov) / 40f;
previousPos = transform.position; previousPos = transform.position;
Camera.main.orthographic = false; for (int i = 0; i < 40; i++)
for (int i = 0; i < 50; i++)
{ {
yield return null; yield return null;
transform.position += posDiff; transform.position += posDiff;
transform.eulerAngles += angleDiff; transform.eulerAngles += angleDiff;
Camera.main.fieldOfView += fovDiff;
} }
transform.position = player.head.transform.position; transform.position = player.head.transform.position;
} }
...@@ -67,23 +73,25 @@ public class CameraController : MonoBehaviour ...@@ -67,23 +73,25 @@ public class CameraController : MonoBehaviour
public IEnumerator ZoomOutFromPlayer() public IEnumerator ZoomOutFromPlayer()
{ {
float startTime = Time.time; float startTime = Time.time;
Vector3 posDiff = (previousPos - transform.position) / 50; Vector3 posDiff = (previousPos - transform.position) / 40;
Vector3 angleDiff = (new Vector3(30, transform.eulerAngles.y, transform.eulerAngles.z) - transform.eulerAngles) / 50; Vector3 angleDiff = (new Vector3(30, transform.eulerAngles.y, transform.eulerAngles.z) - transform.eulerAngles) / 40;
for (int i = 0; i < 50; i++) float fovDiff = (mapFov - shootingFov) / 40f;
for (int i = 0; i < 40; i++)
{ {
yield return null; yield return null;
transform.position += posDiff; transform.position += posDiff;
transform.eulerAngles += angleDiff; transform.eulerAngles += angleDiff;
Camera.main.fieldOfView += fovDiff;
} }
transform.position = previousPos; transform.position = previousPos;
Camera.main.orthographic = true;
PlayerController.inst.isPlayerShooting = false; PlayerController.inst.isPlayerShooting = false;
} }
// Start is called before the first frame update // Start is called before the first frame update
void Start() void Start()
{ {
Camera.main.fieldOfView = mapFov;
transform.eulerAngles = new Vector3(30, transform.eulerAngles.y, transform.eulerAngles.z);
} }
......
...@@ -13,9 +13,9 @@ public class Briefcase : MonoBehaviour, IObject, IPlayerInteractor ...@@ -13,9 +13,9 @@ public class Briefcase : MonoBehaviour, IObject, IPlayerInteractor
return gameObject; return gameObject;
} }
public Vector2 GetPos() public Vector2Int GetPos()
{ {
return new Vector2(transform.position.x, transform.position.z); return new Vector2Int((int)transform.position.x, (int)transform.position.z);
} }
public void Init(Floor floor) public void Init(Floor floor)
......
...@@ -33,9 +33,9 @@ public class CameraTurret : MonoBehaviour, IObject, IBreakable, IPlayerInteracto ...@@ -33,9 +33,9 @@ public class CameraTurret : MonoBehaviour, IObject, IBreakable, IPlayerInteracto
return gameObject; return gameObject;
} }
public Vector2 GetPos() public Vector2Int GetPos()
{ {
return new Vector2(transform.position.x, transform.position.z); return new Vector2Int((int)transform.position.x, (int)transform.position.z);
} }
ObjType IObject.GetType() ObjType IObject.GetType()
......
...@@ -13,6 +13,6 @@ public enum ObjType ...@@ -13,6 +13,6 @@ public enum ObjType
public interface IObject public interface IObject
{ {
GameObject GetObject(); GameObject GetObject();
Vector2 GetPos(); Vector2Int GetPos();
ObjType GetType(); ObjType GetType();
} }
...@@ -54,9 +54,9 @@ public class Mannequin : MonoBehaviour, IObject, IBulletInteractor ...@@ -54,9 +54,9 @@ public class Mannequin : MonoBehaviour, IObject, IBulletInteractor
return gameObject; return gameObject;
} }
public Vector2 GetPos() public Vector2Int GetPos()
{ {
return new Vector2(transform.position.x, transform.position.z); return new Vector2Int((int)transform.position.x, (int)transform.position.z);
} }
ObjType IObject.GetType() ObjType IObject.GetType()
......
...@@ -9,11 +9,6 @@ public class Floor : MonoBehaviour ...@@ -9,11 +9,6 @@ public class Floor : MonoBehaviour
/// </summary> /// </summary>
public Vector2Int mapPos; public Vector2Int mapPos;
public void SetmapPos(Vector2Int pos)
{
mapPos = pos;
}
// Start is called before the first frame update // Start is called before the first frame update
void Start() void Start()
{ {
......
...@@ -8,11 +8,13 @@ public class Map : MonoBehaviour ...@@ -8,11 +8,13 @@ public class Map : MonoBehaviour
public int testInputSizeX, testInputSizeY; public int testInputSizeX, testInputSizeY;
public int maxMapSize; public int maxMapSize;
public Dictionary<Vector2Int, Floor> floorGrid; public Dictionary<Vector2Int, Floor> floorGrid;
public Dictionary<Vector2, Wall> wallGrid; public Dictionary<Vector2, NormalWall> normalWallGrid;
public Dictionary<Vector2, Mirror> mirrorGrid; public Dictionary<Vector2, Mirror> mirrorGrid;
public Dictionary<Vector2Int, IObject> objectGrid; public Dictionary<Vector2Int, IObject> objectGrid;
public GameObject floors; public GameObject floors;
public GameObject walls; public GameObject normalWalls;
public GameObject mirrors;
public GameObject objects;
public List<Floor> startFloors; public List<Floor> startFloors;
/// <summary> /// <summary>
...@@ -36,7 +38,7 @@ public class Map : MonoBehaviour ...@@ -36,7 +38,7 @@ public class Map : MonoBehaviour
/// <returns></returns> /// <returns></returns>
public Wall GetWallAtPos(Vector2 pos) public Wall GetWallAtPos(Vector2 pos)
{ {
return wallGrid.ContainsKey(pos) ? wallGrid[pos] : null; return normalWallGrid.ContainsKey(pos) ? normalWallGrid[pos] : null;
} }
/// <summary> /// <summary>
/// Create floor at position. /// Create floor at position.
...@@ -52,7 +54,7 @@ public class Map : MonoBehaviour ...@@ -52,7 +54,7 @@ public class Map : MonoBehaviour
if (!floorGrid.ContainsKey(pos)) if (!floorGrid.ContainsKey(pos))
{ {
floorGrid.Add(pos, Instantiate(MapManager.inst.floor, new Vector3(pos.x, 0, pos.y), Quaternion.identity, floors.transform).GetComponent<Floor>()); floorGrid.Add(pos, Instantiate(MapManager.inst.floor, new Vector3(pos.x, 0, pos.y), Quaternion.identity, floors.transform).GetComponent<Floor>());
floorGrid[pos].SetmapPos(pos); floorGrid[pos].mapPos = pos;
StartCoroutine(MapManager.inst.Rebaker()); StartCoroutine(MapManager.inst.Rebaker());
} }
else else
...@@ -97,7 +99,7 @@ public class Map : MonoBehaviour ...@@ -97,7 +99,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>
public void CreateWall(Vector2 pos) public void CreateNormalWall(Vector2 pos)
{ {
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)))
{ {
...@@ -109,14 +111,14 @@ public class Map : MonoBehaviour ...@@ -109,14 +111,14 @@ public class Map : MonoBehaviour
Debug.Log("Inappropriate position of wall."); Debug.Log("Inappropriate position of wall.");
return; return;
} }
if (!wallGrid.ContainsKey(pos)) if (!normalWallGrid.ContainsKey(pos))
{ {
wallGrid.Add(pos, Instantiate(MapManager.inst.wall, new Vector3(pos.x, 0, pos.y), Quaternion.identity, walls.transform).GetComponent<Wall>()); normalWallGrid.Add(pos, Instantiate(MapManager.inst.normalWall, new Vector3(pos.x, 0, pos.y), Quaternion.identity, normalWalls.transform).GetComponent<NormalWall>());
wallGrid[pos].SetmapPos(pos); normalWallGrid[pos].mapPos = pos;
if (Mathf.Abs(pos.x * 10) % 10 == 5) if (Mathf.Abs(pos.x * 10) % 10 == 5)
wallGrid[pos].transform.eulerAngles = new Vector3(0, 90, 0); normalWallGrid[pos].transform.eulerAngles = new Vector3(0, 90, 0);
else if (Mathf.Abs(pos.y * 10) % 10 == 5) else if (Mathf.Abs(pos.y * 10) % 10 == 5)
wallGrid[pos].transform.eulerAngles = new Vector3(0, 0, 0); normalWallGrid[pos].transform.eulerAngles = new Vector3(0, 0, 0);
StartCoroutine(MapManager.inst.Rebaker()); StartCoroutine(MapManager.inst.Rebaker());
} }
else else
...@@ -128,12 +130,12 @@ public class Map : MonoBehaviour ...@@ -128,12 +130,12 @@ public class Map : MonoBehaviour
/// <param name="pos">Start position of wall.</param> /// <param name="pos">Start position of wall.</param>
/// <param name="dir">Direction of walls.</param> /// <param name="dir">Direction of walls.</param>
/// <param name="length">Amount of walls.</param> /// <param name="length">Amount of walls.</param>
public void CreateWall(Vector2 pos, Vector2 dir, int length) public void CreateNormalWall(Vector2 pos, Vector2 dir, int length)
{ {
Vector2 wallPos = pos; Vector2 wallPos = pos;
for (int i = 0; i < length; i++) for (int i = 0; i < length; i++)
{ {
CreateWall(wallPos); CreateNormalWall(wallPos);
wallPos += new Vector2((int)dir.x, (int)dir.y); wallPos += new Vector2((int)dir.x, (int)dir.y);
} }
} }
...@@ -143,10 +145,10 @@ public class Map : MonoBehaviour ...@@ -143,10 +145,10 @@ public class Map : MonoBehaviour
/// <param name="pos">Position of wall.</param> /// <param name="pos">Position of wall.</param>
public void RemoveWall(Vector2 pos) public void RemoveWall(Vector2 pos)
{ {
if (wallGrid.ContainsKey(pos)) if (normalWallGrid.ContainsKey(pos))
{ {
Destroy(wallGrid[pos].gameObject); Destroy(normalWallGrid[pos].gameObject);
wallGrid.Remove(pos); normalWallGrid.Remove(pos);
StartCoroutine(MapManager.inst.Rebaker()); StartCoroutine(MapManager.inst.Rebaker());
} }
else else
...@@ -156,23 +158,35 @@ public class Map : MonoBehaviour ...@@ -156,23 +158,35 @@ public class Map : MonoBehaviour
private void LoadObjects() private void LoadObjects()
{ {
floorGrid = new Dictionary<Vector2Int, Floor>(); floorGrid = new Dictionary<Vector2Int, Floor>();
wallGrid = new Dictionary<Vector2, Wall>(); normalWallGrid = new Dictionary<Vector2, NormalWall>();
mirrorGrid = new Dictionary<Vector2, Mirror>();
objectGrid = new Dictionary<Vector2Int, IObject>();
for (int i = 0; i < floors.transform.childCount; i++) for (int i = 0; i < floors.transform.childCount; i++)
{ {
Floor floor = floors.transform.GetChild(i).GetComponent<Floor>(); Floor floor = floors.transform.GetChild(i).GetComponent<Floor>();
floorGrid.Add(floor.mapPos, floor); floorGrid.Add(floor.mapPos, floor);
} }
for (int i = 0; i < walls.transform.childCount; i++) for (int i = 0; i < normalWalls.transform.childCount; i++)
{ {
Wall wall = walls.transform.GetChild(i).GetComponent<Wall>(); NormalWall normalWall = normalWalls.transform.GetChild(i).GetComponent<NormalWall>();
wallGrid.Add(wall.mapPos, wall); normalWallGrid.Add(normalWall.mapPos, normalWall);
}
for (int i = 0; i < mirrors.transform.childCount; i++)
{
Mirror mirror = mirrors.transform.GetChild(i).GetComponent<Mirror>();
mirrorGrid.Add(mirror.mapPos, mirror);
}
for (int i = 0; i < mirrors.transform.childCount; i++)
{
IObject iObject = objects.transform.GetChild(i).GetComponent<IObject>();
objectGrid.Add(iObject.GetPos(), iObject);
} }
} }
public void InitiateMap() public void InitiateMap()
{ {
floorGrid = new Dictionary<Vector2Int, Floor>(); floorGrid = new Dictionary<Vector2Int, Floor>();
wallGrid = new Dictionary<Vector2, Wall>(); normalWallGrid = new Dictionary<Vector2, NormalWall>();
startFloors = new List<Floor>(); startFloors = new List<Floor>();
} }
......
...@@ -36,7 +36,7 @@ public class Mirror : Wall, IBulletInteractor, IBreakable ...@@ -36,7 +36,7 @@ public class Mirror : Wall, IBulletInteractor, IBreakable
}; };
// check before reflect (check walls and mirrors) // check before reflect (check walls and mirrors)
foreach (var wall in MapManager.inst.currentMap.wallGrid) foreach (var wall in MapManager.inst.currentMap.normalWallGrid)
{ {
Pair<float, float> pair = new Pair<float, float>(PointToParRay(stPos, wall.Value.ldPos, false), PointToParRay(stPos, wall.Value.rdPos, false)); Pair<float, float> pair = new Pair<float, float>(PointToParRay(stPos, wall.Value.ldPos, false), PointToParRay(stPos, wall.Value.rdPos, false));
if (pair.l > pair.r) pair = pair.Swap(); if (pair.l > pair.r) pair = pair.Swap();
...@@ -74,7 +74,7 @@ public class Mirror : Wall, IBulletInteractor, IBreakable ...@@ -74,7 +74,7 @@ public class Mirror : Wall, IBulletInteractor, IBreakable
{ // copy floor { // copy floor
int nextx = dir ? floor.Key.x : 2 * ldPos.x - floor.Key.x; int nextx = dir ? floor.Key.x : 2 * ldPos.x - floor.Key.x;
int nexty = dir ? 2 * ldPos.y - floor.Key.y : floor.Key.y; int nexty = dir ? 2 * ldPos.y - floor.Key.y : floor.Key.y;
MapManager.inst.currentMap.CreateFloor(nextx, nexty); MapManager.inst.currentMap.CreateFloor(new Vector2Int(nextx, nexty));
} }
} }
} }
...@@ -88,7 +88,7 @@ public class Mirror : Wall, IBulletInteractor, IBreakable ...@@ -88,7 +88,7 @@ public class Mirror : Wall, IBulletInteractor, IBreakable
} }
} }
} }
foreach (var wall in MapManager.inst.currentMap.wallGrid) foreach (var wall in MapManager.inst.currentMap.normalWallGrid)
{ {
if ((dir ? wall.Key.y : wall.Key.x) == i) if ((dir ? wall.Key.y : wall.Key.x) == i)
{ {
......
...@@ -14,7 +14,7 @@ public class NormalWall : Wall, IBulletInteractor ...@@ -14,7 +14,7 @@ public class NormalWall : Wall, IBulletInteractor
{ {
Mirror mirror = gameObject.AddComponent<Mirror>(); Mirror mirror = gameObject.AddComponent<Mirror>();
GetComponent<Renderer>().material = GameManager.inst.mirrorMaterial; GetComponent<Renderer>().material = GameManager.inst.mirrorMaterial;
mirror.SetmapPos(mapPos); mirror.mapPos = mapPos;
mirror.len = len; mirror.len = len;
mirror.type = WallType.Mirror; mirror.type = WallType.Mirror;
Destroy(this); Destroy(this);
......
...@@ -30,11 +30,6 @@ public class Wall : MonoBehaviour ...@@ -30,11 +30,6 @@ public class Wall : MonoBehaviour
public int len = 1; // length of wall public int len = 1; // length of wall
public WallType type; public WallType type;
public void SetmapPos(Vector2 pos)
{
mapPos = pos;
}
// Start is called before the first frame update // Start is called before the first frame update
void Start() void Start()
{ {
......
...@@ -47,13 +47,13 @@ public class MapEditor : SingletonBehaviour<MapEditor> ...@@ -47,13 +47,13 @@ public class MapEditor : SingletonBehaviour<MapEditor>
Debug.Log("There is no start floor."); Debug.Log("There is no start floor.");
else else
{ {
foreach(Transform child in currentMap.walls.transform) foreach(Transform child in currentMap.normalWalls.transform)
{ {
child.gameObject.GetComponent<MeshRenderer>().material = realWallMat; child.gameObject.GetComponent<MeshRenderer>().material = realWallMat;
} }
PrefabUtility.SaveAsPrefabAsset(_newMap.gameObject, localPath); PrefabUtility.SaveAsPrefabAsset(_newMap.gameObject, localPath);
Debug.Log("Map saved at " + localPath); Debug.Log("Map saved at " + localPath);
foreach (Transform child in currentMap.walls.transform) foreach (Transform child in currentMap.normalWalls.transform)
{ {
child.gameObject.GetComponent<MeshRenderer>().material = editWallMat; child.gameObject.GetComponent<MeshRenderer>().material = editWallMat;
} }
...@@ -147,7 +147,7 @@ public class MapEditor : SingletonBehaviour<MapEditor> ...@@ -147,7 +147,7 @@ public class MapEditor : SingletonBehaviour<MapEditor>
if (isCreateMode) if (isCreateMode)
{ {
Debug.Log(wallPos); Debug.Log(wallPos);
currentMap.CreateWall(wallPos); currentMap.CreateNormalWall(wallPos);
if(currentMap.GetWallAtPos(wallPos) != null) if(currentMap.GetWallAtPos(wallPos) != null)
currentMap.GetWallAtPos(wallPos).gameObject.GetComponent<MeshRenderer>().material = editWallMat; currentMap.GetWallAtPos(wallPos).gameObject.GetComponent<MeshRenderer>().material = editWallMat;
} }
......
...@@ -8,7 +8,7 @@ public class MapManager : SingletonBehaviour<MapManager> ...@@ -8,7 +8,7 @@ public class MapManager : SingletonBehaviour<MapManager>
{ {
public bool isMapEditingOn; public bool isMapEditingOn;
public Floor floor; public Floor floor;
public Wall wall; public NormalWall normalWall;
public List<GameObject> players; public List<GameObject> players;
public GameObject player; public GameObject player;
public Map currentMap; public Map currentMap;
......
...@@ -19,7 +19,7 @@ public class TestTools : MonoBehaviour ...@@ -19,7 +19,7 @@ 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.CreateNormalWall(new Vector2(float.Parse(wallXInput.text), float.Parse(wallYInput.text)));
} }
public void RemoveWall() public void RemoveWall()
{ {
......
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