2023-11-22 07:20:22 +00:00
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
// ReSharper disable once CheckNamespace
|
|
|
|
namespace BlueWaterProject
|
|
|
|
{
|
|
|
|
public class BossPortal : MonoBehaviour
|
|
|
|
{
|
|
|
|
[SerializeField] private GameObject playerSpawnPosObj;
|
2024-02-12 20:50:24 +00:00
|
|
|
[SerializeField] private BossController bossController;
|
|
|
|
[SerializeField] private Collider[] bossEntranceObstacles;
|
2023-11-22 07:20:22 +00:00
|
|
|
|
|
|
|
private bool isIn;
|
|
|
|
|
2024-02-12 20:50:24 +00:00
|
|
|
private void Start()
|
2023-11-22 07:20:22 +00:00
|
|
|
{
|
|
|
|
BossEntranceSetActive(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
private void OnTriggerEnter(Collider other)
|
|
|
|
{
|
2024-02-12 20:50:24 +00:00
|
|
|
if (isIn || !other.CompareTag("CombatPlayer")) return;
|
2023-11-22 07:20:22 +00:00
|
|
|
|
|
|
|
isIn = true;
|
2024-02-12 20:50:24 +00:00
|
|
|
if (playerSpawnPosObj)
|
|
|
|
{
|
|
|
|
other.transform.position = playerSpawnPosObj.transform.position;
|
|
|
|
}
|
2023-11-22 07:20:22 +00:00
|
|
|
BossEntranceSetActive(true);
|
2024-02-12 20:50:24 +00:00
|
|
|
bossController.Respawn();
|
2023-11-22 07:20:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private void BossEntranceSetActive(bool value)
|
|
|
|
{
|
2024-02-12 20:50:24 +00:00
|
|
|
foreach (var entrance in bossEntranceObstacles)
|
2023-11-22 07:20:22 +00:00
|
|
|
{
|
|
|
|
entrance.gameObject.SetActive(value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-02-12 20:50:24 +00:00
|
|
|
public void ResetPortal()
|
2023-11-22 07:20:22 +00:00
|
|
|
{
|
|
|
|
isIn = false;
|
2024-02-12 20:50:24 +00:00
|
|
|
BossEntranceSetActive(false);
|
|
|
|
bossController.ResetBoss();
|
2023-11-29 06:13:25 +00:00
|
|
|
}
|
2023-11-22 07:20:22 +00:00
|
|
|
}
|
|
|
|
}
|