using System; using Doozy.Editor.EditorUI.Components; using UnityEngine; // ReSharper disable once CheckNamespace namespace BlueWaterProject { public class BossPortal : MonoBehaviour { [SerializeField] private GameObject playerSpawnPosObj; [SerializeField] private FieldBoss fieldBoss; private Collider myCollider; private float[] bossMapVertices; private Collider[] bossEntrances; private bool isIn; private void Awake() { myCollider = GetComponent(); var bossEntrance = transform.Find("BossEntrance"); if (!bossEntrance) { print("BossEntrance 오브젝트가 null입니다."); } else { bossEntrances = bossEntrance.GetComponentsInChildren(); } GetColliderVertices(myCollider); BossEntranceSetActive(false); } private void OnTriggerEnter(Collider other) { if (isIn || !other.CompareTag("InIslandPlayer")) return; // TODO : 보스 맵 입장 isIn = true; other.transform.position = playerSpawnPosObj.transform.position; BossEntranceSetActive(true); fieldBoss.BossSpawn(other, bossMapVertices); } private void BossEntranceSetActive(bool value) { foreach (var entrance in bossEntrances) { entrance.gameObject.SetActive(value); } } private void BossReset() { fieldBoss.gameObject.SetActive(false); BossEntranceSetActive(false); isIn = false; } private void GetColliderVertices(Collider col) { var bounds = col.bounds; var center = bounds.center; var size = bounds.size; bossMapVertices = new float[4]; bossMapVertices[0] = center.x + -size.x * 0.5f; bossMapVertices[1] = center.x + size.x * 0.5f; bossMapVertices[2] = center.z + size.z * 0.5f; bossMapVertices[3] = center.z + -size.z * 0.5f; } } }