플레이어 대쉬 중 캐릭터 흔들림 효과 수정

This commit is contained in:
Nam Tae Gun 2024-06-28 14:09:12 +09:00
parent 2e0e105acf
commit bda0688660
2 changed files with 131 additions and 33 deletions

View File

@ -1,7 +1,9 @@
using System;
using System.Collections;
using BlueWater.Audios;
using BlueWater.Interfaces;
using BlueWater.Utility;
using DG.Tweening;
using Sirenix.OdinInspector;
using UnityEngine;
@ -95,12 +97,9 @@ namespace BlueWater.Players.Combat
[field: SerializeField, Tooltip("대쉬가 쿨타임일 때 이펙트 사용 여부")]
public bool EnableDashCooldownEffect { get; private set; } = true;
[field: SerializeField, Range(0f, 1f), Tooltip("대쉬가 쿨타임일 때, VisualLook이 x축 좌우로 움직이는 범위")]
public float DashCooldownShakingOffset { get; private set; } = 0.1f;
[field: SerializeField, Range(0, 10f), Tooltip("대쉬가 쿨타임일 때, VisualLook이 x축 좌우로 움직이는 횟수")]
public int DashCooldownShakingCount { get; private set; } = 2;
[SerializeField]
private DOTweenAnimation _dashCooldownEffect;
public bool IsDashEnabled { get; private set; } = true;
@ -118,7 +117,7 @@ namespace BlueWater.Players.Combat
public bool IsDashCoolDownActive { get; private set; }
private Coroutine _dashCoroutine;
private Coroutine _dashCooldownEffectCoroutineInstance;
private bool _isQuitting;
#endregion
@ -141,7 +140,19 @@ namespace BlueWater.Players.Combat
Move();
}
private void OnApplicationQuit()
{
_isQuitting = true;
}
private void OnDestroy()
{
if (_isQuitting) return;
_dashCooldownEffect.DOKill();
}
#endregion
// Initialize Methods
@ -157,6 +168,7 @@ namespace BlueWater.Players.Combat
_comboAttackable = GetComponent<IComboAttackable>();
_skillHandler = GetComponent<ISkillHandler>();
_stunnable = GetComponent<IStunnable>();
_dashCooldownEffect = _visualLook.GetComponent<DOTweenAnimation>();
}
#endregion
@ -227,18 +239,11 @@ namespace BlueWater.Players.Combat
{
if (EnableDashCooldownEffect)
{
Utils.StartUniqueCoroutine(this, ref _dashCooldownEffectCoroutineInstance, DashCoolDownEffectCoroutine());
_dashCooldownEffect.DORestart();
}
return false;
}
if (EnableDashCooldownEffect && _dashCooldownEffectCoroutineInstance != null)
{
StopCoroutine(_dashCooldownEffectCoroutineInstance);
_dashCooldownEffectCoroutineInstance = null;
_visualLook.localPosition = Vector3.zero;
}
var isActivatingSkill = _skillHandler?.IsActivatingSkill ?? false;
var isStunned = _stunnable?.IsStunned ?? false;
@ -252,21 +257,6 @@ namespace BlueWater.Players.Combat
return true;
}
private IEnumerator DashCoolDownEffectCoroutine()
{
var newLocalPosition = _visualLook.localPosition;
for (var i = 0; i < DashCooldownShakingCount; i++)
{
newLocalPosition.x = DashCooldownShakingOffset;
_visualLook.localPosition = newLocalPosition;
yield return null;
newLocalPosition.x = -DashCooldownShakingOffset;
_visualLook.localPosition = newLocalPosition;
yield return null;
}
}
public void Dash()
{

View File

@ -515,8 +515,7 @@ MonoBehaviour:
<DashTime>k__BackingField: 0.2
<DashCooldown>k__BackingField: 0.5
<EnableDashCooldownEffect>k__BackingField: 1
<DashCooldownShakingOffset>k__BackingField: 0.1
<DashCooldownShakingCount>k__BackingField: 2
_dashCooldownEffect: {fileID: 0}
--- !u!114 &3889238742570113982
MonoBehaviour:
m_ObjectHideFlags: 0
@ -688,6 +687,7 @@ GameObject:
- component: {fileID: 2668222795840865044}
- component: {fileID: 5558898291459354456}
- component: {fileID: 3031446967001791208}
- component: {fileID: 8975283155893490419}
m_Layer: 9
m_Name: VisualLook
m_TagString: Untagged
@ -787,6 +787,114 @@ Animator:
m_AllowConstantClipSamplingOptimization: 1
m_KeepAnimatorStateOnDisable: 0
m_WriteDefaultValuesOnDisable: 0
--- !u!114 &8975283155893490419
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8540731795983184644}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 4d0390bd8b8ffd640b34fe25065ff1df, type: 3}
m_Name:
m_EditorClassIdentifier:
updateType: 0
isSpeedBased: 0
hasOnStart: 0
hasOnPlay: 0
hasOnUpdate: 0
hasOnStepComplete: 0
hasOnComplete: 0
hasOnTweenCreated: 0
hasOnRewind: 0
onStart:
m_PersistentCalls:
m_Calls: []
onPlay:
m_PersistentCalls:
m_Calls: []
onUpdate:
m_PersistentCalls:
m_Calls: []
onStepComplete:
m_PersistentCalls:
m_Calls: []
onComplete:
m_PersistentCalls:
m_Calls: []
onTweenCreated:
m_PersistentCalls:
m_Calls: []
onRewind:
m_PersistentCalls:
m_Calls: []
targetIsSelf: 1
targetGO: {fileID: 0}
tweenTargetIsTargetGO: 1
delay: 0
duration: 0.3
easeType: 1
easeCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0
outWeight: 0
- serializedVersion: 3
time: 1
value: 1
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0
outWeight: 0
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
loopType: 0
loops: 1
id:
isRelative: 0
isFrom: 0
isIndependentUpdate: 0
autoKill: 0
autoGenerate: 1
isActive: 1
isValid: 1
target: {fileID: 2668222795840865044}
animationType: 9
targetType: 11
forcedTargetType: 0
autoPlay: 0
useTargetAsV3: 0
endValueFloat: 0
endValueV3: {x: 0.2, y: 0, z: 0}
endValueV2: {x: 0, y: 0}
endValueColor: {r: 1, g: 1, b: 1, a: 1}
endValueString:
endValueRect:
serializedVersion: 2
x: 0
y: 0
width: 0
height: 0
endValueTransform: {fileID: 0}
optionalBool0: 0
optionalBool1: 0
optionalFloat0: 1
optionalInt0: 30
optionalRotationMode: 0
optionalScrambleMode: 0
optionalShakeRandomnessMode: 0
optionalString:
--- !u!1001 &863562677678979986
PrefabInstance:
m_ObjectHideFlags: 0