ZoneManager.cs 897 B

12345678910111213141516171819202122232425262728293031323334353637
  1. using UnityEngine;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. public class ZoneManager : MonoBehaviour
  5. {
  6. public List<Collider> allowedZones;
  7. public bool IsPositionAllowed(Vector3 position)
  8. {
  9. foreach (var zone in allowedZones)
  10. {
  11. if (zone.bounds.Contains(position))
  12. {
  13. return true;
  14. }
  15. }
  16. return false;
  17. }
  18. private void OnDrawGizmos()
  19. {
  20. Gizmos.color = Color.yellow;
  21. int gridSize = 10;
  22. float cellSize = 1f;
  23. for (int x = 0; x <= gridSize; x++)
  24. {
  25. Gizmos.DrawLine(new Vector3(x * cellSize, 0, 0), new Vector3(x * cellSize, 0, gridSize * cellSize));
  26. }
  27. for (int z = 0; z <= gridSize; z++)
  28. {
  29. Gizmos.DrawLine(new Vector3(0, 0, z * cellSize), new Vector3(gridSize * cellSize, 0, z * cellSize));
  30. }
  31. }
  32. }