From 752a224b4d7dc37ae7863e3fc49815e0935ae0d4 Mon Sep 17 00:00:00 2001 From: jangminseok-05 <55117195+jangminseok-05@users.noreply.github.com> Date: Tue, 9 Apr 2024 19:41:04 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EB=A6=AC=ED=94=84=EC=96=B4=ED=83=9D?= =?UTF-8?q?=EA=B5=AC=ED=98=84=20#61?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit feat: 리프어택구현 #61 --- .../Resources/Animators/Stalker.controller | 62 ++++++++- .../Prefabs/Creatures/Stalker.prefab | 22 ++- Client/Assets/Scenes/TestScene/Map_JSJ.unity | 6 +- .../AnimController/AlienAnimController.cs | 12 ++ .../Scripts/Contents/Skill/LeapAttack.cs | 128 ++++++++++++++++++ .../Scripts/Contents/Skill/LeapAttack.cs.meta | 11 ++ .../Scripts/Controllers/SkillController.cs | 2 +- Client/Assets/Scripts/Controllers/Stalker.cs | 1 + 8 files changed, 231 insertions(+), 13 deletions(-) create mode 100644 Client/Assets/Scripts/Contents/Skill/LeapAttack.cs create mode 100644 Client/Assets/Scripts/Contents/Skill/LeapAttack.cs.meta diff --git a/Client/Assets/Resources/Animators/Stalker.controller b/Client/Assets/Resources/Animators/Stalker.controller index 45afa667f9..4bcf506ab6 100644 --- a/Client/Assets/Resources/Animators/Stalker.controller +++ b/Client/Assets/Resources/Animators/Stalker.controller @@ -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 @@ -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 @@ -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 @@ -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} @@ -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 diff --git a/Client/Assets/Resources/Prefabs/Creatures/Stalker.prefab b/Client/Assets/Resources/Prefabs/Creatures/Stalker.prefab index d2e0dc12b4..b4dcb21938 100644 --- a/Client/Assets/Resources/Prefabs/Creatures/Stalker.prefab +++ b/Client/Assets/Resources/Prefabs/Creatures/Stalker.prefab @@ -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 @@ -1163,6 +1164,7 @@ MonoBehaviour: - {fileID: 6361414726338469051} - {fileID: -4598067215046518199} - {fileID: 1910566033739555847} + - {fileID: 8114384917890620963} --- !u!114 &8848567419615919483 MonoBehaviour: m_ObjectHideFlags: 0 @@ -1179,7 +1181,7 @@ MonoBehaviour: TotalWords: 4 ApplyTiming: 2 SyncSettings: 79 - StateHashes: 000000005775fad1d53ab6540077695bdedc2838d60d65cf5b3f1ae1 + StateHashes: 000000005775fad1d53ab6540077695bdedc2838d60d65cf5b3f1ae1ba3676e238793a6700677f7b822833fe1636ac3c0b316b7b3bc588839e816f3c TriggerHashes: 00000000 --- !u!114 &6976675480461094696 MonoBehaviour: @@ -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 @@ -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 diff --git a/Client/Assets/Scenes/TestScene/Map_JSJ.unity b/Client/Assets/Scenes/TestScene/Map_JSJ.unity index 68ce2a1611..d768f325a5 100644 --- a/Client/Assets/Scenes/TestScene/Map_JSJ.unity +++ b/Client/Assets/Scenes/TestScene/Map_JSJ.unity @@ -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: @@ -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: @@ -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 diff --git a/Client/Assets/Scripts/Contents/AnimController/AlienAnimController.cs b/Client/Assets/Scripts/Contents/AnimController/AlienAnimController.cs index d6a38d8269..f6b5f75fa1 100644 --- a/Client/Assets/Scripts/Contents/AnimController/AlienAnimController.cs +++ b/Client/Assets/Scripts/Contents/AnimController/AlienAnimController.cs @@ -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() @@ -86,5 +97,6 @@ protected override void SetParameterFalse() SetBool("ReadyRoar", false); SetBool("Roar", false); SetBool("CursedHowl", false); + SetBool("LeapAttack", false); } } diff --git a/Client/Assets/Scripts/Contents/Skill/LeapAttack.cs b/Client/Assets/Scripts/Contents/Skill/LeapAttack.cs new file mode 100644 index 0000000000..1088e471da --- /dev/null +++ b/Client/Assets/Scripts/Contents/Skill/LeapAttack.cs @@ -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(); + + 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()); + } + } +} diff --git a/Client/Assets/Scripts/Contents/Skill/LeapAttack.cs.meta b/Client/Assets/Scripts/Contents/Skill/LeapAttack.cs.meta new file mode 100644 index 0000000000..18bb07bc69 --- /dev/null +++ b/Client/Assets/Scripts/Contents/Skill/LeapAttack.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 44a80b8a998f99044998e1ce1fd00de0 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/Controllers/SkillController.cs b/Client/Assets/Scripts/Controllers/SkillController.cs index 3aa717d7a2..519b99de02 100644 --- a/Client/Assets/Scripts/Controllers/SkillController.cs +++ b/Client/Assets/Scripts/Controllers/SkillController.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using Fusion; using UnityEngine; diff --git a/Client/Assets/Scripts/Controllers/Stalker.cs b/Client/Assets/Scripts/Controllers/Stalker.cs index a702d59a2f..6ccc07f9f2 100644 --- a/Client/Assets/Scripts/Controllers/Stalker.cs +++ b/Client/Assets/Scripts/Controllers/Stalker.cs @@ -6,6 +6,7 @@ public override void SetInfo(int templateID) SkillController.Skills[0] = gameObject.GetComponent(); SkillController.Skills[1] = gameObject.GetComponent(); + SkillController.Skills[2] = gameObject.GetComponent(); SkillController.Skills[3] = gameObject.GetComponent(); } }