57 lines
1.9 KiB
C#
57 lines
1.9 KiB
C#
using System.Collections.Generic;
|
|
using BlueWaterProject;
|
|
using Sirenix.OdinInspector;
|
|
using UnityEngine;
|
|
|
|
// ReSharper disable once CheckNamespace
|
|
public class SlimeBossMapController : MonoBehaviour
|
|
{
|
|
// 컴포넌트
|
|
[Title("컴포넌트")]
|
|
[SerializeField] private Transform playerSpawnTransform;
|
|
[SerializeField] private Transform bossSpawnTransform;
|
|
[SerializeField] private Transform bossInstantiateTransform;
|
|
[SerializeField] private TitanSlime bossPrefab;
|
|
[SerializeField] private List<SlimeState> slimeStateList = new(5);
|
|
|
|
private List<GameObject> bossInstanceList = new(10);
|
|
|
|
public void InitBossMap()
|
|
{
|
|
AllDestroyInstantiateObject();
|
|
bossInstanceList = new List<GameObject>(10);
|
|
|
|
var player = GameObject.FindWithTag("CombatPlayer");
|
|
if (player && playerSpawnTransform)
|
|
{
|
|
player.transform.position = playerSpawnTransform.position;
|
|
}
|
|
|
|
InstantiateSlime(bossSpawnTransform.position, 1, true);
|
|
}
|
|
|
|
private void InstantiateSlime(Vector3 instantiatePosition, int level, bool hasRabbit)
|
|
{
|
|
var instantiateBoss = Instantiate(bossPrefab, instantiatePosition, Quaternion.identity, bossInstantiateTransform);
|
|
var slimeState = slimeStateList.Find((list) => list.Level == level);
|
|
instantiateBoss.Init(slimeState, hasRabbit);
|
|
|
|
UiManager.Inst.CombatUi.FieldBossHpSlider.SetHpSlider(instantiateBoss.MaxHp, instantiateBoss.BossName);
|
|
|
|
bossInstanceList.Add(instantiateBoss.gameObject);
|
|
}
|
|
|
|
public void SpawnSplitSlimes(Vector3 deathPosition, int nextLevel, bool hasRabbit)
|
|
{
|
|
InstantiateSlime(deathPosition, nextLevel, hasRabbit);
|
|
InstantiateSlime(deathPosition, nextLevel, false);
|
|
}
|
|
|
|
public void AllDestroyInstantiateObject()
|
|
{
|
|
foreach (var element in bossInstanceList)
|
|
{
|
|
Destroy(element);
|
|
}
|
|
}
|
|
} |