OldBlueWater/BlueWater/Assets/02.Scripts/BossPortal.cs
NTG_Lenovo 8069748e49 맵 크기 변경
+ 스킬 구조 변경
+ 공격시 히트스톱 추가
+ Lava 추가 중
2023-11-29 15:13:25 +09:00

77 lines
2.2 KiB
C#

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<Collider>();
var bossEntrance = transform.Find("BossEntrance");
if (!bossEntrance)
{
print("BossEntrance 오브젝트가 null입니다.");
}
else
{
bossEntrances = bossEntrance.GetComponentsInChildren<Collider>();
}
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;
}
}
}