diff --git a/Assets/JAY/Animation/Attack01.anim b/Assets/JAY/Animation/Attack01.anim new file mode 100644 index 00000000..ccf26dd9 --- /dev/null +++ b/Assets/JAY/Animation/Attack01.anim @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ff89c66614bf77aca6b21457902509d878dab266578f6d69878a2266ea7ec4fa +size 874011 diff --git a/Assets/JAY/Animation/Attack01.anim.meta b/Assets/JAY/Animation/Attack01.anim.meta new file mode 100644 index 00000000..53d368c8 --- /dev/null +++ b/Assets/JAY/Animation/Attack01.anim.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: c25471f7e975de140af2a11af5aa791a +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 7400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/JAY/Animation/Attack02.anim b/Assets/JAY/Animation/Attack02.anim new file mode 100644 index 00000000..796d1efb --- /dev/null +++ b/Assets/JAY/Animation/Attack02.anim @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:24f7ad70756e8581b0e29837f63b0cd778239d0e814ca8e6fba9f1369135ad15 +size 915074 diff --git a/Assets/JAY/Animation/Attack02.anim.meta b/Assets/JAY/Animation/Attack02.anim.meta new file mode 100644 index 00000000..3633a74b --- /dev/null +++ b/Assets/JAY/Animation/Attack02.anim.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 2c17f0c4e3017bb448ff5120b9f61794 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 7400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/JAY/Animation/Attack03.anim b/Assets/JAY/Animation/Attack03.anim new file mode 100644 index 00000000..e3d35d5e --- /dev/null +++ b/Assets/JAY/Animation/Attack03.anim @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e7c047dd8e6f911de18984f8f22b41642f540216eb00405e1f3f88ed9b17ede1 +size 1696284 diff --git a/Assets/JAY/Animation/Attack03.anim.meta b/Assets/JAY/Animation/Attack03.anim.meta new file mode 100644 index 00000000..5bb70d98 --- /dev/null +++ b/Assets/JAY/Animation/Attack03.anim.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 23ef3f3f7e8603c43b49b5a12de765cf +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 7400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/JAY/Animation/Attack04.anim b/Assets/JAY/Animation/Attack04.anim new file mode 100644 index 00000000..0dd4649a --- /dev/null +++ b/Assets/JAY/Animation/Attack04.anim @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b7cd9ef4b089d4cb8c37104f3c8394664b89cb584cf7b9cb976a1f1843ebb4b2 +size 915194 diff --git a/Assets/JAY/Animation/Attack04.anim.meta b/Assets/JAY/Animation/Attack04.anim.meta new file mode 100644 index 00000000..394bbd8e --- /dev/null +++ b/Assets/JAY/Animation/Attack04.anim.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: ee0fb1c70ff918147854e2fa7f8ce65d +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 7400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/JAY/Animation/UpperBodyOnly.mask b/Assets/JAY/Animation/UpperBodyOnly.mask new file mode 100644 index 00000000..568a323f --- /dev/null +++ b/Assets/JAY/Animation/UpperBodyOnly.mask @@ -0,0 +1,109 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!319 &31900000 +AvatarMask: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: UpperBodyOnly + m_Mask: 00000000010000000100000000000000000000000100000001000000010000000100000000000000000000000100000001000000 + m_Elements: + - m_Path: + m_Weight: 1 + - m_Path: Body05 + m_Weight: 1 + - m_Path: Eye01 + m_Weight: 1 + - m_Path: Hair01 + m_Weight: 1 + - m_Path: Head01_Male + m_Weight: 1 + - m_Path: Mouth01 + m_Weight: 1 + - m_Path: root + m_Weight: 1 + - m_Path: root/pelvis + m_Weight: 1 + - m_Path: root/pelvis/spine_01 + m_Weight: 1 + - m_Path: root/pelvis/spine_01/spine_02 + m_Weight: 1 + - m_Path: root/pelvis/spine_01/spine_02/spine_03 + m_Weight: 1 + - m_Path: root/pelvis/spine_01/spine_02/spine_03/BackpackBone + m_Weight: 1 + - m_Path: root/pelvis/spine_01/spine_02/spine_03/clavicle_l + m_Weight: 1 + - m_Path: root/pelvis/spine_01/spine_02/spine_03/clavicle_l/shoulderPadJoint_l + m_Weight: 1 + - m_Path: root/pelvis/spine_01/spine_02/spine_03/clavicle_l/upperarm_l + m_Weight: 1 + - m_Path: root/pelvis/spine_01/spine_02/spine_03/clavicle_l/upperarm_l/lowerarm_l + m_Weight: 1 + - m_Path: root/pelvis/spine_01/spine_02/spine_03/clavicle_l/upperarm_l/lowerarm_l/hand_l + m_Weight: 1 + - m_Path: root/pelvis/spine_01/spine_02/spine_03/clavicle_l/upperarm_l/lowerarm_l/hand_l/index_01_l + m_Weight: 1 + - m_Path: root/pelvis/spine_01/spine_02/spine_03/clavicle_l/upperarm_l/lowerarm_l/hand_l/index_01_l/index_02_l + m_Weight: 1 + - m_Path: root/pelvis/spine_01/spine_02/spine_03/clavicle_l/upperarm_l/lowerarm_l/hand_l/index_01_l/index_02_l/index_03_l + m_Weight: 1 + - m_Path: root/pelvis/spine_01/spine_02/spine_03/clavicle_l/upperarm_l/lowerarm_l/hand_l/thumb_01_l + m_Weight: 1 + - m_Path: root/pelvis/spine_01/spine_02/spine_03/clavicle_l/upperarm_l/lowerarm_l/hand_l/thumb_01_l/thumb_02_l + m_Weight: 1 + - m_Path: root/pelvis/spine_01/spine_02/spine_03/clavicle_l/upperarm_l/lowerarm_l/hand_l/thumb_01_l/thumb_02_l/thumb_03_l + m_Weight: 1 + - m_Path: root/pelvis/spine_01/spine_02/spine_03/clavicle_l/upperarm_l/lowerarm_l/hand_l/weapon_l + m_Weight: 1 + - m_Path: root/pelvis/spine_01/spine_02/spine_03/clavicle_r + m_Weight: 1 + - m_Path: root/pelvis/spine_01/spine_02/spine_03/clavicle_r/shoulderPadJoint_r + m_Weight: 1 + - m_Path: root/pelvis/spine_01/spine_02/spine_03/clavicle_r/upperarm_r + m_Weight: 1 + - m_Path: root/pelvis/spine_01/spine_02/spine_03/clavicle_r/upperarm_r/lowerarm_r + m_Weight: 1 + - m_Path: root/pelvis/spine_01/spine_02/spine_03/clavicle_r/upperarm_r/lowerarm_r/hand_r + m_Weight: 1 + - m_Path: root/pelvis/spine_01/spine_02/spine_03/clavicle_r/upperarm_r/lowerarm_r/hand_r/index_01_r + m_Weight: 1 + - m_Path: root/pelvis/spine_01/spine_02/spine_03/clavicle_r/upperarm_r/lowerarm_r/hand_r/index_01_r/index_02_r + m_Weight: 1 + - m_Path: root/pelvis/spine_01/spine_02/spine_03/clavicle_r/upperarm_r/lowerarm_r/hand_r/index_01_r/index_02_r/index_03_r + m_Weight: 1 + - m_Path: root/pelvis/spine_01/spine_02/spine_03/clavicle_r/upperarm_r/lowerarm_r/hand_r/thumb_01_r + m_Weight: 1 + - m_Path: root/pelvis/spine_01/spine_02/spine_03/clavicle_r/upperarm_r/lowerarm_r/hand_r/thumb_01_r/thumb_02_r + m_Weight: 1 + - m_Path: root/pelvis/spine_01/spine_02/spine_03/clavicle_r/upperarm_r/lowerarm_r/hand_r/thumb_01_r/thumb_02_r/thumb_03_r + m_Weight: 1 + - m_Path: root/pelvis/spine_01/spine_02/spine_03/clavicle_r/upperarm_r/lowerarm_r/hand_r/weapon_r + m_Weight: 1 + - m_Path: root/pelvis/spine_01/spine_02/spine_03/CloakBone01 + m_Weight: 1 + - m_Path: root/pelvis/spine_01/spine_02/spine_03/CloakBone01/CloakBone02 + m_Weight: 1 + - m_Path: root/pelvis/spine_01/spine_02/spine_03/CloakBone01/CloakBone02/CloakBone03 + m_Weight: 1 + - m_Path: root/pelvis/spine_01/spine_02/spine_03/neck_01 + m_Weight: 1 + - m_Path: root/pelvis/spine_01/spine_02/spine_03/neck_01/head + m_Weight: 1 + - m_Path: root/pelvis/thigh_l + m_Weight: 1 + - m_Path: root/pelvis/thigh_l/calf_l + m_Weight: 1 + - m_Path: root/pelvis/thigh_l/calf_l/foot_l + m_Weight: 1 + - m_Path: root/pelvis/thigh_l/calf_l/foot_l/ball_l + m_Weight: 1 + - m_Path: root/pelvis/thigh_r + m_Weight: 1 + - m_Path: root/pelvis/thigh_r/calf_r + m_Weight: 1 + - m_Path: root/pelvis/thigh_r/calf_r/foot_r + m_Weight: 1 + - m_Path: root/pelvis/thigh_r/calf_r/foot_r/ball_r + m_Weight: 1 diff --git a/Assets/JAY/Animation/UpperBodyOnly.mask.meta b/Assets/JAY/Animation/UpperBodyOnly.mask.meta new file mode 100644 index 00000000..4e08c186 --- /dev/null +++ b/Assets/JAY/Animation/UpperBodyOnly.mask.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 7a5307288916a174ab64fb7c68209bac +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 31900000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/JAY/Animator/PlayerController.controller b/Assets/JAY/Animator/PlayerController.controller index d46c2f2f..4c9ad755 100644 --- a/Assets/JAY/Animator/PlayerController.controller +++ b/Assets/JAY/Animator/PlayerController.controller @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:08d59f4f15437f527ada2d57db2db6ad8fa7d0dc8446934f0d18a2a590021068 -size 4267 +oid sha256:1c91b275bd31dd5542b32ae3205c9b28e7dd0225cde394431b345bee95a06306 +size 16228 diff --git a/Assets/JAY/HousingUI.unity b/Assets/JAY/HousingUI.unity index 6a31f72a..3f604c83 100644 --- a/Assets/JAY/HousingUI.unity +++ b/Assets/JAY/HousingUI.unity @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:dfbe617d5120b11016d29cf820a94aece991331056d41a410117dc27cbb42763 -size 70754 +oid sha256:04d17aad8f57adf668bc3fe3bef9a990ac563a32935d0435a5c934a2e9b8ebda +size 73969 diff --git a/Assets/JAY/Prefabs/Equipments/Chopstick.prefab b/Assets/JAY/Prefabs/Equipments/Chopstick.prefab deleted file mode 100644 index 58ddd54a..00000000 --- a/Assets/JAY/Prefabs/Equipments/Chopstick.prefab +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:92273f22c8c7d7c2962ae85babfc37d80ead49026cc9787136a7a4cd8b794c40 -size 6474 diff --git a/Assets/JAY/Prefabs/WoodChopstick.prefab b/Assets/JAY/Prefabs/WoodChopstick.prefab new file mode 100644 index 00000000..66ce75f5 --- /dev/null +++ b/Assets/JAY/Prefabs/WoodChopstick.prefab @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4904e55e8266662c174fa05e8c1f7099aa8f6c2948a4415a960b3b554e759185 +size 6029 diff --git a/Assets/JAY/Prefabs/Equipments/Chopstick.prefab.meta b/Assets/JAY/Prefabs/WoodChopstick.prefab.meta similarity index 74% rename from Assets/JAY/Prefabs/Equipments/Chopstick.prefab.meta rename to Assets/JAY/Prefabs/WoodChopstick.prefab.meta index eb3fbe58..f9ec860d 100644 --- a/Assets/JAY/Prefabs/Equipments/Chopstick.prefab.meta +++ b/Assets/JAY/Prefabs/WoodChopstick.prefab.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: cdfd96e94fec4014989e36f19373adb2 +guid: 31f394375ca23d74e82ded5b2efca2b6 PrefabImporter: externalObjects: {} userData: diff --git a/Assets/JAY/Prefabs/woodChopstick.fbx b/Assets/JAY/Prefabs/woodChopstick.fbx new file mode 100644 index 00000000..692fa465 --- /dev/null +++ b/Assets/JAY/Prefabs/woodChopstick.fbx @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:901f57f6d372ea013842f7c94545a9469a6728497100b191a452fa1b9d4ce362 +size 22124 diff --git a/Assets/JAY/Prefabs/woodChopstick.fbx.meta b/Assets/JAY/Prefabs/woodChopstick.fbx.meta new file mode 100644 index 00000000..ee02bca5 --- /dev/null +++ b/Assets/JAY/Prefabs/woodChopstick.fbx.meta @@ -0,0 +1,109 @@ +fileFormatVersion: 2 +guid: 72a88a4cb2c991b48a9c7ebd8f1a5065 +ModelImporter: + serializedVersion: 22200 + internalIDToNameTable: [] + externalObjects: {} + materials: + materialImportMode: 2 + materialName: 0 + materialSearch: 1 + materialLocation: 1 + animations: + legacyGenerateAnimations: 4 + bakeSimulation: 0 + resampleCurves: 1 + optimizeGameObjects: 0 + removeConstantScaleCurves: 0 + motionNodeName: + rigImportErrors: + rigImportWarnings: + animationImportErrors: + animationImportWarnings: + animationRetargetingWarnings: + animationDoRetargetingWarnings: 0 + importAnimatedCustomProperties: 0 + importConstraints: 0 + animationCompression: 1 + animationRotationError: 0.5 + animationPositionError: 0.5 + animationScaleError: 0.5 + animationWrapMode: 0 + extraExposedTransformPaths: [] + extraUserProperties: [] + clipAnimations: [] + isReadable: 0 + meshes: + lODScreenPercentages: [] + globalScale: 1 + meshCompression: 0 + addColliders: 0 + useSRGBMaterialColor: 1 + sortHierarchyByName: 1 + importPhysicalCameras: 1 + importVisibility: 1 + importBlendShapes: 1 + importCameras: 1 + importLights: 1 + nodeNameCollisionStrategy: 1 + fileIdsGeneration: 2 + swapUVChannels: 0 + generateSecondaryUV: 0 + useFileUnits: 1 + keepQuads: 0 + weldVertices: 1 + bakeAxisConversion: 0 + preserveHierarchy: 0 + skinWeightsMode: 0 + maxBonesPerVertex: 4 + minBoneWeight: 0.001 + optimizeBones: 1 + meshOptimizationFlags: -1 + indexFormat: 0 + secondaryUVAngleDistortion: 8 + secondaryUVAreaDistortion: 15.000001 + secondaryUVHardAngle: 88 + secondaryUVMarginMethod: 1 + secondaryUVMinLightmapResolution: 40 + secondaryUVMinObjectScale: 1 + secondaryUVPackMargin: 4 + useFileScale: 1 + strictVertexDataChecks: 0 + tangentSpace: + normalSmoothAngle: 60 + normalImportMode: 0 + tangentImportMode: 3 + normalCalculationMode: 4 + legacyComputeAllNormalsFromSmoothingGroupsWhenMeshHasBlendShapes: 0 + blendShapeNormalImportMode: 1 + normalSmoothingSource: 0 + referencedClips: [] + importAnimation: 1 + humanDescription: + serializedVersion: 3 + human: [] + skeleton: [] + armTwist: 0.5 + foreArmTwist: 0.5 + upperLegTwist: 0.5 + legTwist: 0.5 + armStretch: 0.05 + legStretch: 0.05 + feetSpacing: 0 + globalScale: 1 + rootMotionBoneName: + hasTranslationDoF: 0 + hasExtraRoot: 0 + skeletonHasParents: 1 + lastHumanDescriptionAvatarSource: {instanceID: 0} + autoGenerateAvatarMappingIfUnspecified: 1 + animationType: 2 + humanoidOversampling: 1 + avatarSetup: 0 + addHumanoidExtraRootOnlyWhenUsingAvatar: 1 + importBlendShapeDeformPercent: 1 + remapMaterialsIfMaterialImportModeIsNone: 0 + additionalBone: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/JAY/Prefabs/Equipments.meta b/Assets/JAY/Scripts/AnimatorState.meta similarity index 77% rename from Assets/JAY/Prefabs/Equipments.meta rename to Assets/JAY/Scripts/AnimatorState.meta index f9f6bd08..0459b99e 100644 --- a/Assets/JAY/Prefabs/Equipments.meta +++ b/Assets/JAY/Scripts/AnimatorState.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 2c820602050ac1d4b907f11034ef95ad +guid: ee6466b67735a354ab9810bc780da469 folderAsset: yes DefaultImporter: externalObjects: {} diff --git a/Assets/JAY/Scripts/AnimatorState/PlayerAnimatorStateAttack.cs b/Assets/JAY/Scripts/AnimatorState/PlayerAnimatorStateAttack.cs new file mode 100644 index 00000000..ba454806 --- /dev/null +++ b/Assets/JAY/Scripts/AnimatorState/PlayerAnimatorStateAttack.cs @@ -0,0 +1,50 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class PlayerAnimatorStateAttack : StateMachineBehaviour +{ + + // OnStateEnter is called before OnStateEnter is called on any state inside this state machine + //override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) + //{ + // + //} + + // OnStateUpdate is called before OnStateUpdate is called on any state inside this state machine + //override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) + //{ + // + //} + + // OnStateExit is called before OnStateExit is called on any state inside this state machine + // override public void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) + // { + // animator.gameObject.GetComponent().SetState(PlayerState.Idle); + // } + + // OnStateMove is called before OnStateMove is called on any state inside this state machine + //override public void OnStateMove(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) + //{ + // + //} + + // OnStateIK is called before OnStateIK is called on any state inside this state machine + //override public void OnStateIK(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) + //{ + // + //} + + // OnStateMachineEnter is called when entering a state machine via its Entry Node + //override public void OnStateMachineEnter(Animator animator, int stateMachinePathHash) + //{ + // + //} + + // OnStateMachineExit is called when exiting a state machine via its Exit Node + // override public void OnStateMachineExit(Animator animator, int stateMachinePathHash) + // { + // Debug.Log("스테이트머신 콤보끝?"); + // animator.gameObject.GetComponent().SetState(PlayerState.Idle); + // } +} diff --git a/Assets/JAY/Scripts/AnimatorState/PlayerAnimatorStateAttack.cs.meta b/Assets/JAY/Scripts/AnimatorState/PlayerAnimatorStateAttack.cs.meta new file mode 100644 index 00000000..9a74076c --- /dev/null +++ b/Assets/JAY/Scripts/AnimatorState/PlayerAnimatorStateAttack.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 088c7e98d4f31fb418eab3d8a8a48e57 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/JAY/Scripts/IPlayerAction.meta b/Assets/JAY/Scripts/IPlayerAction.meta new file mode 100644 index 00000000..5678e1a2 --- /dev/null +++ b/Assets/JAY/Scripts/IPlayerAction.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 0d821074393d4e97aa21ac0fb2cb40d9 +timeCreated: 1745375836 \ No newline at end of file diff --git a/Assets/JAY/Scripts/IPlayerAction/IPlayerAction.cs b/Assets/JAY/Scripts/IPlayerAction/IPlayerAction.cs new file mode 100644 index 00000000..621c4842 --- /dev/null +++ b/Assets/JAY/Scripts/IPlayerAction/IPlayerAction.cs @@ -0,0 +1,6 @@ +public interface IPlayerAction { + void StartAction(PlayerController player); + void UpdateAction(); + void EndAction(); + bool IsActive { get; } +} \ No newline at end of file diff --git a/Assets/JAY/Scripts/IPlayerAction/IPlayerAction.cs.meta b/Assets/JAY/Scripts/IPlayerAction/IPlayerAction.cs.meta new file mode 100644 index 00000000..8f473e93 --- /dev/null +++ b/Assets/JAY/Scripts/IPlayerAction/IPlayerAction.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: d66c33c9a4ef493f9522d78f41b3778f +timeCreated: 1745375851 \ No newline at end of file diff --git a/Assets/JAY/Scripts/IPlayerAction/PlayerActionAttack.cs b/Assets/JAY/Scripts/IPlayerAction/PlayerActionAttack.cs new file mode 100644 index 00000000..ab824561 --- /dev/null +++ b/Assets/JAY/Scripts/IPlayerAction/PlayerActionAttack.cs @@ -0,0 +1,58 @@ +using UnityEngine; + +public class PlayerActionAttack : IPlayerAction { + private PlayerController player; + private int comboStep = 1; + private bool comboQueued = false; + private bool canReceiveCombo = false; + + public bool IsActive { get; private set; } + + public void StartAction(PlayerController player) { + this.player = player; + IsActive = true; + comboStep = 1; + comboQueued = false; + PlayComboAnimation(comboStep); + player.PlayerAnimator.SetBool("Attack", true); + } + + public void UpdateAction() { + if (Input.GetKeyDown(KeyCode.X) && canReceiveCombo) { + comboQueued = true; + } + } + + public void EndAction() { + player.PlayerAnimator.SetBool("Attack", false); + IsActive = false; + player = null; + } + + public void EnableCombo() { + canReceiveCombo = true; + } + + public void DisableCombo() { + canReceiveCombo = false; + + if (comboQueued && comboStep < 4) { + comboStep++; + PlayComboAnimation(comboStep); + comboQueued = false; + } else { + EndAction(); // 행동 종료 + } + } + + private void PlayComboAnimation(int step) { + player.PlayerAnimator.SetInteger("ComboStep", step); + + // 무기에 콤보 단계 전달 + var weapon = player.GetComponentInChildren(); + if (weapon != null) + { + weapon.SetComboStep(step); + } + } +} \ No newline at end of file diff --git a/Assets/JAY/Scripts/IPlayerAction/PlayerActionAttack.cs.meta b/Assets/JAY/Scripts/IPlayerAction/PlayerActionAttack.cs.meta new file mode 100644 index 00000000..217961db --- /dev/null +++ b/Assets/JAY/Scripts/IPlayerAction/PlayerActionAttack.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 0513c92d4bea436fb9be539a2f3ad0e3 +timeCreated: 1745375880 \ No newline at end of file diff --git a/Assets/JAY/Scripts/PlayerController.cs b/Assets/JAY/Scripts/PlayerController.cs index 4dc0bfef..6dd94b93 100644 --- a/Assets/JAY/Scripts/PlayerController.cs +++ b/Assets/JAY/Scripts/PlayerController.cs @@ -1,28 +1,32 @@ +using System; using System.Collections; using System.Collections.Generic; using UnityEngine; -public enum PlayerState { None, Idle, Move, Attack, Hit, Dead } +public enum PlayerState { None, Idle, Move, Hit, Dead } -public class PlayerController : CharacterBase +public class PlayerController : CharacterBase, IObserver { // 외부 접근 가능 변수 - [Header("Movement")] - [SerializeField] private float rotationSpeed = 10f; - [Header("Attach Points")] [SerializeField] private Transform rightHandTransform; - [SerializeField] private Transform headTransform; - // 내부에서만 사용하는 변수 private CharacterController _characterController; private bool _isBattle; private GameObject weapon; + private WeaponController _weaponController; + + private IPlayerState CurrentStateClass { get; set; } + private IPlayerAction currentAction; // 상태 관련 private PlayerStateIdle _playerStateIdle; private PlayerStateMove _playerStateMove; + // public PlayerStateAttack _playerStateAttack; + + // 행동 관련 + private PlayerActionAttack attackAction; // 외부에서도 사용하는 변수 public FixedJoystick joystick { get; private set; } @@ -40,19 +44,25 @@ public class PlayerController : CharacterBase joystick = FindObjectOfType(); } } - - private void Start() + + protected override void Start() { + base.Start(); + // 상태 초기화 _playerStateIdle = new PlayerStateIdle(); _playerStateMove = new PlayerStateMove(); + // _playerStateAttack = new PlayerStateAttack(); _playerStates = new Dictionary { { PlayerState.Idle, _playerStateIdle }, { PlayerState.Move, _playerStateMove }, + // { PlayerState.Attack, _playerStateAttack }, }; - + + attackAction = new PlayerActionAttack(); + PlayerInit(); } @@ -62,6 +72,21 @@ public class PlayerController : CharacterBase { _playerStates[CurrentState].Update(); } + + // 현재 액션이 활성화 되어 있으면 Update 호출 + if (currentAction != null && currentAction.IsActive) { + currentAction.UpdateAction(); + } + + // 공격 입력 처리 + if (Input.GetKeyDown(KeyCode.X) && (currentAction == null || !currentAction.IsActive)) { + StartAttackAction(); + } + } + + public void StartAttackAction() { + currentAction = attackAction; + currentAction.StartAction(this); } #region 초기화 관련 @@ -71,7 +96,6 @@ public class PlayerController : CharacterBase SetState(PlayerState.Idle); InstantiateWeapon(); - weapon.SetActive(_isBattle); } private void InstantiateWeapon() @@ -80,11 +104,12 @@ public class PlayerController : CharacterBase { GameObject weaponObject = Resources.Load("Player/Weapon/Chopstick"); weapon = Instantiate(weaponObject, rightHandTransform); - // .GetComponent(); + _weaponController = weapon?.GetComponent(); + _weaponController?.Subscribe(this); + weapon?.SetActive(_isBattle); } } - #endregion public void SetState(PlayerState state) @@ -94,12 +119,47 @@ public class PlayerController : CharacterBase _playerStates[CurrentState].Exit(); } CurrentState = state; - _playerStates[CurrentState].Enter(this); + CurrentStateClass = _playerStates[state]; + CurrentStateClass.Enter(this); } - + public void SwitchBattleMode() { _isBattle = !_isBattle; weapon.SetActive(_isBattle); } + + // Animation Event에서 호출될 메서드 + public void SetAttackComboTrue() { + if (currentAction == attackAction) { + attackAction.EnableCombo(); + _weaponController.AttackStart(); + } + } + + public void SetAttackComboFalse() { + if (currentAction == attackAction) { + attackAction.DisableCombo(); + _weaponController.AttackEnd(); + } + } + + #region IObserver 관련 + + public void OnNext(GameObject value) + { + Debug.Log("무기 타격"); + float playerAttackPower = _weaponController.AttackPower * attackPower; // 플레이어 공격 데미지(막타는 일반 데미지의 4배) + } + + public void OnError(Exception error) + { + } + + public void OnCompleted() + { + _weaponController.Unsubscribe(this); + } + + #endregion } diff --git a/Assets/JAY/Scripts/PlayerControllerEditor.cs b/Assets/JAY/Scripts/PlayerControllerEditor.cs index 846aad26..0c7a78db 100644 --- a/Assets/JAY/Scripts/PlayerControllerEditor.cs +++ b/Assets/JAY/Scripts/PlayerControllerEditor.cs @@ -21,8 +21,7 @@ public class PlayerControllerEditor : Editor EditorGUILayout.BeginVertical(EditorStyles.helpBox); - EditorGUILayout.LabelField("현재 상태", playerController.CurrentState.ToString(), - EditorStyles.boldLabel); + EditorGUILayout.LabelField("현재 상태", playerController.CurrentState.ToString(), EditorStyles.boldLabel); EditorGUILayout.EndVertical(); @@ -39,8 +38,6 @@ public class PlayerControllerEditor : Editor if (GUILayout.Button("BattleMode")) playerController.SwitchBattleMode(); - // if (GUILayout.Button("Attack")) - // playerController.SetState(PlayerState.Attack); // if (GUILayout.Button("Hit")) // playerController.SetState(PlayerState.Hit); // if (GUILayout.Button("Dead")) diff --git a/Assets/JAY/Scripts/PlayerState/PlayerStateMove.cs b/Assets/JAY/Scripts/PlayerState/PlayerStateMove.cs index cc55078c..ae1d19b2 100644 --- a/Assets/JAY/Scripts/PlayerState/PlayerStateMove.cs +++ b/Assets/JAY/Scripts/PlayerState/PlayerStateMove.cs @@ -16,7 +16,7 @@ public class PlayerStateMove : IPlayerState { float inputHorizontal = _playerController.joystick.Horizontal; float inputVertical = _playerController.joystick.Vertical; - + // 이동 if (inputHorizontal != 0 || inputVertical != 0) { diff --git a/Assets/JAY/Scripts/Weapon.meta b/Assets/JAY/Scripts/Weapon.meta new file mode 100644 index 00000000..b595354d --- /dev/null +++ b/Assets/JAY/Scripts/Weapon.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: e8c373d7c1104f62b6ff1848bcc6b3f1 +timeCreated: 1745283320 \ No newline at end of file diff --git a/Assets/JAY/Scripts/Weapon/IObservable.cs b/Assets/JAY/Scripts/Weapon/IObservable.cs new file mode 100644 index 00000000..43c88a48 --- /dev/null +++ b/Assets/JAY/Scripts/Weapon/IObservable.cs @@ -0,0 +1,10 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public interface IObservable +{ + public void Subscribe(IObserver observer); + public void Unsubscribe(IObserver observer); + public void Notify(T value); +} \ No newline at end of file diff --git a/Assets/JAY/Scripts/Weapon/IObservable.cs.meta b/Assets/JAY/Scripts/Weapon/IObservable.cs.meta new file mode 100644 index 00000000..3821c1a5 --- /dev/null +++ b/Assets/JAY/Scripts/Weapon/IObservable.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 7db2e89701864527b193c3c5b241ca76 +timeCreated: 1745283381 \ No newline at end of file diff --git a/Assets/JAY/Scripts/Weapon/IObserver.cs b/Assets/JAY/Scripts/Weapon/IObserver.cs new file mode 100644 index 00000000..c4ec57f2 --- /dev/null +++ b/Assets/JAY/Scripts/Weapon/IObserver.cs @@ -0,0 +1,11 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public interface IObserver +{ + public void OnNext(T value); + public void OnError(Exception error); + public void OnCompleted(); +} \ No newline at end of file diff --git a/Assets/JAY/Scripts/Weapon/IObserver.cs.meta b/Assets/JAY/Scripts/Weapon/IObserver.cs.meta new file mode 100644 index 00000000..6eb76ab9 --- /dev/null +++ b/Assets/JAY/Scripts/Weapon/IObserver.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 739f14653b804ce4a07632994722e3d6 +timeCreated: 1745283352 \ No newline at end of file diff --git a/Assets/JAY/Scripts/WeaponController.cs b/Assets/JAY/Scripts/WeaponController.cs new file mode 100644 index 00000000..84c988cc --- /dev/null +++ b/Assets/JAY/Scripts/WeaponController.cs @@ -0,0 +1,183 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class WeaponController : MonoBehaviour, IObservable +{ + [Serializable] + public class WeaponTriggerZone + { + public Vector3 position; + public float radius; + } + + [SerializeField] private WeaponTriggerZone[] _triggerZones; + [SerializeField] private LayerMask targetLayerMask; + + private List> _observers = new List>(); + + // 공격 데미지 처리 + private int attackPower = 1; + private int _comboStep = 1; + public int AttackPower // 플레이어 공격 데미지 + { + get + { + // 마지막 콤보일 경우 공격력 증가 + return _comboStep == 4 ? attackPower * 4 : attackPower; + } + } + private PlayerController _playerController; + + // 충돌 처리 + private Vector3[] _previousPositions; + private HashSet _hitColliders; + private Ray _ray = new Ray(); + private RaycastHit[] _hits = new RaycastHit[10]; + private bool _isAttacking = false; + + private void Start() + { + if (_triggerZones == null || _triggerZones.Length == 0) + { + Debug.LogWarning("Trigger Zones이 설정되지 않았습니다."); + return; + } + + _playerController = GetComponent(); + _previousPositions = new Vector3[_triggerZones.Length]; + _hitColliders = new HashSet(); + } + + public void AttackStart() + { + if (_hitColliders == null) + { + Debug.LogError("_hitColliders가 null입니다. 무기를 들고 있는지 확인해 주세요!"); + return; + } + _isAttacking = true; + _hitColliders.Clear(); + + for (int i = 0; i < _triggerZones.Length; i++) + { + _previousPositions[i] = transform.position + transform.TransformVector(_triggerZones[i].position); + } + } + + public void AttackEnd() + { + _isAttacking = false; + } + + private void FixedUpdate() + { + if (_isAttacking) + { + for (int i = 0; i < _triggerZones.Length; i++) + { + var worldPosition = transform.position + + transform.TransformVector(_triggerZones[i].position); + var direction = worldPosition - _previousPositions[i]; + _ray.origin = _previousPositions[i]; + _ray.direction = direction; + + var hitCount = Physics.SphereCastNonAlloc(_ray, + _triggerZones[i].radius, _hits, + direction.magnitude, targetLayerMask, + QueryTriggerInteraction.UseGlobal); + for (int j = 0; j < hitCount; j++) + { + var hit = _hits[j]; + if (!_hitColliders.Contains(hit.collider)) + { + _hitColliders.Add(hit.collider); + Notify(hit.collider.gameObject); + } + } + _previousPositions[i] = worldPosition; + } + } + } + + private IEnumerator ResumeTimeScale() + { + yield return new WaitForSecondsRealtime(10f); + Time.timeScale = 1f; + } + + public void Subscribe(IObserver observer) + { + if (!_observers.Contains(observer)) + { + _observers.Add(observer); + } + } + + public void Unsubscribe(IObserver observer) + { + _observers.Remove(observer); + } + + public void Notify(GameObject value) + { + foreach (var observer in _observers) + { + observer.OnNext(value); + } + } + + private void OnDestroy() + { + var copyObservers = new List>(_observers); + foreach (var observer in copyObservers) + { + observer.OnCompleted(); + } + _observers.Clear(); + } + + public void SetComboStep(int step) + { + _comboStep = step; + } + +#if UNITY_EDITOR + + private void OnDrawGizmos() + { + if (_triggerZones == null) return; + + if (_isAttacking && _previousPositions != null) + { + for (int i = 0; i < _triggerZones.Length; i++) + { + if (_triggerZones[i] == null) continue; + + var worldPosition = transform.position + + transform.TransformVector(_triggerZones[i].position); + var direction = worldPosition - _previousPositions[i]; + + Gizmos.color = Color.green; + Gizmos.DrawWireSphere(worldPosition, _triggerZones[i].radius); + + Gizmos.color = Color.red; + Gizmos.DrawWireSphere(worldPosition + direction, _triggerZones[i].radius); + } + } + else + { + foreach (var triggerZone in _triggerZones) + { + if (triggerZone == null) continue; + + Gizmos.color = Color.green; + Gizmos.DrawSphere(triggerZone.position, triggerZone.radius); + } + } + } + +#endif + +} diff --git a/Assets/JAY/Scripts/WeaponController.cs.meta b/Assets/JAY/Scripts/WeaponController.cs.meta new file mode 100644 index 00000000..d8e7e6fc --- /dev/null +++ b/Assets/JAY/Scripts/WeaponController.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 14a4a5b667c44deaac42b0a5b624aaaf +timeCreated: 1745289551 \ No newline at end of file diff --git a/Assets/Resources/Player/Weapon/Chopstick.prefab b/Assets/Resources/Player/Weapon/Chopstick.prefab index 8970c492..810dcc1c 100644 --- a/Assets/Resources/Player/Weapon/Chopstick.prefab +++ b/Assets/Resources/Player/Weapon/Chopstick.prefab @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:9b26784c1a742fe9cf59e6ecac6ac918b457769ccbe4619379a957a387351714 -size 6476 +oid sha256:d539e2dc365e5f928744e7478a1785defad00891355f53d0f9a5fa87940fa13d +size 7199 diff --git a/Assets/StoreAssets/LittleFriends-CartoonAnimals-Lite/Materials/Squirrel_Body_Crying.mat b/Assets/StoreAssets/LittleFriends-CartoonAnimals-Lite/Materials/Squirrel_Body_Crying.mat index 19c41c3e..ac724a60 100644 --- a/Assets/StoreAssets/LittleFriends-CartoonAnimals-Lite/Materials/Squirrel_Body_Crying.mat +++ b/Assets/StoreAssets/LittleFriends-CartoonAnimals-Lite/Materials/Squirrel_Body_Crying.mat @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:b28dfb189b3f4df7d26c7d8e3a07f12e9043c9b2ff033b4bee2c3ca6d203745c -size 3717 +oid sha256:5220e1934f4317967017e3840f42e794f401ba43e68d640d10b7f0c334064a6f +size 3772 diff --git a/Assets/StoreAssets/LittleFriends-CartoonAnimals-Lite/Materials/Squirrel_Ears.mat b/Assets/StoreAssets/LittleFriends-CartoonAnimals-Lite/Materials/Squirrel_Ears.mat index 0bb8c51d..c29afd33 100644 --- a/Assets/StoreAssets/LittleFriends-CartoonAnimals-Lite/Materials/Squirrel_Ears.mat +++ b/Assets/StoreAssets/LittleFriends-CartoonAnimals-Lite/Materials/Squirrel_Ears.mat @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:22a8811b27a4c316103c0250eaba6345edaf21aca504a965f71f1b337e0d0d52 -size 3711 +oid sha256:b3b41ac5455e1a0271b2edb2d3bd6a88c1e1db9b0b7a73d3b10d89d2d0e35eba +size 3766 diff --git a/Assets/StoreAssets/LittleFriends-CartoonAnimals-Lite/Materials/Squirrel_EyelidsTail.mat b/Assets/StoreAssets/LittleFriends-CartoonAnimals-Lite/Materials/Squirrel_EyelidsTail.mat index c69fe342..16bbbce5 100644 --- a/Assets/StoreAssets/LittleFriends-CartoonAnimals-Lite/Materials/Squirrel_EyelidsTail.mat +++ b/Assets/StoreAssets/LittleFriends-CartoonAnimals-Lite/Materials/Squirrel_EyelidsTail.mat @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:ea2d8bcf17d4e1a79d035e476ea309828832423ef28e27a234a7bb765a1713d9 -size 3717 +oid sha256:ddd7e45b59bb79c86f4a43b1441dfa23a02de3d320d1464b1217d968cc155412 +size 3772