+ GhostBarrel 오브젝트 추가 + OpaqueLit 재질에서 Receive Shadow를 받고 안받는 재질을 구분 + 코뿔소 맵에 Maple Leaf 파티클 추가 + 얼음두지 맵에 Bgm Missing 오류 수정 + 얼음두지 피격 파티클, Spike Die 파티클 추가
168 lines
4.7 KiB
C#
168 lines
4.7 KiB
C#
using System.Collections.Generic;
|
|
using BlueWater.Audios;
|
|
using BlueWater.Enemies.Bosses;
|
|
using BlueWater.Uis;
|
|
using Sirenix.OdinInspector;
|
|
using UnityEngine;
|
|
|
|
namespace BlueWater.Maps
|
|
{
|
|
public abstract class MapController : MonoBehaviour
|
|
{
|
|
/// 컴포넌트
|
|
[Title("컴포넌트")]
|
|
[SerializeField, Required]
|
|
protected Transform PlayerSpawnLocation;
|
|
|
|
[field: SerializeField, Required]
|
|
public Transform EnemyInstanceLocation { get; private set; }
|
|
|
|
[field: SerializeField]
|
|
public Transform ParticleInstanceLocation { get; private set; }
|
|
|
|
[SerializeField]
|
|
protected Transform MapEntranceLocations;
|
|
|
|
[SerializeField]
|
|
protected List<MapEntrance> MapEntrances;
|
|
|
|
[SerializeField]
|
|
protected SaveStage SaveStage;
|
|
|
|
[SerializeField]
|
|
protected string BgmName;
|
|
|
|
[SerializeField]
|
|
protected Vector2 InitializeFadeInOutTime = new(0.2f, 1f);
|
|
|
|
[SerializeField]
|
|
protected Vector2 ClearFadeInOutTime = new(0.2f, 0.3f);
|
|
|
|
protected Coroutine MapInitializeCoroutineInstance;
|
|
protected static bool IsCleared;
|
|
private bool _isQuitting;
|
|
|
|
private void Awake()
|
|
{
|
|
InitializeComponents();
|
|
}
|
|
|
|
protected virtual void Start()
|
|
{
|
|
foreach (var element in MapEntrances)
|
|
{
|
|
element.OpenMapEntrance();
|
|
}
|
|
}
|
|
|
|
protected virtual void OnApplicationQuit()
|
|
{
|
|
_isQuitting = true;
|
|
}
|
|
|
|
protected virtual void OnDestroy()
|
|
{
|
|
if (_isQuitting) return;
|
|
}
|
|
|
|
[Button("컴포넌트 초기화")]
|
|
protected virtual void InitializeComponents()
|
|
{
|
|
PlayerSpawnLocation = transform.Find("Spawns/PlayerSpawn");
|
|
EnemyInstanceLocation = transform.Find("Enemies");
|
|
ParticleInstanceLocation = transform.Find("InstantiateObjects");
|
|
MapEntranceLocations = transform.Find("MapEntrances");
|
|
|
|
//var entrancesArray = MapEntranceLocations.GetComponentsInChildren<MapEntrance>();
|
|
//MapEntrances = new List<MapEntrance>(entrancesArray.Length);
|
|
//MapEntrances.AddRange(entrancesArray);
|
|
}
|
|
|
|
public abstract void InitializeMap();
|
|
|
|
public void OpenMapEntrances()
|
|
{
|
|
foreach (var element in MapEntrances)
|
|
{
|
|
element.OpenMapEntrance();
|
|
}
|
|
}
|
|
|
|
public void CloseMapEntrances()
|
|
{
|
|
foreach (var element in MapEntrances)
|
|
{
|
|
element.CloseMapEntrance();
|
|
}
|
|
}
|
|
|
|
public void DestroyAllEnemies()
|
|
{
|
|
var temps = new List<Transform>();
|
|
foreach (Transform element in EnemyInstanceLocation)
|
|
{
|
|
temps.Add(element);
|
|
}
|
|
|
|
foreach (var element in temps)
|
|
{
|
|
Destroy(element.gameObject);
|
|
}
|
|
}
|
|
|
|
public void DestroyAllEnemiesExceptBoss(GameObject bossObject)
|
|
{
|
|
foreach (Transform element in EnemyInstanceLocation)
|
|
{
|
|
if (element.gameObject == bossObject) continue;
|
|
|
|
Destroy(element.gameObject);
|
|
}
|
|
}
|
|
|
|
public void DestroyAllObjects()
|
|
{
|
|
DestroyAllEnemies();
|
|
|
|
var temps = new List<Transform>();
|
|
foreach (Transform element in ParticleInstanceLocation)
|
|
{
|
|
temps.Add(element);
|
|
}
|
|
|
|
foreach (Transform element in temps)
|
|
{
|
|
Destroy(element.gameObject);
|
|
}
|
|
}
|
|
|
|
public void ForceKillBoss()
|
|
{
|
|
var temps = new List<Transform>();
|
|
foreach (Transform element in EnemyInstanceLocation)
|
|
{
|
|
temps.Add(element);
|
|
}
|
|
|
|
foreach (Transform element in temps)
|
|
{
|
|
var boss = element.GetComponent<Boss>();
|
|
if (!boss) continue;
|
|
|
|
boss.ForceKillBoss();
|
|
}
|
|
}
|
|
|
|
public void MovePlayer()
|
|
{
|
|
if (!GameManager.Instance.CurrentCombatPlayer) return;
|
|
|
|
GameManager.Instance.CurrentCombatPlayer.transform.position = PlayerSpawnLocation.position;
|
|
CombatUiManager.Instance.FieldBossHealthPointUi.SetActiveHpSlider(false);
|
|
}
|
|
|
|
public abstract void ResetMap(bool isHardReset = false);
|
|
public abstract void RestartMap();
|
|
public abstract void ClearMap(GameObject bossObject);
|
|
}
|
|
} |