Skip to content

Commit

Permalink
alien 공격 패턴 정리
Browse files Browse the repository at this point in the history
alien 공격 패턴 골격 코드 작성
  • Loading branch information
jangminseok-05 committed Mar 27, 2024
1 parent b8a7445 commit 0110ef8
Show file tree
Hide file tree
Showing 9 changed files with 206 additions and 34 deletions.
125 changes: 113 additions & 12 deletions Client/Assets/Resources/Animators/Anglerox_Controller.controller
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ AnimatorStateTransition:
m_PrefabAsset: {fileID: 0}
m_Name:
m_Conditions:
- m_ConditionMode: 1
m_ConditionEvent: attack
- m_ConditionMode: 3
m_ConditionEvent: skill
m_EventTreshold: 0
m_DstStateMachine: {fileID: 0}
m_DstState: {fileID: 1102169362966966258}
Expand Down Expand Up @@ -50,6 +50,31 @@ AnimatorStateTransition:
m_InterruptionSource: 0
m_OrderedInterruption: 1
m_CanTransitionToSelf: 1
--- !u!1101 &-6730112904534654097
AnimatorStateTransition:
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name:
m_Conditions:
- m_ConditionMode: 4
m_ConditionEvent: skill
m_EventTreshold: 0
m_DstStateMachine: {fileID: 0}
m_DstState: {fileID: 1102212010505364052}
m_Solo: 0
m_Mute: 0
m_IsExit: 0
serializedVersion: 3
m_TransitionDuration: 0.25
m_TransitionOffset: 0
m_ExitTime: 0.75
m_HasExitTime: 0
m_HasFixedDuration: 1
m_InterruptionSource: 0
m_OrderedInterruption: 1
m_CanTransitionToSelf: 1
--- !u!1101 &-5846802461361528369
AnimatorStateTransition:
m_ObjectHideFlags: 1
Expand Down Expand Up @@ -83,8 +108,8 @@ AnimatorStateTransition:
m_PrefabAsset: {fileID: 0}
m_Name:
m_Conditions:
- m_ConditionMode: 1
m_ConditionEvent: attack
- m_ConditionMode: 3
m_ConditionEvent: skill
m_EventTreshold: 0
m_DstStateMachine: {fileID: 0}
m_DstState: {fileID: 1102169362966966258}
Expand Down Expand Up @@ -133,8 +158,8 @@ AnimatorStateTransition:
m_PrefabAsset: {fileID: 0}
m_Name:
m_Conditions:
- m_ConditionMode: 1
m_ConditionEvent: attack
- m_ConditionMode: 3
m_ConditionEvent: skill
m_EventTreshold: 0
m_DstStateMachine: {fileID: 0}
m_DstState: {fileID: 1102169362966966258}
Expand Down Expand Up @@ -171,8 +196,8 @@ AnimatorController:
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 0}
- m_Name: attack
m_Type: 9
- m_Name: skill
m_Type: 1
m_DefaultFloat: 0
m_DefaultInt: 0
m_DefaultBool: 0
Expand All @@ -190,6 +215,53 @@ AnimatorController:
m_IKPass: 0
m_SyncedLayerAffectsTiming: 0
m_Controller: {fileID: 9100000}
--- !u!1101 &274247715963133694
AnimatorStateTransition:
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name:
m_Conditions: []
m_DstStateMachine: {fileID: 0}
m_DstState: {fileID: 1102116144221277292}
m_Solo: 0
m_Mute: 0
m_IsExit: 0
serializedVersion: 3
m_TransitionDuration: 0.25
m_TransitionOffset: 0
m_ExitTime: 0.78571427
m_HasExitTime: 1
m_HasFixedDuration: 1
m_InterruptionSource: 0
m_OrderedInterruption: 1
m_CanTransitionToSelf: 1
--- !u!1101 &882864214085579865
AnimatorStateTransition:
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name:
m_Conditions:
- m_ConditionMode: 4
m_ConditionEvent: skill
m_EventTreshold: 0
m_DstStateMachine: {fileID: 0}
m_DstState: {fileID: 1102212010505364052}
m_Solo: 0
m_Mute: 0
m_IsExit: 0
serializedVersion: 3
m_TransitionDuration: 0.25
m_TransitionOffset: 0
m_ExitTime: 0.875
m_HasExitTime: 0
m_HasFixedDuration: 1
m_InterruptionSource: 0
m_OrderedInterruption: 1
m_CanTransitionToSelf: 1
--- !u!1101 &1101106466963419862
AnimatorStateTransition:
m_ObjectHideFlags: 1
Expand Down Expand Up @@ -516,6 +588,7 @@ AnimatorState:
m_Transitions:
- {fileID: -7168314016512429803}
- {fileID: -5261395689582889934}
- {fileID: 882864214085579865}
m_StateMachineBehaviours: []
m_Position: {x: 50, y: 50, z: 0}
m_IKOnFeet: 0
Expand Down Expand Up @@ -568,7 +641,8 @@ AnimatorState:
m_Name: ClawsAttackLeftForward_RM
m_Speed: 1
m_CycleOffset: 0
m_Transitions: []
m_Transitions:
- {fileID: 274247715963133694}
m_StateMachineBehaviours: []
m_Position: {x: 50, y: 50, z: 0}
m_IKOnFeet: 0
Expand Down Expand Up @@ -701,6 +775,7 @@ AnimatorState:
m_Transitions:
- {fileID: -9085755005458341798}
- {fileID: -661135665665489740}
- {fileID: 3508939189481570180}
m_StateMachineBehaviours: []
m_Position: {x: 50, y: 50, z: 0}
m_IKOnFeet: 0
Expand Down Expand Up @@ -1074,6 +1149,7 @@ AnimatorState:
- {fileID: 4868208991692245075}
- {fileID: -5846802461361528369}
- {fileID: -434603738816467208}
- {fileID: -6730112904534654097}
m_StateMachineBehaviours: []
m_Position: {x: 50, y: 50, z: 0}
m_IKOnFeet: 0
Expand Down Expand Up @@ -1444,7 +1520,7 @@ AnimatorStateMachine:
m_ChildStates:
- serializedVersion: 1
m_State: {fileID: 1102169362966966258}
m_Position: {x: -930, y: 230, z: 0}
m_Position: {x: -960, y: 200, z: 0}
- serializedVersion: 1
m_State: {fileID: 1102624063638261004}
m_Position: {x: -372, y: -228, z: 0}
Expand All @@ -1459,7 +1535,7 @@ AnimatorStateMachine:
m_Position: {x: -372, y: -84, z: 0}
- serializedVersion: 1
m_State: {fileID: 1102212010505364052}
m_Position: {x: -372, y: -36, z: 0}
m_Position: {x: -970, y: 280, z: 0}
- serializedVersion: 1
m_State: {fileID: 1102491730542474456}
m_Position: {x: -372, y: 12, z: 0}
Expand Down Expand Up @@ -1528,7 +1604,7 @@ AnimatorStateMachine:
m_Position: {x: 300, y: 156, z: 0}
- serializedVersion: 1
m_State: {fileID: 1102353878863111946}
m_Position: {x: -650, y: 310, z: 0}
m_Position: {x: -640, y: 310, z: 0}
- serializedVersion: 1
m_State: {fileID: 1102381232877895124}
m_Position: {x: 300, y: 252, z: 0}
Expand Down Expand Up @@ -1582,6 +1658,31 @@ AnimatorStateTransition:
m_InterruptionSource: 0
m_OrderedInterruption: 1
m_CanTransitionToSelf: 1
--- !u!1101 &3508939189481570180
AnimatorStateTransition:
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name:
m_Conditions:
- m_ConditionMode: 4
m_ConditionEvent: skill
m_EventTreshold: 0
m_DstStateMachine: {fileID: 0}
m_DstState: {fileID: 1102212010505364052}
m_Solo: 0
m_Mute: 0
m_IsExit: 0
serializedVersion: 3
m_TransitionDuration: 0.25
m_TransitionOffset: 0
m_ExitTime: 0.5833334
m_HasExitTime: 0
m_HasFixedDuration: 1
m_InterruptionSource: 0
m_OrderedInterruption: 1
m_CanTransitionToSelf: 1
--- !u!1101 &4868208991692245075
AnimatorStateTransition:
m_ObjectHideFlags: 1
Expand Down
4 changes: 2 additions & 2 deletions Client/Assets/Resources/Prefabs/Creatures/CrewA.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -5209,11 +5209,11 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
Animator: {fileID: 9068755759678369339}
TotalWords: 6
TotalWords: 5
ApplyTiming: 2
SyncSettings: 79
StateHashes: 000000005775fad1d53ab6546918b6d32ab685d02afa8626a8b5caa326c31e36e4b1df9473a11ec450111d6242f0ae2fcfc2d1012cd143fb0f61405d
TriggerHashes: 00000000779675136918b6d3c64020f2f50acd24
TriggerHashes: 000000001e59b44b779675136918b6d3c64020f2f50acd2449905c91
--- !u!114 &5850708474315694979
MonoBehaviour:
m_ObjectHideFlags: 0
Expand Down
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 @@ -1071,7 +1071,7 @@ Animator:
m_GameObject: {fileID: 8694943018831287373}
m_Enabled: 1
m_Avatar: {fileID: 9000000, guid: 359149b95323d894b978dcd5c8770617, type: 3}
m_Controller: {fileID: 0}
m_Controller: {fileID: 9100000, guid: e370a4311eb91c04d90986cbec69bd94, type: 2}
m_CullingMode: 1
m_UpdateMode: 0
m_ApplyRootMotion: 0
Expand Down
3 changes: 2 additions & 1 deletion Client/Assets/Scenes/TestScene/TestSceneTemplate.unity
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ Transform:
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_LocalScale: {x: 10, y: 1, z: 10}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
Expand Down Expand Up @@ -555,6 +555,7 @@ MonoBehaviour:
PlayerPrefab:
- {fileID: 8694943018831287373, guid: 8699e629035530341baf2cfaa50ba60a, type: 3}
- {fileID: 8694943018831287373, guid: 39a13000f5b6bcd4891069578e10aebd, type: 3}
PrefabNum: 0
PlayerSpawnPosition: {x: 0, y: 0, z: 0}
--- !u!114 &1421730656
MonoBehaviour:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ protected override void Init()
{
base.Init();
SetFloat("currentSpeed", 0);
SetFloat("skill", 0);
}

