2024-01-28 15:46:56 +00:00
|
|
|
using System;
|
|
|
|
using System.Collections;
|
|
|
|
using Sirenix.OdinInspector;
|
2024-01-24 00:48:26 +00:00
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
// ReSharper disable once CheckNamespace
|
|
|
|
namespace BlueWaterProject
|
|
|
|
{
|
2024-01-28 15:46:56 +00:00
|
|
|
[Serializable]
|
|
|
|
public class SkillInputData
|
2024-01-24 00:48:26 +00:00
|
|
|
{
|
2024-01-28 15:46:56 +00:00
|
|
|
[Title("초기화 데이터")]
|
|
|
|
public Collider playerCollider;
|
|
|
|
public Rigidbody playerRb;
|
|
|
|
public Transform playerVisualLook;
|
|
|
|
public LayerMask targetLayer;
|
|
|
|
public SkillUi skillUi;
|
2024-01-24 00:48:26 +00:00
|
|
|
|
2024-01-28 15:46:56 +00:00
|
|
|
[Title("실시간 데이터")]
|
|
|
|
public Vector3 startPosition;
|
2024-01-24 00:48:26 +00:00
|
|
|
|
2024-01-28 15:46:56 +00:00
|
|
|
public void InitInputData(Collider collider, Rigidbody rb, Transform visualLook, LayerMask target, SkillUi ui)
|
|
|
|
{
|
|
|
|
playerCollider = collider;
|
|
|
|
playerRb = rb;
|
|
|
|
playerVisualLook = visualLook;
|
|
|
|
targetLayer = target;
|
|
|
|
skillUi = ui;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void UpdateInputData(Vector3 start)
|
|
|
|
{
|
|
|
|
startPosition = start;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public abstract class SkillBase : MonoBehaviour, ISkill
|
|
|
|
{
|
|
|
|
[Title("기본 설정")]
|
|
|
|
public string skillName;
|
|
|
|
public bool enableSkill = true;
|
|
|
|
public float damage;
|
|
|
|
public float cooldown;
|
|
|
|
public float range;
|
|
|
|
public float castingTime;
|
|
|
|
public float skillDuration;
|
|
|
|
|
|
|
|
[field: DisableIf("@true")]
|
|
|
|
[field: SerializeField] public SkillInputData SkillInputData { get; set; }
|
|
|
|
|
2024-01-28 18:16:35 +00:00
|
|
|
protected Transform instantiateLocation;
|
|
|
|
|
2024-01-28 15:46:56 +00:00
|
|
|
public abstract void ActivateSkill();
|
|
|
|
|
|
|
|
public virtual bool EnableSkill() => enableSkill;
|
2024-01-28 18:16:35 +00:00
|
|
|
public virtual void InitData()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
private void Start()
|
|
|
|
{
|
|
|
|
var instantiateObjects = GameObject.Find("InstantiateObjects").transform;
|
|
|
|
if (!instantiateObjects)
|
|
|
|
{
|
|
|
|
instantiateObjects = new GameObject("InstantiateObjects").transform;
|
|
|
|
}
|
|
|
|
|
|
|
|
instantiateLocation = instantiateObjects.Find("Particles");
|
|
|
|
if (!instantiateLocation)
|
|
|
|
{
|
|
|
|
instantiateLocation = new GameObject("Particles").transform;
|
|
|
|
instantiateLocation.SetParent(instantiateObjects);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-01-28 15:46:56 +00:00
|
|
|
public void CoolDown(float waitTime, Action onCooldownComplete = null)
|
|
|
|
{
|
|
|
|
StartCoroutine(CoolDownCoroutine(waitTime, onCooldownComplete));
|
|
|
|
}
|
|
|
|
|
|
|
|
private IEnumerator CoolDownCoroutine(float waitTime, Action onCooldownComplete = null)
|
|
|
|
{
|
|
|
|
var time = 0f;
|
|
|
|
|
|
|
|
while (time <= waitTime)
|
|
|
|
{
|
|
|
|
time += Time.deltaTime;
|
|
|
|
yield return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
onCooldownComplete?.Invoke();
|
|
|
|
}
|
2024-01-24 00:48:26 +00:00
|
|
|
}
|
|
|
|
}
|