Skip to content

Commit

Permalink
feat: 침식 지역 볼륨 이펙트 추가 & Alien 스턴 구현 (#103)
Browse files Browse the repository at this point in the history
  • Loading branch information
scarleter99 authored May 1, 2024
1 parent 182c4ea commit ecc883a
Show file tree
Hide file tree
Showing 8 changed files with 77 additions and 41 deletions.
2 changes: 1 addition & 1 deletion Client/Assets/Resources/Prefabs/Creatures/Stalker.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -1081,7 +1081,7 @@ Animator:
m_Controller: {fileID: 9100000, guid: 72accfa72a7464e4aa5ee9f3b7b1b3c5, type: 2}
m_CullingMode: 0
m_UpdateMode: 0
m_ApplyRootMotion: 1
m_ApplyRootMotion: 0
m_LinearVelocityBlending: 0
m_StabilizeFeet: 0
m_WarningMessage:
Expand Down
6 changes: 3 additions & 3 deletions Client/Assets/Scenes/TestScene/Test_Scene.unity
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ RenderSettings:
m_ReflectionIntensity: 1
m_CustomReflection: {fileID: 0}
m_Sun: {fileID: 0}
m_IndirectSpecularColor: {r: 0.7475758, g: 0.5764442, b: 0.64617735, a: 1}
m_IndirectSpecularColor: {r: 0.7476371, g: 0.57648665, b: 0.6462155, a: 1}
m_UseRadianceAmbientProbe: 0
--- !u!157 &3
LightmapSettings:
Expand Down Expand Up @@ -2413,7 +2413,7 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
m_Profile: {fileID: 11400000, guid: 4eb29f365f594ac4aa02685e19fe4cfd, type: 2}
m_StaticLightingSkyUniqueID: 4
m_StaticLightingSkyUniqueID: 0
m_StaticLightingCloudsUniqueID: 0
m_StaticLightingVolumetricClouds: 0
--- !u!4 &447438399
Expand Down Expand Up @@ -4572,7 +4572,7 @@ MonoBehaviour:
m_EditorClassIdentifier:
PlayerName: Player
DefaultRoomName: TestScene
Creature: 2
Creature: 1
PrefabNum: 0
PlayerSpawnPosition: {x: -6, y: 0, z: 10}
--- !u!114 &999382491
Expand Down
2 changes: 1 addition & 1 deletion Client/Assets/Scripts/Contents/Items/FlashBang.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ protected void Explode(Vector3 attackPosition)
{
foreach (var hitCollider in hitColliders)
if (hitCollider.gameObject.TryGetComponent(out Creature creature))
creature.Rpc_OnBlind(ItemData.Value);
creature.Rpc_OnBlind(ItemData.Value, 3f);
}
}
}
8 changes: 4 additions & 4 deletions Client/Assets/Scripts/Creatures/Alien.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ protected override void HandleInput()
// TODO - TEST CODE
if (Input.GetKeyDown(KeyCode.K))
{
Rpc_OnBlind(2f);
Rpc_OnBlind(2f, 3f);
return;
}
/////////////////////////////////
Expand Down Expand Up @@ -183,14 +183,14 @@ protected bool CheckAndUseSkill(int skillIdx)
#region Event

[Rpc(RpcSources.All, RpcTargets.StateAuthority)]
public override void Rpc_OnBlind(float value)
public override void Rpc_OnBlind(float blindTime, float backTime)
{
base.Rpc_OnBlind(value);
base.Rpc_OnBlind(blindTime, backTime);

CreatureState = Define.CreatureState.Damaged;
AlienAnimController.PlayAnim(Define.AlienActionType.Damaged);
AlienSoundController.PlaySound(Define.AlienActionType.Damaged);
ReturnToIdle(value);
ReturnToIdle(blindTime);
}

public void OnAllKill()
Expand Down
4 changes: 2 additions & 2 deletions Client/Assets/Scripts/Creatures/Creature.cs
Original file line number Diff line number Diff line change
Expand Up @@ -230,11 +230,11 @@ protected bool CheckInteractable(bool tryInteract)
#endregion

[Rpc(RpcSources.All, RpcTargets.StateAuthority)]
public virtual void Rpc_OnBlind(float value)
public virtual void Rpc_OnBlind(float blindTime, float backTime)
{
if (!HasStateAuthority || CreatureState == Define.CreatureState.Dead || !IsSpawned)
return;

Managers.GameMng.RenderingSystem.GetBlind(value);
Managers.GameMng.RenderingSystem.GetBlind(blindTime, backTime);
}
}
28 changes: 19 additions & 9 deletions Client/Assets/Scripts/Creatures/Crew.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,6 @@ protected override void HandleInput()

