2024-06-13 16:46:37 +00:00
|
|
|
|
using BlueWater.Maps;
|
2024-06-15 01:20:43 +00:00
|
|
|
|
using Sirenix.OdinInspector;
|
2024-06-13 16:46:37 +00:00
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
namespace BlueWater.Enemies.Bosses.SandMole
|
|
|
|
|
{
|
|
|
|
|
public enum SandMoleSkill
|
|
|
|
|
{
|
|
|
|
|
None = 0,
|
2024-06-14 20:36:32 +00:00
|
|
|
|
GateOfSpikes,
|
|
|
|
|
MultiThrowSpikes,
|
2024-06-14 09:11:35 +00:00
|
|
|
|
SingleRoll,
|
|
|
|
|
SummonMiniSandMole
|
2024-06-13 16:46:37 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-06-14 09:11:35 +00:00
|
|
|
|
public class SandMole : Boss
|
2024-06-13 16:46:37 +00:00
|
|
|
|
{
|
|
|
|
|
// Variables
|
|
|
|
|
#region Variables
|
|
|
|
|
|
2024-06-15 01:20:43 +00:00
|
|
|
|
[field: SerializeField, Required]
|
|
|
|
|
public SandMoleStatus SandMoleStatus { get; private set; }
|
2024-06-13 16:46:37 +00:00
|
|
|
|
public SandMoleData SandMoleData { get; private set; }
|
|
|
|
|
public BossMapController BossMapController { get; private set; }
|
|
|
|
|
|
|
|
|
|
private bool _isMoving;
|
|
|
|
|
public bool IsMoving
|
|
|
|
|
{
|
|
|
|
|
get => _isMoving;
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
_isMoving = value;
|
|
|
|
|
AnimationController.SetAnimationParameter("isMoving", _isMoving);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private Vector3 _currentDirection = Vector3.right;
|
|
|
|
|
public Vector3 CurrentDirection
|
|
|
|
|
{
|
|
|
|
|
get => _currentDirection;
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (value == Vector3.zero) return;
|
|
|
|
|
|
|
|
|
|
_currentDirection = value;
|
|
|
|
|
AnimationController.SetAnimationParameter("xDirection", _currentDirection.x);
|
|
|
|
|
AnimationController.SetAnimationParameter("zDirection", _currentDirection.z);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
// Unity events
|
|
|
|
|
#region Unity events
|
|
|
|
|
|
|
|
|
|
protected override void Update()
|
|
|
|
|
{
|
|
|
|
|
base.Update();
|
|
|
|
|
|
|
|
|
|
HandleMovement();
|
|
|
|
|
FlipVisualLook();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
// Initialize methods
|
|
|
|
|
#region Initialize methods
|
|
|
|
|
|
|
|
|
|
protected override void InitializeComponents()
|
|
|
|
|
{
|
|
|
|
|
base.InitializeComponents();
|
2024-06-15 01:20:43 +00:00
|
|
|
|
|
|
|
|
|
SandMoleStatus = GetComponent<SandMoleStatus>();
|
2024-06-13 16:46:37 +00:00
|
|
|
|
SandMoleData = BossData as SandMoleData;
|
|
|
|
|
BossMapController = MapManager.Instance.SandMoleMapController;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void Initialize()
|
|
|
|
|
{
|
|
|
|
|
BossHealthPoint.InitializeComponents(true, CharacterCollider, SpriteRenderer, SandMoleData.MaxHealthPoint,
|
|
|
|
|
SandMoleData.DisplayName, BossMapController.ParticleInstantiateLocation);
|
|
|
|
|
BossSkillController.Initialize(BossData.SkillDataList);
|
|
|
|
|
SetMoveSpeed(SandMoleData.MoveSpeed);
|
|
|
|
|
StopMove();
|
|
|
|
|
BehaviorTree.EnableBehavior();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
// Methods
|
|
|
|
|
#region Methods
|
|
|
|
|
|
|
|
|
|
protected override void HandleDie()
|
|
|
|
|
{
|
|
|
|
|
StopMove();
|
|
|
|
|
|
|
|
|
|
if (Rigidbody)
|
|
|
|
|
{
|
|
|
|
|
Rigidbody.isKinematic = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
AnimationController.SetAnimationTrigger("isDead");
|
|
|
|
|
BossMapController.MapClear();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void FlipVisualLook()
|
|
|
|
|
{
|
|
|
|
|
var localScale = VisualLook.localScale;
|
|
|
|
|
localScale.x = CurrentDirection.x switch
|
|
|
|
|
{
|
|
|
|
|
> 0.01f => Mathf.Abs(localScale.x),
|
|
|
|
|
< -0.01f => -Mathf.Abs(localScale.x),
|
|
|
|
|
_ => localScale.x
|
|
|
|
|
};
|
|
|
|
|
VisualLook.localScale = localScale;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void HandleMovement()
|
|
|
|
|
{
|
|
|
|
|
if (!IAstarAi.canMove || IAstarAi.isStopped)
|
|
|
|
|
{
|
|
|
|
|
IsMoving = false;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CurrentDirection = IAstarAi.velocity.normalized;
|
|
|
|
|
IsMoving = IAstarAi.velocity != Vector3.zero || IAstarAi.velocity != Vector3.positiveInfinity;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
}
|