Skip to content

Commit

Permalink
feat: Alien 타격 시 delay & Crew 피격 시 속도 부스트 (#141)
Browse files Browse the repository at this point in the history
* feat: Alien 타격 시 delay
* Crew 피격 시 속도 부스트
  • Loading branch information
scarleter99 authored May 13, 2024
1 parent c09eb46 commit 6298c6b
Show file tree
Hide file tree
Showing 13 changed files with 115 additions and 94 deletions.
1 change: 0 additions & 1 deletion Client/Assets/Resources/Datas/ExcelData/CrewData.csv
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
DataId,Name,WalkSpeed,RunSpeed,WorkSpeed,MaxHp,MaxStamina,MaxSanity,SitSpeed
101000,CrewA,80,110,10,3,100,100,40
,,,,,,,,
4 changes: 1 addition & 3 deletions Client/Assets/Resources/Datas/ExcelData/SkillData.csv
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
DataId,Name,CoolTime,Range,Damage,SanityDamage,TotalSkillAmount,TotalReadySkillAmount
301000,Basic Attack,2,1.5,1,20,1.2,-1
301001,Roar,10,10,-1,30,2.5,0.7
301002,Cursed Howl,60,-1,-1,-1,3.5,0.7
301002,Cursed Howl,60,-1,-1,-1,2.5,0.7
301003,Leap Attack,20,1.5,1,20,2,0.7
,,,,,,
,,,
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using UnityEngine;

public class AlienAnimController : BaseAnimController
{
#region Update
Expand Down Expand Up @@ -77,6 +75,9 @@ public void PlayAnim(Define.AlienActionType alienActionType)
case Define.AlienActionType.LeapAttack:
PlayLeapAttack();
break;
case Define.AlienActionType.HitDelay:
PlayHitDelay();
break;
}
}

Expand All @@ -103,7 +104,6 @@ public void PlayReadyRoar()
public void PlayRoar()
{
SetBool("Roar", true);
SetBool("ReadyRoar", false);
}

public void PlayReadyCursedHowl()
Expand All @@ -114,7 +114,6 @@ public void PlayReadyCursedHowl()
public void PlayCursedHowl()
{
SetBool("CursedHowl", true);
SetBool("ReadyRoar", false);
}

public void PlayReadyLeapAttack()
Expand All @@ -125,7 +124,11 @@ public void PlayReadyLeapAttack()
public void PlayLeapAttack()
{
SetBool("LeapAttack", true);
SetBool("ReadyLeapAttack", false);
}

public void PlayHitDelay()
{
SetBool("HitDelay", true);
}

#endregion
Expand All @@ -141,5 +144,6 @@ protected override void SetParameterFalse()
SetBool("LeapAttack", false);
SetBool("ReadyRoar", false);
SetBool("ReadyLeapAttack", false);
SetBool("HitDelay", false);
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using UnityEngine;
using Fusion;

public class CrewAnimController : BaseAnimController
Expand Down
80 changes: 56 additions & 24 deletions Client/Assets/Scripts/Contents/Skills/BaseSkill.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public abstract class BaseSkill : NetworkBehaviour

public Alien Owner { get; protected set; }
public Vector3 ForwardDirection => Owner.Transform.forward;
public Vector3 AttackPosition => Owner.Head.transform.position + Vector3.down * 0.2f;
public Vector3 AttackPosition { get; protected set; }

private Tweener _coolTimeTweener;

Expand Down Expand Up @@ -75,6 +75,24 @@ public void UseSkill()
StartCoroutine(ProgressSkill());
}

protected IEnumerator ReadySkillProgress()
{
while (CurrentReadySkillAmount < SkillData.TotalReadySkillAmount)
{
CurrentReadySkillAmount = Mathf.Clamp(CurrentReadySkillAmount + Time.deltaTime, 0, SkillData.TotalReadySkillAmount);
Owner.IngameUI.WorkProgressBarUI.CurrentWorkAmount = CurrentReadySkillAmount;

yield return null;
}

UseSkill();
}

protected virtual IEnumerator ProgressSkill()
{
yield return null;
}

protected void UpdateWorkAmount()
{
CurrentSkillAmount = Mathf.Clamp(CurrentSkillAmount + Time.deltaTime, 0, SkillData.TotalSkillAmount);
Expand All @@ -94,7 +112,26 @@ protected void Cooldown()
});
}

public void SkillInterrupt()
protected virtual void DecideHit(float x, float y)
{
Ray ray = new Ray(AttackPosition + Owner.CameraRotationY * new Vector3(x, y, 0f), ForwardDirection);

Debug.DrawRay(ray.origin, ray.direction * SkillData.Range, Color.red);

if (Physics.Raycast(ray, out RaycastHit rayHit, maxDistance: SkillData.Range,
layerMask: LayerMask.GetMask("Crew", "MapObject", "PlanTargetObject")))
{
if (rayHit.transform.gameObject.TryGetComponent(out Crew crew))
{
IsHit = true;
Owner.AlienSoundController.PlaySound(Define.AlienActionType.Hit);
crew.Rpc_OnDamaged(SkillData.Damage);
crew.Rpc_OnSanityDamaged(SkillData.SanityDamage);
}
}
}

