124 lines
3.3 KiB
C#
124 lines
3.3 KiB
C#
|
using BlueWater.Maps;
|
|||
|
using UnityEngine;
|
|||
|
|
|||
|
namespace BlueWater.Enemies.Bosses.SandMole
|
|||
|
{
|
|||
|
public enum SandMoleSkill
|
|||
|
{
|
|||
|
None = 0,
|
|||
|
}
|
|||
|
|
|||
|
public class Rhinoceros : Boss
|
|||
|
{
|
|||
|
// Variables
|
|||
|
#region Variables
|
|||
|
|
|||
|
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();
|
|||
|
|
|||
|
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
|
|||
|
}
|
|||
|
}
|