Skip to content

Commit

Permalink
feat: 리프어택구현 #61
Browse files Browse the repository at this point in the history
feat: 리프어택구현 #61
  • Loading branch information
jangminseok-05 committed Apr 9, 2024
1 parent 0d8c549 commit 752a224
Show file tree
Hide file tree
Showing 8 changed files with 231 additions and 13 deletions.
62 changes: 60 additions & 2 deletions Client/Assets/Resources/Animators/Stalker.controller
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ AnimatorState:
m_Transitions:
- {fileID: 7059878599765826778}
- {fileID: 6004740808190876546}
- {fileID: -4441658194178284524}
m_StateMachineBehaviours: []
m_Position: {x: 50, y: 50, z: 0}
m_IKOnFeet: 0
Expand All @@ -103,6 +104,56 @@ AnimatorState:
m_MirrorParameter:
m_CycleOffsetParameter:
m_TimeParameter:
--- !u!1101 &-4441658194178284524
AnimatorStateTransition:
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name:
m_Conditions:
- m_ConditionMode: 1
m_ConditionEvent: LeapAttack
m_EventTreshold: 0
m_DstStateMachine: {fileID: 0}
m_DstState: {fileID: 5877090942591934916}
m_Solo: 0
m_Mute: 0
m_IsExit: 0
serializedVersion: 3
m_TransitionDuration: 0.25
m_TransitionOffset: 0
m_ExitTime: 0.70000005
m_HasExitTime: 0
m_HasFixedDuration: 1
m_InterruptionSource: 0
m_OrderedInterruption: 1
m_CanTransitionToSelf: 1
--- !u!1101 &-3851986499957370548
AnimatorStateTransition:
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name:
m_Conditions:
- m_ConditionMode: 2
m_ConditionEvent: LeapAttack
m_EventTreshold: 0
m_DstStateMachine: {fileID: 0}
m_DstState: {fileID: 2017622887031129876}
m_Solo: 0
m_Mute: 0
m_IsExit: 0
serializedVersion: 3
m_TransitionDuration: 0.25
m_TransitionOffset: 0
m_ExitTime: 0.85
m_HasExitTime: 0
m_HasFixedDuration: 1
m_InterruptionSource: 0
m_OrderedInterruption: 1
m_CanTransitionToSelf: 1
--- !u!1101 &-3443602318480781062
AnimatorStateTransition:
m_ObjectHideFlags: 1
Expand Down Expand Up @@ -320,6 +371,12 @@ AnimatorController:
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 0}
- m_Name: LeapAttack
m_Type: 4
m_DefaultFloat: 0
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 0}
m_AnimatorLayers:
- serializedVersion: 5
m_Name: Base Layer
Expand Down Expand Up @@ -384,7 +441,7 @@ AnimatorStateMachine:
m_Position: {x: 800, y: 400, z: 0}
- serializedVersion: 1
m_State: {fileID: 5877090942591934916}
m_Position: {x: 200, y: 400, z: 0}
m_Position: {x: 490, y: 400, z: 0}
- serializedVersion: 1
m_State: {fileID: -4880496416681003384}
m_Position: {x: 500, y: 200, z: 0}
Expand Down Expand Up @@ -569,7 +626,8 @@ AnimatorState:
m_Name: JumpClawsAttack
m_Speed: 1
m_CycleOffset: 0
m_Transitions: []
m_Transitions:
- {fileID: -3851986499957370548}
m_StateMachineBehaviours: []
m_Position: {x: 50, y: 50, z: 0}
m_IKOnFeet: 0
Expand Down
22 changes: 15 additions & 7 deletions Client/Assets/Resources/Prefabs/Creatures/Stalker.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -1041,6 +1041,7 @@ GameObject:
- component: {fileID: 6361414726338469051}
- component: {fileID: -4598067215046518199}
- component: {fileID: 1910566033739555847}
- component: {fileID: 8114384917890620963}
m_Layer: 7
m_Name: Stalker
m_TagString: Untagged
Expand Down Expand Up @@ -1163,6 +1164,7 @@ MonoBehaviour:
- {fileID: 6361414726338469051}
- {fileID: -4598067215046518199}
- {fileID: 1910566033739555847}
- {fileID: 8114384917890620963}
--- !u!114 &8848567419615919483
MonoBehaviour:
m_ObjectHideFlags: 0
Expand All @@ -1179,7 +1181,7 @@ MonoBehaviour:
TotalWords: 4
ApplyTiming: 2
SyncSettings: 79
StateHashes: 000000005775fad1d53ab6540077695bdedc2838d60d65cf5b3f1ae1
StateHashes: 000000005775fad1d53ab6540077695bdedc2838d60d65cf5b3f1ae1ba3676e238793a6700677f7b822833fe1636ac3c0b316b7b3bc588839e816f3c
TriggerHashes: 00000000
--- !u!114 &6976675480461094696
MonoBehaviour:
Expand Down Expand Up @@ -1245,13 +1247,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 430d34e7eabc46ba86caccfe28e7476b, type: 3}
m_Name:
m_EditorClassIdentifier:
_DataId: 0
_CreatureType: 0
_CreatureState: 0
_CreaturePose: 0
_Direction: {x: 0, y: 0, z: 0}
_Velocity: {x: 0, y: 0, z: 0}
CurrentSkillRange: 0
--- !u!114 &4476358356948161216
MonoBehaviour:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -1331,6 +1327,18 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 8351ace36e714fffac612c2255b76fc8, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!114 &8114384917890620963
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8694943018831287373}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 44a80b8a998f99044998e1ce1fd00de0, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1 &8694943018831287375
GameObject:
m_ObjectHideFlags: 0
Expand Down
6 changes: 3 additions & 3 deletions Client/Assets/Scenes/TestScene/Map_JSJ.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.7476314, g: 0.5764814, b: 0.64622027, a: 1}
m_IndirectSpecularColor: {r: 0, g: 0, b: 0, a: 1}
m_UseRadianceAmbientProbe: 0
--- !u!157 &3
LightmapSettings:
Expand Down Expand Up @@ -5767,7 +5767,7 @@ MonoBehaviour:
PlayerPrefab:
- {fileID: 7920281149799720858, guid: 29a9a66ff70ef064aab2dd74f627c7c9, type: 3}
- {fileID: 8694943018831287373, guid: 8699e629035530341baf2cfaa50ba60a, type: 3}
PrefabNum: 0
PrefabNum: 1
PlayerSpawnPosition: {x: -6, y: 0, z: 10}
--- !u!114 &631919794
MonoBehaviour:
Expand Down Expand Up @@ -7678,7 +7678,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: e11b68cfa65e85444a9b9ff196f29a34, type: 3}
m_Name:
m_EditorClassIdentifier:
_playerName:
PlayerName:
--- !u!114 &999382491
MonoBehaviour:
m_ObjectHideFlags: 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,17 @@ public void PlayCursedHowl()
SetBool("ReadyRoar", false);
}