public void SkillInterrupt(float hitDelayTime)
{
StopAllCoroutines();

Expand All @@ -103,11 +140,27 @@ public void SkillInterrupt()
CurrentSkillAmount = 0f;
CurrentReadySkillAmount = 0f;

IsHit = false;
if (IsHit)
{
HitDelay(hitDelayTime);
return;
}

Owner.ReturnToIdle(0);
}

protected void HitDelay(float time)
{
if (time > 0f)
{
Owner.AlienAnimController.PlayAnim(Define.AlienActionType.HitDelay);
Owner.AlienSoundController.PlaySound(Define.AlienActionType.HitDelay);
}

IsHit = false;
Owner.ReturnToIdle(time);
}

protected void PlayAnim(bool isReady)
{
if (isReady)
Expand All @@ -120,26 +173,5 @@ protected void PlaySound()
{
Owner.AlienSoundController.PlaySound(SkillActionType);
}

protected IEnumerator ReadySkillProgress()
{
while (CurrentReadySkillAmount < SkillData.TotalReadySkillAmount)
{
// if (Owner.CreatureState != Define.CreatureState.Use)
// SkillInterrupt();

CurrentReadySkillAmount = Mathf.Clamp(CurrentReadySkillAmount + Time.deltaTime, 0, SkillData.TotalReadySkillAmount);
Owner.IngameUI.WorkProgressBarUI.CurrentWorkAmount = CurrentReadySkillAmount;

yield return null;
}

UseSkill();
}

protected virtual IEnumerator ProgressSkill()
{
yield return null;
}
}

23 changes: 5 additions & 18 deletions Client/Assets/Scripts/Contents/Skills/BasicAttack.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,29 +28,16 @@ protected override IEnumerator ProgressSkill()
PlayAnim(false);
PlaySound();

AttackPosition = Owner.Head.transform.position + Vector3.down * 0.2f;
while (CurrentSkillAmount < SkillData.TotalSkillAmount)
{
if (CurrentSkillAmount > 0.3f && !IsHit)
if (CurrentSkillAmount > 0.3f && CurrentSkillAmount < 0.6f && !IsHit)
{
for (float i = -1f; i <= 1f && !IsHit; i += 0.2f)
for (float i = -0.3f; i <= 0.3f && !IsHit; i += 0.2f)
{
for (float j = -1f; j <= 1f && !IsHit; j += 0.2f)
{
Ray ray = new Ray(AttackPosition + Owner.CameraRotationY * new Vector3(i, j, 0f), ForwardDirection);

Debug.DrawRay(ray.origin, ray.direction * SkillData.Range, Color.red);

if (Physics.Raycast(ray, out RaycastHit rayHit, maxDistance: SkillData.Range,
layerMask: LayerMask.GetMask("Crew", "MapObject", "PlanTargetObject")))
{
if (rayHit.transform.gameObject.TryGetComponent(out Crew crew))
{
IsHit = true;
Owner.AlienSoundController.PlaySound(Define.AlienActionType.Hit);
crew.Rpc_OnDamaged(SkillData.Damage);
crew.Rpc_OnSanityDamaged(SkillData.SanityDamage);
}
}
DecideHit(i, j);
}
}
}
Expand All @@ -59,6 +46,6 @@ protected override IEnumerator ProgressSkill()
yield return null;
}

SkillInterrupt();
SkillInterrupt(1.5f);
}
}
2 changes: 1 addition & 1 deletion Client/Assets/Scripts/Contents/Skills/CursedHowl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,6 @@ protected override IEnumerator ProgressSkill()
yield return null;
}

SkillInterrupt();
SkillInterrupt(0f);
}
}
25 changes: 5 additions & 20 deletions Client/Assets/Scripts/Contents/Skills/LeapAttack.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ public class LeapAttack : BaseSkill
{
public SimpleKCC KCC => Owner.KCC;

public bool IsMoving { get; protected set; }
public bool IsMoving { get; protected set; } = false;
public bool IsErosion => Managers.GameMng.MapSystem.Sectors[Owner.CurrentSector].IsErosion;

public override void SetInfo(int templateId)
Expand All @@ -15,8 +15,6 @@ public override void SetInfo(int templateId)

ReadySkillActionType = Define.AlienActionType.ReadyLeapAttack;
SkillActionType = Define.AlienActionType.LeapAttack;

IsMoving = false;
}

public override bool CheckAndUseSkill()
Expand All @@ -41,29 +39,16 @@ protected override IEnumerator ProgressSkill()
PlayAnim(false);
PlaySound();

