2024-06-28 08:44:52 +00:00
|
|
|
|
using System.Collections;
|
|
|
|
|
using BlueWater.Items;
|
|
|
|
|
using BlueWater.Maps;
|
|
|
|
|
using Sirenix.OdinInspector;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
namespace BlueWater.Enemies.Bosses.GhostBarrel
|
|
|
|
|
{
|
|
|
|
|
public enum GhostBarrelSkill
|
|
|
|
|
{
|
|
|
|
|
None = 0,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public enum GhostBarrelSkin
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public enum GhostBarrelAnimation
|
|
|
|
|
{
|
|
|
|
|
None = 0,
|
|
|
|
|
Empty,
|
|
|
|
|
Idle,
|
|
|
|
|
In,
|
|
|
|
|
Out
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class GhostBarrel : SpineBoss
|
|
|
|
|
{
|
|
|
|
|
// Variables
|
|
|
|
|
#region Variables
|
|
|
|
|
|
|
|
|
|
public GhostBarrelData GhostBarrelData { get; private set; }
|
|
|
|
|
public GhostBarrelMapController GhostBarrelMapController { get; private set; }
|
2024-06-29 08:47:49 +00:00
|
|
|
|
|
|
|
|
|
[Title("효과")]
|
|
|
|
|
[SerializeField]
|
|
|
|
|
private float _spawnDissolveTime = 2f;
|
|
|
|
|
|
|
|
|
|
[SerializeField]
|
|
|
|
|
private float _dieDissolveTime = 1f;
|
|
|
|
|
|
|
|
|
|
// Hashes
|
|
|
|
|
private static readonly int _dissolveValueHash = Shader.PropertyToID("_DissolveValue");
|
2024-06-28 08:44:52 +00:00
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
// Unity events
|
|
|
|
|
#region Unity events
|
|
|
|
|
|
|
|
|
|
protected override void OnDestroy()
|
|
|
|
|
{
|
|
|
|
|
base.OnDestroy();
|
|
|
|
|
|
|
|
|
|
//BossHealthPoint.OnHealthChanged -= SummonMiniSandMole;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
// Initialize methods
|
|
|
|
|
#region Initialize methods
|
|
|
|
|
|
|
|
|
|
protected override void InitializeComponents()
|
|
|
|
|
{
|
|
|
|
|
base.InitializeComponents();
|
|
|
|
|
|
|
|
|
|
//SandMoleStatus = GetComponent<SandMoleStatus>();
|
|
|
|
|
GhostBarrelData = BossData as GhostBarrelData;
|
|
|
|
|
GhostBarrelMapController = MapManager.Instance.GhostBarrelMapController;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void Initialize()
|
|
|
|
|
{
|
|
|
|
|
StartCoroutine(InitializeCoroutine());
|
|
|
|
|
}
|
2024-06-29 08:47:49 +00:00
|
|
|
|
|
2024-06-28 08:44:52 +00:00
|
|
|
|
private IEnumerator InitializeCoroutine()
|
|
|
|
|
{
|
|
|
|
|
HitBoxCollider.enabled = false;
|
|
|
|
|
BossHealthPoint.Initialize(true, GhostBarrelData.MaxHealthPoint,
|
|
|
|
|
GhostBarrelData.DisplayName, GhostBarrelMapController.ParticleInstanceLocation);
|
|
|
|
|
BossSkillController.Initialize(BossData.SkillDataList);
|
|
|
|
|
SetMoveSpeed(GhostBarrelData.MoveSpeed);
|
|
|
|
|
StopMove();
|
2024-06-29 08:47:49 +00:00
|
|
|
|
|
|
|
|
|
SpineController.PlayAnimation(BoomBarrelAnimation.In.ToString(), false);
|
|
|
|
|
|
|
|
|
|
MaterialPropertyBlock.SetFloat(_dissolveValueHash, 0f);
|
|
|
|
|
MeshRenderer.SetPropertyBlock(MaterialPropertyBlock);
|
|
|
|
|
var elapsedTime = 0f;
|
|
|
|
|
while (elapsedTime <= _spawnDissolveTime)
|
|
|
|
|
{
|
|
|
|
|
if (CurrentHealthPoint == 0) yield break;
|
|
|
|
|
|
|
|
|
|
var value = Mathf.Lerp(0f, 1f, elapsedTime / _spawnDissolveTime);
|
|
|
|
|
MaterialPropertyBlock.SetFloat(_dissolveValueHash, value);
|
|
|
|
|
MeshRenderer.SetPropertyBlock(MaterialPropertyBlock);
|
|
|
|
|
elapsedTime += Time.deltaTime;
|
|
|
|
|
yield return null;
|
|
|
|
|
}
|
|
|
|
|
MaterialPropertyBlock.SetFloat(_dissolveValueHash, 1f);
|
|
|
|
|
MeshRenderer.SetPropertyBlock(MaterialPropertyBlock);
|
2024-06-28 08:44:52 +00:00
|
|
|
|
|
|
|
|
|
BehaviorTree.EnableBehavior();
|
|
|
|
|
HitBoxCollider.enabled = true;
|
|
|
|
|
}
|
|
|
|
|
|
2024-06-29 08:47:49 +00:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
// Methods
|
|
|
|
|
#region Methods
|
|
|
|
|
|
|
|
|
|
protected override void Die()
|
|
|
|
|
{
|
|
|
|
|
StartCoroutine(DieCoroutine());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private IEnumerator DieCoroutine()
|
2024-06-28 08:44:52 +00:00
|
|
|
|
{
|
|
|
|
|
BossSkillController.StopAllCoroutine();
|
|
|
|
|
BehaviorTree.DisableBehavior();
|
|
|
|
|
StopMove();
|
|
|
|
|
|
|
|
|
|
HitBoxCollider.enabled = false;
|
|
|
|
|
if (Rigidbody)
|
|
|
|
|
{
|
|
|
|
|
Rigidbody.linearVelocity = Vector3.zero;
|
|
|
|
|
Rigidbody.isKinematic = true;
|
|
|
|
|
}
|
|
|
|
|
|
2024-06-29 08:47:49 +00:00
|
|
|
|
GhostBarrelMapController.ClearMap(gameObject);
|
|
|
|
|
// TODO : 죽는 애니메이션 추가
|
2024-06-28 08:44:52 +00:00
|
|
|
|
//SpineController.SetSkin(SandMoleSkin.Idle.ToString());
|
|
|
|
|
//var dieTrack = SpineController.PlayAnimation(SandMoleAnimation.Die.ToString(), false);
|
|
|
|
|
|
|
|
|
|
//await SpineController.WaitForAnimationCompletion(dieTrack);
|
2024-06-29 08:47:49 +00:00
|
|
|
|
|
|
|
|
|
MaterialPropertyBlock.SetFloat(_dissolveValueHash, 1f);
|
|
|
|
|
MeshRenderer.SetPropertyBlock(MaterialPropertyBlock);
|
|
|
|
|
var elapsedTime = 0f;
|
|
|
|
|
while (elapsedTime <= _dieDissolveTime)
|
|
|
|
|
{
|
|
|
|
|
var value = Mathf.Lerp(1f, 0f, elapsedTime / _dieDissolveTime);
|
|
|
|
|
MaterialPropertyBlock.SetFloat(_dissolveValueHash, value);
|
|
|
|
|
MeshRenderer.SetPropertyBlock(MaterialPropertyBlock);
|
|
|
|
|
elapsedTime += Time.deltaTime;
|
|
|
|
|
yield return null;
|
|
|
|
|
}
|
|
|
|
|
MaterialPropertyBlock.SetFloat(_dissolveValueHash, 0f);
|
|
|
|
|
MeshRenderer.SetPropertyBlock(MaterialPropertyBlock);
|
|
|
|
|
|
2024-06-28 08:44:52 +00:00
|
|
|
|
Destroy(gameObject);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
}
|