OldBlueWater/BlueWater/Assets/02.Scripts/NewSkill/Rhinoceros/EarthquakeWave.cs
NTG b021b6ba6b Combat씬 보완하기
+ 우측 상단에 개발자 모드 Toggle 기능 추가
+ 전투 플레이어의 HpBar 추가
+ 전투 플레이어가 공격 시 이펙트 추가
+ 승회님 포레스트 맵에 잡몹 추가
+ 승회님 2D 나무 sorting Layer 플레이어와 동일하게 변경
+ 코뿔소 스킬마다 넉백 효과 짧고 굵게 변경
+ 코뿔소 돌진 스킬 넉백 로직 변경
+ 코뿔소 지진 스킬 이펙트 추가
+ StylizedAllEffect 에셋 추가
2024-02-19 20:40:16 +09:00

106 lines
3.7 KiB
C#

using System;
using System.Collections;
using BlueWaterProject;
using Sirenix.OdinInspector;
using UnityEngine;
// ReSharper disable once CheckNamespace
namespace RhinocerosSkill
{
public class EarthquakeWave : SkillBase
{
[Title("추가 옵션")]
[SerializeField] private bool isDrawingGizmo = true;
[SerializeField] private float width = 3f;
[SerializeField] private GameObject earthquakeParticlePrefab;
private Vector3 startPosition;
private Vector3 halfScale;
private RaycastHit[] hits;
private bool isUsingSkill;
private void OnDrawGizmos()
{
if (!isDrawingGizmo || !isUsingSkill) return;
Gizmos.color = Color.red;
Gizmos.matrix = Matrix4x4.TRS(startPosition, transform.rotation, Vector3.one);
Gizmos.DrawWireCube(Vector3.zero, halfScale * 2f);
Gizmos.matrix = Matrix4x4.identity;
}
public override void ActivateSkill(params Action[] actions)
{
ReadySkill = false;
CoolDown(Cooldown, () => ReadySkill = true);
StartCoroutine(SkillCoroutine(actions));
}
public override bool EnableSkill()
{
if (!ReadySkill) return false;
return true;
}
protected override void BasicSetting()
{
base.BasicSetting();
hits = new RaycastHit[5];
}
private IEnumerator SkillCoroutine(params Action[] actions)
{
isUsingSkill = true;
transform.position = SkillInputData.PlayerRb.position;
var angle = Mathf.Atan2(SkillInputData.PreviousDirection.x, SkillInputData.PreviousDirection.z) * Mathf.Rad2Deg;
transform.rotation = Quaternion.Euler(0, angle, 0);
transform.localScale = new Vector3(width, 6f, Range * 2);
var myLocalScale = transform.localScale;
halfScale = new Vector3(myLocalScale.x * 0.5f, myLocalScale.y * 0.5f, myLocalScale.z * 0.25f);
ShowIndicator();
var elapsedTime = 0f;
var fill = 1 / CastingTime;
while (elapsedTime < CastingTime)
{
elapsedTime += Time.deltaTime;
if (isUsingIndicator && indicator)
{
var fillValue = indicator.material.GetFloat(FillHash) + Time.deltaTime * fill;
indicator.material.SetFloat(FillHash, fillValue);
}
yield return null;
}
Instantiate(earthquakeParticlePrefab, transform.position + transform.forward * 4f, transform.rotation);
startPosition = transform.position + transform.forward * halfScale.z;
var maxSize = Physics.BoxCastNonAlloc(startPosition, halfScale, transform.forward,
hits, transform.rotation, 0f, SkillInputData.TargetLayer, QueryTriggerInteraction.Ignore);
for (var i = 0; i < maxSize; i++)
{
var iDamageable = hits[i].transform.GetComponent<IDamageable>();
iDamageable?.TakeDamage(Damage);
var iCombatable = hits[i].transform.GetComponent<ICombatable>();
if (iCombatable != null)
{
iCombatable.DisableMove(0.15f);
iCombatable.AddForceToDirection(transform.forward, 20f);
}
}
HideIndicator();
actions[0].Invoke();
isUsingSkill = false;
}
}
}