+ Item관련 Excel, Json, So 수정 + DropItemTable 로직 수정 + 아이템 프리팹에서 Enable Interaction 체크하면 직접 룻팅, 해제하면 자동 룻팅 + 체력회복 아이템 추가 + 개발자 메뉴 상호작용 "F1" 키를 통해 접근 가능 + 보스 맵은 마법진을 상호작용하면 보스전 시작 + 맵 안에서 교전 중일 때, 투명 벽 쉐이더 추가 + 맵 마다의 통로를 통해서 이동 가능 + 선형적인 맵 구조에 맞게 리소스 및 위치 수정 + 타이틀 화면으로 이동할 때 나타나는 오류 수정(CombatUiManager OnDisable 싱글톤 문제) Closes #25, #26
148 lines
4.7 KiB
C#
148 lines
4.7 KiB
C#
using System.Collections;
|
|
using BlueWater.Audios;
|
|
using BlueWater.Interfaces;
|
|
using BlueWater.Maps;
|
|
using Sirenix.OdinInspector;
|
|
using UnityEngine;
|
|
using UnityEngine.Rendering.Universal;
|
|
|
|
namespace BlueWater
|
|
{
|
|
public class Rockfall : DamageableProps
|
|
{
|
|
[Title("컴포넌트")]
|
|
[SerializeField, Required]
|
|
private SphereCollider _sphereCollider;
|
|
|
|
[SerializeField]
|
|
private DecalProjector _indicator;
|
|
|
|
[Title("표시기 설정")]
|
|
[SerializeField]
|
|
private bool _isUsingIndicator = true;
|
|
|
|
[Title("충돌 설정")]
|
|
[SerializeField]
|
|
private LayerMask _targetLayer;
|
|
|
|
[SerializeField]
|
|
private LayerMask _groundLayer;
|
|
|
|
[SerializeField, Range(0f, 5f)]
|
|
private float _fallTime = 1f;
|
|
|
|
[SerializeField, Range(0, 5)]
|
|
private int _attackDamage = 1;
|
|
|
|
[Title("Ground Crash 설정")]
|
|
[SerializeField]
|
|
private string _groundCrashSfxName;
|
|
|
|
[SerializeField]
|
|
private ParticleSystem _groundCrashParticle;
|
|
|
|
private Collider[] _hitColliders;
|
|
private RaycastHit _raycastHit;
|
|
private Vector3 _startPosition;
|
|
private Vector3 _endPosition;
|
|
private bool _isAttacked;
|
|
|
|
// Hashes
|
|
private static readonly int _fillHash = Shader.PropertyToID("_Fill");
|
|
|
|
private IEnumerator Start()
|
|
{
|
|
_sphereCollider.enabled = false;
|
|
_startPosition = transform.position;
|
|
SpawnLocation = MapManager.Instance.SandMoleMapController.ParticleInstanceLocation;
|
|
_hitColliders = new Collider[4];
|
|
BasicSetting();
|
|
|
|
if (!Physics.Raycast(transform.position, Vector3.down, out _raycastHit, 50f, _groundLayer))
|
|
{
|
|
Debug.LogError("땅을 감지하지 못하는 버그");
|
|
yield break;
|
|
}
|
|
_endPosition = _raycastHit.point;
|
|
|
|
ShowIndicator();
|
|
var elapsedTime = 0f;
|
|
while (elapsedTime <= _fallTime)
|
|
{
|
|
var time = elapsedTime / _fallTime;
|
|
if (_isUsingIndicator && _indicator)
|
|
{
|
|
var fillValue = Mathf.Lerp(0f, 1f, time);
|
|
_indicator.material.SetFloat(_fillHash, fillValue);
|
|
}
|
|
transform.position = Vector3.Lerp(_startPosition, _endPosition, time);
|
|
elapsedTime += Time.deltaTime;
|
|
|
|
yield return null;
|
|
}
|
|
|
|
_indicator.material.SetFloat(_fillHash, 1f);
|
|
HideIndicator();
|
|
|
|
if (!string.IsNullOrEmpty(_groundCrashSfxName))
|
|
{
|
|
AudioManager.Instance.PlaySfx(_groundCrashSfxName);
|
|
}
|
|
|
|
if (_groundCrashParticle)
|
|
{
|
|
if (!SpawnLocation)
|
|
{
|
|
Debug.LogError("파티클 위치 생성 오류");
|
|
yield break;
|
|
}
|
|
Instantiate(_groundCrashParticle, transform.position, Quaternion.identity, SpawnLocation);
|
|
}
|
|
|
|
var hitCount = Physics.OverlapSphereNonAlloc(_sphereCollider.bounds.center, _sphereCollider.radius,
|
|
_hitColliders, _targetLayer, QueryTriggerInteraction.Collide);
|
|
for (var i = 0; i < hitCount; i++)
|
|
{
|
|
var hitCollider = _hitColliders[i];
|
|
var iDamageable = hitCollider.GetComponentInParent<IDamageable>();
|
|
if (iDamageable == null || !iDamageable.CanDamage()) continue;
|
|
|
|
iDamageable.TakeDamage(_attackDamage);
|
|
_isAttacked = true;
|
|
}
|
|
|
|
if (_isAttacked)
|
|
{
|
|
Die();
|
|
yield break;
|
|
}
|
|
|
|
_sphereCollider.enabled = true;
|
|
}
|
|
|
|
private void BasicSetting()
|
|
{
|
|
if (!_isUsingIndicator || !_indicator) return;
|
|
|
|
_indicator.scaleMode = DecalScaleMode.InheritFromHierarchy;
|
|
_indicator.material = new Material(_indicator.material);
|
|
_indicator.material.SetFloat(_fillHash, 0f);
|
|
}
|
|
|
|
private void HideIndicator()
|
|
{
|
|
if (!_isUsingIndicator || !_indicator) return;
|
|
|
|
_indicator.enabled = false;
|
|
_indicator.material.SetFloat(_fillHash, 0);
|
|
}
|
|
|
|
private void ShowIndicator()
|
|
{
|
|
if (!_isUsingIndicator || !_indicator) return;
|
|
|
|
_indicator.material.SetFloat(_fillHash, 0);
|
|
_indicator.enabled = true;
|
|
}
|
|
}
|
|
} |