public void PlayReadyLeapAttack()
{
SetBool("ReadyRoar", true);
}

public void PlayLeapAttack()
{
SetBool("LeapAttack", true);
SetBool("ReadyRoar", false);
}

#endregion

protected override void SetParameterFalse()
Expand All @@ -86,5 +97,6 @@ protected override void SetParameterFalse()
SetBool("ReadyRoar", false);
SetBool("Roar", false);
SetBool("CursedHowl", false);
SetBool("LeapAttack", false);
}
}
128 changes: 128 additions & 0 deletions Client/Assets/Scripts/Contents/Skill/LeapAttack.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
using Fusion.Addons.SimpleKCC;
using System.Collections;
using Unity.VisualScripting;
using UnityEngine;
using static Define;

public class LeapAttack : BaseSkill
{
public SimpleKCC KCC { get; protected set; }
private bool isMoving;
private bool isMoveCoroutineRunning;

protected override void Init()
{
base.Init();
KCC = GetComponent<SimpleKCC>();

SkillDescription = "LEAP ATTACK";
SkillTime = 1f;//스킬 시전시간
CoolTime = 4f;//재사용 대기시간
TotalSkillAmount = 2f;//시전 대기시간
AttackRange = 3f;
isMoving = false;
isMoveCoroutineRunning = false;
}

public override bool CheckAndUseSkill()
{
if (!Ready)
return false;

Owner.CurrentSkillRange = AttackRange;
ReadySkill();
return true;
}
public override void ReadySkill()
{
Owner.IngameUI.WorkProgressBarUI.Show(SkillDescription, CurrentSkillAmount, TotalSkillAmount);
Owner.CreatureState = Define.CreatureState.Use;
Owner.CreaturePose = Define.CreaturePose.Stand;

Owner.AlienAnimController.PlayReadyLeapAttack();

StartCoroutine(CoReadySkill());
}

public override void UseSkill()
{
base.UseSkill();

Owner.AlienAnimController.PlayLeapAttack();

isMoving = true;

SkillInterrupt();
Owner.ReturnToIdle(SkillTime);

}

private IEnumerator MoveToTarget()
{
isMoveCoroutineRunning = true;

//Debug.Log("move&");
Vector3 forwardDirection = Owner.CreatureCamera.transform.forward;

RaycastHit hit;
if (Physics.SphereCast(Owner.transform.position, 2f, forwardDirection, out hit, 12f, LayerMask.GetMask("Crew")))
{
Vector3 targetPosition = hit.point; // 충돌 지점까지 이동할 위치
float distance = Vector3.Distance(Owner.transform.position, targetPosition); // 충돌 지점까지의 거리

float moveSpeed = distance / SkillTime * 4; // 이동 속도 계산, 4는 KCC.Movd에 맞춘 조정값.
KCC.Move(forwardDirection * distance, moveSpeed); // 충돌 지점까지 이동

// 이동에 걸리는 시간만큼 대기
yield return new WaitForSeconds(SkillTime);

// 이동이 끝난 후 공격 실행
if (isMoveCoroutineRunning)
{
Attack();
}
}
else
{
// 충돌이 감지되지 않았을 때 기본 값만큼 이동
float moveSpeed = 4f; // 기본 이동 속도
KCC.Move(forwardDirection * 12f, moveSpeed);

yield return new WaitForSeconds(SkillTime);

if (isMoveCoroutineRunning)
{
Attack();
}
}
isMoving = false;
isMoveCoroutineRunning = false;
}


private void Attack()
{
//isMoving = false;
Debug.Log("hit");
// 공격 로직
Vector3 attackPosition = Owner.transform.position + Owner.CreatureCamera.transform.forward * AttackRange;

Collider[] hitColliders = new Collider[4];
int hitNum = Physics.OverlapSphereNonAlloc(attackPosition, AttackRange, hitColliders, LayerMask.GetMask("Crew"));
if (hitNum > 0)
{
foreach (Collider col in hitColliders)
{
if (col != null && col.gameObject.TryGetComponent(out Crew crew))
crew.Rpc_OnDamaged(Owner.AlienStat.AttackDamage);
}
}
}
public override void FixedUpdateNetwork()
{
if (isMoving)
{
StartCoroutine(MoveToTarget());
}
}
}
11 changes: 11 additions & 0 deletions Client/Assets/Scripts/Contents/Skill/LeapAttack.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Client/Assets/Scripts/Controllers/SkillController.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using Fusion;
using UnityEngine;

Expand Down
1 change: 1 addition & 0 deletions Client/Assets/Scripts/Controllers/Stalker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ public override void SetInfo(int templateID)

SkillController.Skills[0] = gameObject.GetComponent<BasicAttack>();
SkillController.Skills[1] = gameObject.GetComponent<Roar>();
SkillController.Skills[2] = gameObject.GetComponent<LeapAttack>();
SkillController.Skills[3] = gameObject.GetComponent<CursedHowl>();
}
}

0 comments on commit 752a224

Please sign in to comment.