+ Item관련 Excel, Json, So 수정 + DropItemTable 로직 수정 + 아이템 프리팹에서 Enable Interaction 체크하면 직접 룻팅, 해제하면 자동 룻팅 + 체력회복 아이템 추가 + 개발자 메뉴 상호작용 "F1" 키를 통해 접근 가능 + 보스 맵은 마법진을 상호작용하면 보스전 시작 + 맵 안에서 교전 중일 때, 투명 벽 쉐이더 추가 + 맵 마다의 통로를 통해서 이동 가능 + 선형적인 맵 구조에 맞게 리소스 및 위치 수정 + 타이틀 화면으로 이동할 때 나타나는 오류 수정(CombatUiManager OnDisable 싱글톤 문제) Closes #25, #26
172 lines
4.8 KiB
C#
172 lines
4.8 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using BlueWater.Interfaces;
|
|
using BlueWater.Items;
|
|
using BlueWater.Maps;
|
|
using Sirenix.OdinInspector;
|
|
using UnityEngine;
|
|
|
|
namespace BlueWater.Enemies.Bosses.SandMole
|
|
{
|
|
public enum SandMoleSkill
|
|
{
|
|
None = 0,
|
|
GateOfSpikes,
|
|
MultiThrowSpikes,
|
|
SingleRoll,
|
|
SpikeBarrage
|
|
}
|
|
|
|
[Serializable]
|
|
public class SummonMiniSandMole
|
|
{
|
|
[field: SerializeField]
|
|
public float HealthPercentage { get; private set; }
|
|
|
|
[field: SerializeField]
|
|
public bool SummonTrigger { get; set; }
|
|
}
|
|
|
|
public class SandMole : Boss, ICurrentDirection
|
|
{
|
|
// Variables
|
|
#region Variables
|
|
|
|
[field: SerializeField, Required]
|
|
public SandMoleStatus SandMoleStatus { get; private set; }
|
|
|
|
[SerializeField]
|
|
private List<SummonMiniSandMole> _summonMiniSandMoles;
|
|
|
|
public SandMoleData SandMoleData { get; private set; }
|
|
public SandMoleMapController SandMoleMapController { 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();
|
|
}
|
|
|
|
protected override void OnDestroy()
|
|
{
|
|
base.OnDestroy();
|
|
|
|
BossHealthPoint.OnHealthChanged -= SummonMiniSandMole;
|
|
}
|
|
|
|
#endregion
|
|
|
|
// Initialize methods
|
|
#region Initialize methods
|
|
|
|
protected override void InitializeComponents()
|
|
{
|
|
base.InitializeComponents();
|
|
|
|
SandMoleStatus = GetComponent<SandMoleStatus>();
|
|
SandMoleData = BossData as SandMoleData;
|
|
SandMoleMapController = MapManager.Instance.SandMoleMapController;
|
|
}
|
|
|
|
public override void Initialize()
|
|
{
|
|
BossHealthPoint.Initialize(true, SandMoleData.MaxHealthPoint,
|
|
SandMoleData.DisplayName, SandMoleMapController.ParticleInstanceLocation);
|
|
BossHealthPoint.OnHealthChanged += SummonMiniSandMole;
|
|
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");
|
|
ItemManager.Instance.ItemDropRandomPosition(BossData.CharacterIdx, transform.position);
|
|
SandMoleMapController.ClearMap();
|
|
}
|
|
|
|
private void SummonMiniSandMole(int currentHp)
|
|
{
|
|
var currentHealthPercentage = (float)currentHp / BossData.MaxHealthPoint * 100f;
|
|
|
|
foreach (var element in _summonMiniSandMoles)
|
|
{
|
|
if (currentHealthPercentage > element.HealthPercentage || element.SummonTrigger) continue;
|
|
|
|
SandMoleMapController.SummonMiniSandMole();
|
|
element.SummonTrigger = true;
|
|
}
|
|
}
|
|
|
|
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
|
|
}
|
|
} |