AttackPosition = Owner.Head.transform.position + Vector3.down * 0.2f;
while (CurrentSkillAmount < SkillData.TotalSkillAmount)
{
if (CurrentSkillAmount < SkillData.TotalSkillAmount - 0.5f && !IsHit)
{
for (float i = -1f; i <= 1f && !IsHit; i += 0.2f)
for (float i = -0.5f; i <= 0.5f && !IsHit; i += 0.2f)
{
for (float j = -1f; j <= 1f && !IsHit; j += 0.2f)
{
Ray ray = new Ray(AttackPosition + Owner.CameraRotationY * new Vector3(i, j, 0f), ForwardDirection);

Debug.DrawRay(ray.origin, ray.direction * SkillData.Range, Color.red);

if (Physics.Raycast(ray, out RaycastHit rayHit, maxDistance: SkillData.Range,
layerMask: LayerMask.GetMask("Crew", "MapObject", "PlanTargetObject")))
{
if (rayHit.transform.gameObject.TryGetComponent(out Crew crew))
{
IsHit = true;
Owner.AlienSoundController.PlaySound(Define.AlienActionType.Hit);
crew.Rpc_OnDamaged(SkillData.Damage);
crew.Rpc_OnSanityDamaged(SkillData.SanityDamage);
}
}
DecideHit(i, j);
}
}
}
Expand All @@ -75,7 +60,7 @@ protected override IEnumerator ProgressSkill()
}

IsMoving = false;
SkillInterrupt();
SkillInterrupt(1.5f);
}

public override void FixedUpdateNetwork()
Expand Down
39 changes: 22 additions & 17 deletions Client/Assets/Scripts/Contents/Skills/Roar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,34 +16,39 @@ protected override IEnumerator ProgressSkill()
PlayAnim(false);
PlaySound();

AttackPosition = Owner.Head.transform.position + Vector3.down * 0.2f;
while (CurrentSkillAmount < SkillData.TotalSkillAmount)
{
for (float i = -1.5f; i <= 1.5f && !IsHit; i += 0.2f)
{
for (float j = -1.5f; j <= 1.5f && !IsHit; j += 0.2f)
for (float j = -1f; j <= 1f && !IsHit; j += 0.2f)
{
Ray ray = new Ray(AttackPosition + Owner.CameraRotationY * new Vector3(i, j, 0f), ForwardDirection);

Debug.DrawRay(ray.origin, ray.direction * SkillData.Range, Color.red);

if (Physics.Raycast(ray, out RaycastHit rayHit, maxDistance: SkillData.Range,
layerMask: LayerMask.GetMask("Crew", "MapObject", "PlanTargetObject")))
{
if (rayHit.transform.gameObject.TryGetComponent(out Crew crew))
{
IsHit = true;
crew.Rpc_OnDamaged(SkillData.Damage);
crew.Rpc_OnSanityDamaged(SkillData.SanityDamage);
Owner.SkillController.Skills[2].CurrentCoolTime -= 20f;
}
}
DecideHit(i, j);
}
}

UpdateWorkAmount();
yield return null;
}

SkillInterrupt();
SkillInterrupt(0f);
}

protected override void DecideHit(float x, float y)
{
Ray ray = new Ray(AttackPosition + Owner.CameraRotationY * new Vector3(x, y, 0f), ForwardDirection);

Debug.DrawRay(ray.origin, ray.direction * SkillData.Range, Color.red);

if (Physics.Raycast(ray, out RaycastHit rayHit, maxDistance: SkillData.Range,
layerMask: LayerMask.GetMask("Crew", "MapObject", "PlanTargetObject")))
{
if (rayHit.transform.gameObject.TryGetComponent(out Crew crew))
{
IsHit = true;
crew.Rpc_OnSanityDamaged(SkillData.SanityDamage);
Owner.SkillController.Skills[2].CurrentCoolTime -= 20f;
}
}
}
}
8 changes: 8 additions & 0 deletions Client/Assets/Scripts/Contents/Stats/CrewStat.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Data;
using DG.Tweening;
using UnityEngine;

public class CrewStat : BaseStat
Expand All @@ -16,6 +17,7 @@ public class CrewStat : BaseStat
public bool IsRunnable { get; set; } = true;
public bool Exhausted { get; set; } = false;
public bool Doped { get; set; } = false;
public bool DamagedBoost { get; set; } = false;

public override void SetStat(CreatureData creatureData)
{
Expand All @@ -42,6 +44,12 @@ public void ChangeHp(int value)
if (value < 0)
{
Managers.GameMng.RenderingSystem.DamageEffect(Hp);

DamagedBoost = true;
DOVirtual.DelayedCall(3.5f, () =>
{
DamagedBoost = false;
});
}
}

Expand Down
2 changes: 1 addition & 1 deletion Client/Assets/Scripts/Creatures/Alien.cs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ protected override void UpdateMove()

KCC.SetLookRotation(0, CreatureCamera.transform.rotation.eulerAngles.y);

KCC.Move(Velocity * (AlienStat.Speed * Runner.DeltaTime), 0f);
KCC.Move(Velocity * (AlienStat.Speed * Runner.DeltaTime));
}

protected bool CheckAndUseSkill(int skillIdx)
Expand Down
Loading

0 comments on commit 6298c6b

Please sign in to comment.