#region Update

protected override void PlayIdle()
{
SetFloat("currentSpeed", 0);
SetFloat("skill", 0);
}

protected override void PlayMove()
Expand All @@ -29,10 +31,25 @@ protected override void PlayMove()
}
}

public void PlayUseSkill1()
protected override void PlayUse()
{
SetTrigger("attack");
Debug.Log("Alien PlayInteract anim called");
switch (CreaturePose)
{
case Define.CreaturePose.Stand:
SetFloat("skill", 5);
//Debug.Log("Alien PlayInteract anim called");
break;
case Define.CreaturePose.Run:
SetFloat("skill", -5);
//Debug.Log("Alien PlayInteract anim called");
break;
case Define.CreaturePose.Sit:
SetFloat("skill", 5);
//Debug.Log("Alien PlayInteract anim called");
break;

}

}

#endregion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ public void UpdateAnimation()
case Define.CreatureState.Move:
PlayMove();
break;
case Define.CreatureState.Use:
PlayUse();
break;
}
}

Expand All @@ -48,6 +51,10 @@ protected virtual void PlayMove()
{
}

protected virtual void PlayUse()
{
}

#endregion

#region SetParameter
Expand Down
50 changes: 38 additions & 12 deletions Client/Assets/Scripts/Contents/Skill/BasicAttack.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@
public class BasicAttack : BaseSkill
{
private float attackRange = 2f; // 근접 공격 범위
private int skillNum;

// 생성자 추가
public BasicAttack(int num)
{
skillNum = num;
}

public override bool CheckAndUseSkill()
{
Expand All @@ -16,19 +23,38 @@ public override void Rpc_UseSkill()
{
try
{
// 주인공 캐릭터의 위치와 방향을 기준으로 공격 범위 내의 대상을 찾음
Collider[] hitColliders = Physics.OverlapSphere(Owner.transform.position, attackRange);

// 찾은 대상에 대해 각각 데미지를 입히는 동작 수행
foreach (Collider col in hitColliders)
switch (skillNum)
{
// 대상이 공격자 자신이 아니고, 대상이 Crew 클래스를 가진 경우
if (col.gameObject != Owner.gameObject && col.gameObject.TryGetComponent(out Crew crew))
{
// 대상에게 데미지를 입히는 함수 호출
crew.OnDamaged(Owner.AlienStat.Damage);
Debug.Log(crew.DataId + " take damage");
}
case 0:
Debug.Log("skill 0 called");

// 카메라의 위치와 방향을 기준으로,
Vector3 cameraForward = Camera.main.transform.forward;
Vector3 attackPosition = Owner.transform.position + cameraForward * attackRange;
// (카메라의 위치와 방향을 기준으로) 공격 범위 내의 대상을 찾음
Collider[] hitColliders = Physics.OverlapSphere(attackPosition, attackRange); //Collider[] hitColliders = Physics.OverlapSphere(Owner.transform.position, attackRange);

// 찾은 대상에 대해 각각 데미지를 입히는 동작 수행
foreach (Collider col in hitColliders)
{
// 대상이 공격자 자신이 아니고, 대상이 Crew 클래스를 가진 경우
if (col.gameObject != Owner.gameObject && col.gameObject.TryGetComponent(out Crew crew))
{
// 대상에게 데미지를 입히는 함수 호출
crew.OnDamaged(Owner.AlienStat.Damage);
Debug.Log(crew.DataId + " take damage");
}
}
break;
case 1:
Debug.Log("skill 1 called");
break;
case 2:
Debug.Log("skill 2 called");
break;
case 3:
Debug.Log("skill 3 called");
break;
}
}
catch (System.NullReferenceException ex)
Expand Down
Loading

0 comments on commit 0110ef8

Please sign in to comment.