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

Merge branch 'interact'

# Conflicts:
#	Assets/Scripts/PlayerController.cs
parents f14c5b52 d5b6c173
......@@ -4,13 +4,10 @@ using UnityEngine;
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;
bool ydiff = Mathf.Abs(a.y - b.y) <= size;
return (xdiff && !ydiff) || (!xdiff && ydiff);
return (a - b).magnitude <= size;
}
public static int ManhattanDistance(this Vector2Int a, Vector2Int b)
{
return Mathf.Abs(a.x - b.x) + Mathf.Abs(a.y - b.y);
......
......@@ -21,9 +21,9 @@ public class CameraTurret : MonoBehaviour, IObject, IBreakable, IPlayerInteracto
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
}
}
......
......@@ -16,8 +16,11 @@ public class PlayerController : SingletonBehaviour<PlayerController>
get
{
Vector2Int pos = Vector2Int.zero;
pos.x = Mathf.RoundToInt(transform.position.x);
pos.y = Mathf.RoundToInt(transform.position.y);
if (currentPlayer)
{
pos.x = Mathf.RoundToInt(currentPlayer.transform.position.x);
pos.y = Mathf.RoundToInt(currentPlayer.transform.position.z);
}
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