OldBlueWater/BlueWater/Assets/02.Scripts/BossPortal.cs
2023-11-22 16:20:22 +09:00

60 lines
1.5 KiB
C#

using System;
using UnityEngine;
// ReSharper disable once CheckNamespace
namespace BlueWaterProject
{
public class BossPortal : MonoBehaviour
{
[SerializeField] private GameObject playerSpawnPosObj;
[SerializeField] private FieldBoss fieldBoss;
private Collider[] bossEntrances;
private bool isIn;
private void Awake()
{
var bossEntrance = transform.Find("BossEntrance");
if (!bossEntrance)
{
print("BossEntrance 오브젝트가 null입니다.");
}
else
{
bossEntrances = bossEntrance.GetComponentsInChildren<Collider>();
}
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);
fieldBoss.Target = other;
}
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;
}
}
}