Commit d5b6c173 authored by 18손재민's avatar 18손재민

카메라 감지하는거 적용함

parent 1c531be9
...@@ -4,13 +4,10 @@ using UnityEngine; ...@@ -4,13 +4,10 @@ using UnityEngine;
public static class Vector2IntExtensions public static class Vector2IntExtensions
{ {
public static bool IsInSquareArea(this Vector2Int a, Vector2Int b, int size) public static bool IsInAdjacentArea(this Vector2Int a, Vector2Int b, int size)
{ {
bool xdiff = Mathf.Abs(a.x - b.x) <= size; return (a - b).magnitude <= size;
bool ydiff = Mathf.Abs(a.y - b.y) <= size; }
return (xdiff && !ydiff) || (!xdiff && ydiff);
}
public static int ManhattanDistance(this Vector2Int a, Vector2Int b) public static int ManhattanDistance(this Vector2Int a, Vector2Int b)
{ {
return Mathf.Abs(a.x - b.x) + Mathf.Abs(a.y - b.y); return Mathf.Abs(a.x - b.x) + Mathf.Abs(a.y - b.y);
......
...@@ -21,9 +21,9 @@ public class CameraTurret : MonoBehaviour, IObject, IBreakable, IPlayerInteracto ...@@ -21,9 +21,9 @@ public class CameraTurret : MonoBehaviour, IObject, IBreakable, IPlayerInteracto
public void Interact(Vector2Int pos) public void Interact(Vector2Int pos)
{ {
if (Position.IsInSquareArea(pos, 1)) if (Position.IsInAdjacentArea(pos, 1))
{ {
Debug.Log("Stage Restart!"); Debug.Log(Position.x + " " + Position.y +" Stage Restart!");
//TODO : Restart Level //TODO : Restart Level
} }
} }
......
...@@ -10,14 +10,17 @@ public class PlayerController : SingletonBehaviour<PlayerController> ...@@ -10,14 +10,17 @@ public class PlayerController : SingletonBehaviour<PlayerController>
public bool isPlayerMoving; public bool isPlayerMoving;
public bool isPlayerShooting; public bool isPlayerShooting;
public bool isZooming; public bool isZooming;
private Vector2Int prePos; [SerializeField] private Vector2Int prePos;
public Vector2Int MapPos public Vector2Int MapPos
{ {
get get
{ {
Vector2Int pos = Vector2Int.zero; Vector2Int pos = Vector2Int.zero;
pos.x = Mathf.RoundToInt(transform.position.x); if (currentPlayer)
pos.y = Mathf.RoundToInt(transform.position.y); {
pos.x = Mathf.RoundToInt(currentPlayer.transform.position.x);
pos.y = Mathf.RoundToInt(currentPlayer.transform.position.z);
}
return pos; return pos;
} }
} }
......
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