/////////////////////////////////
// TODO - TEST CODE
if (Input.GetKeyDown(KeyCode.L))
{
IsGameScene = true;
}
if (Input.GetKeyDown(KeyCode.K))
{
Rpc_OnBlind(2f);
return;
}
if (Input.GetKeyDown(KeyCode.U))
{
Rpc_OnDamaged(1);
Expand All @@ -119,6 +110,25 @@ protected override void HandleInput()
CrewStat.ChangeSanity(10f);
return;
}
if (Input.GetKeyDown(KeyCode.K))
{
Rpc_OnBlind(2f, 3f);
return;
}
if (Input.GetKeyDown(KeyCode.H))
{
Managers.GameMng.RenderingSystem.SetColorAdjustments(true);
return;
}
if (Input.GetKeyDown(KeyCode.J))
{
Managers.GameMng.RenderingSystem.SetColorAdjustments(false);
return;
}
if (Input.GetKeyDown(KeyCode.L))
{
IsGameScene = true;
}
if (Input.GetKeyDown(KeyCode.Z))
{
OnClear();
Expand Down
65 changes: 44 additions & 21 deletions Client/Assets/Scripts/Systems/RenderingSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,15 @@ public class RenderingSystem : NetworkBehaviour

public Material DamageMaterial { get; protected set; }

public float DamageEffectSpeed { get; protected set; } = 1.5f;
private Tweener _setChromaticAberrationTweener;
private Tweener _setColorAdjustmentsTweener;
private Tweener _setVignetteTweener;
private Tweener _getBlindTweener;
private Color _erosionColor = new Color(255.0f / 255.0f, 76.0f / 255.0f, 76.0f / 255.0f);
private Color _erosionColor2 = new Color(76.0f / 255.0f, 76.0f / 255.0f, 255.0f / 255.0f);
private Color _defaultColor = new Color(255.0f / 255.0f, 255.0f / 255.0f, 255.0f / 255.0f);
private float _damageEffectSpeed = 1.5f;


public override void Spawned()
{
Expand All @@ -43,8 +51,9 @@ public void Init()

DamageMaterial = Managers.ResourceMng.Load<Material>("Material/DamageMaterial");

SetChromaticAberration(100f);
SetVignette(100f);
ChromaticAberration.intensity.value = 0f;
ColorAdjustments.colorFilter.value = _defaultColor;
Vignette.intensity.value = 0.2f;
IndirectLightingController.indirectDiffuseLightingMultiplier.value = 0f;

DamageEffect(3);
Expand All @@ -55,31 +64,50 @@ public void Init()
public void SetChromaticAberration(float sanity)
{
ChromaticAberration.intensity.value = (100f - sanity) * 0.01f;

_setChromaticAberrationTweener.Kill();
_setChromaticAberrationTweener = DOVirtual.Float(ChromaticAberration.intensity.value,
(100f - sanity) * 0.01f, 1f, value =>
{
ChromaticAberration.intensity.value = value;
});
}

public void SetColorAdjustments(bool value)
public void SetColorAdjustments(bool isErosion)
{
if (value)
ColorAdjustments.colorFilter.value = new Color(76f, 76f, 255f);
else
ColorAdjustments.colorFilter.value = new Color(255f, 255f, 255f);
Color color = _defaultColor;

if (isErosion)
color = _erosionColor;

_setColorAdjustmentsTweener.Kill();
_setColorAdjustmentsTweener = DOVirtual.Color(ColorAdjustments.colorFilter.value, color, 2f, value =>
{
ColorAdjustments.colorFilter.value = value;
});
}

public void SetVignette(float sanity)
{
Vignette.intensity.value = 0.2f + (100f - sanity) * 0.01f * 0.55f;
_setVignetteTweener.Kill();
_setVignetteTweener = DOVirtual.Float(Vignette.intensity.value,
0.2f + (100f - sanity) * 0.01f * 0.55f, 1f, value =>
{
Vignette.intensity.value = value;
});
}

public void GetBlind(float time)
public void GetBlind(float blindTime, float backTime)
{
_getBlindTweener.Kill();
IndirectLightingController.indirectDiffuseLightingMultiplier.value = 5000f;

float temp = 5100f / 2f;
DOVirtual.DelayedCall(time, () =>
DOVirtual.DelayedCall(blindTime, () =>
{
DOVirtual.Float(0, 0, 3f, value =>
_getBlindTweener.Kill();
_getBlindTweener = DOVirtual.Float(IndirectLightingController.indirectDiffuseLightingMultiplier.value, 0, backTime, value =>
{
IndirectLightingController.indirectDiffuseLightingMultiplier.value -= temp * Time.deltaTime;
IndirectLightingController.indirectDiffuseLightingMultiplier.value = value;
});
});
}
Expand Down Expand Up @@ -108,7 +136,7 @@ private IEnumerator DamageEffectProgress(float intensity)
float targetRadius = Mathf.Lerp(1.2f, -1f, Mathf.InverseLerp(0, 1, intensity));
//float targetRadius = Remap(intensity, 0, 1, 1.2f, -1f);
float curRadius = 1; // No damage
for (float t = 0; curRadius != targetRadius; t += Time.deltaTime * DamageEffectSpeed)
for (float t = 0; curRadius != targetRadius; t += Time.deltaTime * _damageEffectSpeed)
{
curRadius = Mathf.Lerp(1, targetRadius, t);
DamageMaterial.SetFloat("_Vignette_radius", curRadius);
Expand All @@ -117,7 +145,7 @@ private IEnumerator DamageEffectProgress(float intensity)

if (intensity < 1)
{
for (float t = 0; curRadius < 1; t += Time.deltaTime * DamageEffectSpeed)
for (float t = 0; curRadius < 1; t += Time.deltaTime * _damageEffectSpeed)
{
curRadius = Mathf.Lerp(targetRadius, 1, t);
DamageMaterial.SetFloat("_Vignette_radius", curRadius);
Expand All @@ -131,11 +159,6 @@ private IEnumerator DamageEffectProgress(float intensity)
//impulseSource.GenerateImpulse(velocity * intensity * 0.4f);
}

private float Remap(float value, float fromMin, float fromMax, float toMin, float toMax)
{
return Mathf.Lerp(toMin, toMax, Mathf.InverseLerp(fromMin, fromMax, value));
}

#endregion
}

3 changes: 3 additions & 0 deletions Client/Assets/Scripts/Utils/Define.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
using UnityEngine;

public static class Define
{
#region Type
Expand Down Expand Up @@ -63,6 +65,7 @@ public enum SoundType
Effect,
MaxCount,
}

#endregion

#region State
Expand Down

0 comments on commit ecc883a

Please sign in to comment.