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

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

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