+ Title Ui 수정 + 전투 맵 이동 위치 수정 + 맵 입구 이미지 변경 + 풀잎 아이템 추가에 따른 Excel, Json, So 수정 + 타이탄 슬라임 맵에서 풀이 잘릴 때, 40% 확률로 풀잎을 드롭 + 타이탄 슬라임 젬스톤 위치 및 재질 변경 + AutoDropItem 프리팹 추가
91 lines
2.4 KiB
C#
91 lines
2.4 KiB
C#
using BlueWater.Audios;
|
|
using BlueWater.Interfaces;
|
|
using BlueWater.Items;
|
|
using Sirenix.OdinInspector;
|
|
using UnityEngine;
|
|
|
|
namespace BlueWater
|
|
{
|
|
public class DamageableProps : MonoBehaviour, IDamageable
|
|
{
|
|
[Title("드롭 아이템")]
|
|
[SerializeField]
|
|
protected int CharacterIdx;
|
|
|
|
[field: Title("체력")]
|
|
[field: SerializeField]
|
|
public int MaxHealthPoint { get; private set; } = 1;
|
|
|
|
[field: SerializeField]
|
|
public int CurrentHealthPoint { get; private set; }
|
|
|
|
public bool IsInvincible { get; private set; }
|
|
|
|
[field: SerializeField]
|
|
public float InvincibilityDuration { get; private set; }
|
|
|
|
[Title("Die 설정")]
|
|
[SerializeField]
|
|
protected string DieSfxName;
|
|
|
|
[SerializeField]
|
|
protected ParticleSystem DieParticle;
|
|
|
|
protected Transform SpawnLocation;
|
|
|
|
protected virtual void OnEnable()
|
|
{
|
|
SetCurrentHealthPoint(MaxHealthPoint);
|
|
}
|
|
|
|
public virtual void SetCurrentHealthPoint(int changedHealthPoint)
|
|
{
|
|
CurrentHealthPoint = changedHealthPoint;
|
|
}
|
|
|
|
public virtual bool CanDamage()
|
|
{
|
|
return CurrentHealthPoint > 0;
|
|
}
|
|
|
|
public virtual void TakeDamage(int damageAmount)
|
|
{
|
|
var changeHp = Mathf.Max(CurrentHealthPoint - damageAmount, 0);
|
|
SetCurrentHealthPoint(changeHp);
|
|
|
|
if (changeHp == 0f)
|
|
{
|
|
Die();
|
|
return;
|
|
}
|
|
}
|
|
|
|
public virtual void TryTakeDamage(int damageAmount)
|
|
{
|
|
if (!CanDamage()) return;
|
|
|
|
TakeDamage(damageAmount);
|
|
}
|
|
|
|
public virtual void Die()
|
|
{
|
|
if (!string.IsNullOrEmpty(DieSfxName))
|
|
{
|
|
AudioManager.Instance.PlaySfx(DieSfxName);
|
|
}
|
|
|
|
if (DieParticle && SpawnLocation)
|
|
{
|
|
var dieParticleInstance = Instantiate(DieParticle, transform.position, DieParticle.transform.rotation, SpawnLocation);
|
|
dieParticleInstance.Play();
|
|
}
|
|
|
|
if (CharacterIdx != 0)
|
|
{
|
|
ItemManager.Instance.ItemDropRandomPosition(CharacterIdx, transform.position, 0f);
|
|
}
|
|
|
|
Destroy(gameObject);
|
|
}
|
|
}
|
|
} |