Commit dbbd1473 authored by 18신대성's avatar 18신대성

모든 Object에 대해 IObject라는 인터페이스를 만듬

parent a64e7953
...@@ -2,13 +2,23 @@ ...@@ -2,13 +2,23 @@
using System.Collections.Generic; using System.Collections.Generic;
using UnityEngine; using UnityEngine;
public class Briefcase : MonoBehaviour, IPlayerInteractor public class Briefcase : MonoBehaviour, IObject, IPlayerInteractor
{ {
[SerializeField] [SerializeField]
private Floor floor = null; private Floor floor = null;
public Vector2Int Position { get { return floor != null ? floor.mapPos : throw new UnassignedReferenceException("Floor of Interactor is not assigned"); } } public Vector2Int Position { get { return floor != null ? floor.mapPos : throw new UnassignedReferenceException("Floor of Interactor is not assigned"); } }
public void Init(Floor floor) public GameObject GetObject()
{
return gameObject;
}
public Vector2 GetPos()
{
return new Vector2(transform.position.x, transform.position.z);
}
public void Init(Floor floor)
{ {
this.floor = floor; this.floor = floor;
PlayerController.inst.OnPlayerMove += Interact; PlayerController.inst.OnPlayerMove += Interact;
...@@ -23,4 +33,9 @@ public class Briefcase : MonoBehaviour, IPlayerInteractor ...@@ -23,4 +33,9 @@ public class Briefcase : MonoBehaviour, IPlayerInteractor
Destroy(gameObject); Destroy(gameObject);
} }
} }
ObjType IObject.GetType()
{
return ObjType.Briefcase;
}
} }
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using UnityEngine; using UnityEngine;
public class CameraTurret : MonoBehaviour, IBreakable, IPlayerInteractor public class CameraTurret : MonoBehaviour, IObject, IBreakable, IPlayerInteractor
{ {
[SerializeField] [SerializeField]
private Floor floor = null; private Floor floor = null;
...@@ -27,4 +27,19 @@ public class CameraTurret : MonoBehaviour, IBreakable, IPlayerInteractor ...@@ -27,4 +27,19 @@ public class CameraTurret : MonoBehaviour, IBreakable, IPlayerInteractor
//TODO : Restart Level //TODO : Restart Level
} }
} }
public GameObject GetObject()
{
return gameObject;
}
public Vector2 GetPos()
{
return new Vector2(transform.position.x, transform.position.z);
}
ObjType IObject.GetType()
{
return ObjType.Camera;
}
} }
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public enum ObjType
{
NULL,
Briefcase,
Camera,
Mannequin
}
public interface IObject
{
GameObject GetObject();
Vector2 GetPos();
ObjType GetType();
}
fileFormatVersion: 2
guid: e7d883246c45c6f4f94bae2ca2d05d6f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using UnityEngine; using UnityEngine;
public class Mannequin : MonoBehaviour, IBulletInteractor public class Mannequin : MonoBehaviour, IObject, IBulletInteractor
{ {
[SerializeField] [SerializeField]
private Mesh[] mannequinMesh = new Mesh[2]; private Mesh[] mannequinMesh = new Mesh[2];
...@@ -48,4 +48,19 @@ public class Mannequin : MonoBehaviour, IBulletInteractor ...@@ -48,4 +48,19 @@ public class Mannequin : MonoBehaviour, IBulletInteractor
{ {
Color = isWhite ? Color.white : Color.black; Color = isWhite ? Color.white : Color.black;
} }
public GameObject GetObject()
{
return gameObject;
}
public Vector2 GetPos()
{
return new Vector2(transform.position.x, transform.position.z);
}
ObjType IObject.GetType()
{
return ObjType.Mannequin;
}
} }
...@@ -9,8 +9,8 @@ public class Map : MonoBehaviour ...@@ -9,8 +9,8 @@ public class Map : MonoBehaviour
public int maxMapSize; public int maxMapSize;
public Dictionary<Vector2Int, Floor> floorGrid; public Dictionary<Vector2Int, Floor> floorGrid;
public Dictionary<Vector2, Wall> wallGrid; public Dictionary<Vector2, Wall> wallGrid;
// public Dictionary<Vector2, Mirror> mirrorGrid; public Dictionary<Vector2, Mirror> mirrorGrid;
// public Dictionary<Vector2Int, InteractableObject> objectGrid; public Dictionary<Vector2Int, IObject> objectGrid;
public GameObject floors; public GameObject floors;
public GameObject walls; public GameObject walls;
public List<Floor> startFloors; public List<Floor> startFloors;
......
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