ludumdare50/Assets/Scripts/SafeZone.cs

26 lines
687 B
C#

using UnityEngine;
public class SafeZone : MonoBehaviour {
public SafeZoneStats stats;
[SerializeField] CircleCollider2D moatCollider;
public bool IsInSafeZone { get; private set; } = true;
void Awake() {
if (moatCollider.enabled)
Debug.LogWarning("Moat collider was enabled on start, shouldn't be if the player starts in the safe zone.");
}
public void EnterSafeZone() {
moatCollider.enabled = false;
IsInSafeZone = true;
}
public void ExitSafeZone() {
moatCollider.enabled = true;
IsInSafeZone = false;
}
public Vector3 GetOutsidePosition(Vector2 direction) {
return transform.position + (moatCollider.radius + stats.JumpOffset) * (Vector3)direction;
}
}