DEG-18 [Update] 움직일 때 공격 추가 : 공격을 상태가 아닌 행동으로 처리
This commit is contained in:
parent
c40fa3f5b5
commit
86133f44a0
3
Assets/JAY/Animation/Attack01.anim
Normal file
3
Assets/JAY/Animation/Attack01.anim
Normal file
@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:ff89c66614bf77aca6b21457902509d878dab266578f6d69878a2266ea7ec4fa
|
||||
size 874011
|
8
Assets/JAY/Animation/Attack01.anim.meta
Normal file
8
Assets/JAY/Animation/Attack01.anim.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c25471f7e975de140af2a11af5aa791a
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 7400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
BIN
Assets/JAY/Animation/Attack02.anim
(Stored with Git LFS)
Normal file
BIN
Assets/JAY/Animation/Attack02.anim
(Stored with Git LFS)
Normal file
Binary file not shown.
8
Assets/JAY/Animation/Attack02.anim.meta
Normal file
8
Assets/JAY/Animation/Attack02.anim.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2c17f0c4e3017bb448ff5120b9f61794
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 7400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
3
Assets/JAY/Animation/Attack03.anim
Normal file
3
Assets/JAY/Animation/Attack03.anim
Normal file
@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:e7c047dd8e6f911de18984f8f22b41642f540216eb00405e1f3f88ed9b17ede1
|
||||
size 1696284
|
8
Assets/JAY/Animation/Attack03.anim.meta
Normal file
8
Assets/JAY/Animation/Attack03.anim.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 23ef3f3f7e8603c43b49b5a12de765cf
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 7400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
BIN
Assets/JAY/Animation/Attack04.anim
(Stored with Git LFS)
Normal file
BIN
Assets/JAY/Animation/Attack04.anim
(Stored with Git LFS)
Normal file
Binary file not shown.
8
Assets/JAY/Animation/Attack04.anim.meta
Normal file
8
Assets/JAY/Animation/Attack04.anim.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ee0fb1c70ff918147854e2fa7f8ce65d
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 7400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
109
Assets/JAY/Animation/UpperBodyOnly.mask
Normal file
109
Assets/JAY/Animation/UpperBodyOnly.mask
Normal file
@ -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
|
8
Assets/JAY/Animation/UpperBodyOnly.mask.meta
Normal file
8
Assets/JAY/Animation/UpperBodyOnly.mask.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7a5307288916a174ab64fb7c68209bac
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 31900000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
BIN
Assets/JAY/Animator/PlayerController.controller
(Stored with Git LFS)
BIN
Assets/JAY/Animator/PlayerController.controller
(Stored with Git LFS)
Binary file not shown.
BIN
Assets/JAY/HousingUI.unity
(Stored with Git LFS)
BIN
Assets/JAY/HousingUI.unity
(Stored with Git LFS)
Binary file not shown.
BIN
Assets/JAY/Prefabs/Equipments/Chopstick.prefab
(Stored with Git LFS)
BIN
Assets/JAY/Prefabs/Equipments/Chopstick.prefab
(Stored with Git LFS)
Binary file not shown.
BIN
Assets/JAY/Prefabs/WoodChopstick.prefab
(Stored with Git LFS)
Normal file
BIN
Assets/JAY/Prefabs/WoodChopstick.prefab
(Stored with Git LFS)
Normal file
Binary file not shown.
@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cdfd96e94fec4014989e36f19373adb2
|
||||
guid: 31f394375ca23d74e82ded5b2efca2b6
|
||||
PrefabImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
BIN
Assets/JAY/Prefabs/woodChopstick.fbx
(Stored with Git LFS)
Normal file
BIN
Assets/JAY/Prefabs/woodChopstick.fbx
(Stored with Git LFS)
Normal file
Binary file not shown.
109
Assets/JAY/Prefabs/woodChopstick.fbx.meta
Normal file
109
Assets/JAY/Prefabs/woodChopstick.fbx.meta
Normal file
@ -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:
|
@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2c820602050ac1d4b907f11034ef95ad
|
||||
guid: ee6466b67735a354ab9810bc780da469
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
@ -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<PlayerController>().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<PlayerController>().SetState(PlayerState.Idle);
|
||||
// }
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 088c7e98d4f31fb418eab3d8a8a48e57
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
3
Assets/JAY/Scripts/IPlayerAction.meta
Normal file
3
Assets/JAY/Scripts/IPlayerAction.meta
Normal file
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0d821074393d4e97aa21ac0fb2cb40d9
|
||||
timeCreated: 1745375836
|
6
Assets/JAY/Scripts/IPlayerAction/IPlayerAction.cs
Normal file
6
Assets/JAY/Scripts/IPlayerAction/IPlayerAction.cs
Normal file
@ -0,0 +1,6 @@
|
||||
public interface IPlayerAction {
|
||||
void StartAction(PlayerController player);
|
||||
void UpdateAction();
|
||||
void EndAction();
|
||||
bool IsActive { get; }
|
||||
}
|
3
Assets/JAY/Scripts/IPlayerAction/IPlayerAction.cs.meta
Normal file
3
Assets/JAY/Scripts/IPlayerAction/IPlayerAction.cs.meta
Normal file
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d66c33c9a4ef493f9522d78f41b3778f
|
||||
timeCreated: 1745375851
|
58
Assets/JAY/Scripts/IPlayerAction/PlayerActionAttack.cs
Normal file
58
Assets/JAY/Scripts/IPlayerAction/PlayerActionAttack.cs
Normal file
@ -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<WeaponController>();
|
||||
if (weapon != null)
|
||||
{
|
||||
weapon.SetComboStep(step);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0513c92d4bea436fb9be539a2f3ad0e3
|
||||
timeCreated: 1745375880
|
@ -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<GameObject>
|
||||
{
|
||||
// 외부 접근 가능 변수
|
||||
[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<FixedJoystick>();
|
||||
}
|
||||
}
|
||||
|
||||
private void Start()
|
||||
|
||||
protected override void Start()
|
||||
{
|
||||
base.Start();
|
||||
|
||||
// 상태 초기화
|
||||
_playerStateIdle = new PlayerStateIdle();
|
||||
_playerStateMove = new PlayerStateMove();
|
||||
// _playerStateAttack = new PlayerStateAttack();
|
||||
|
||||
_playerStates = new Dictionary<PlayerState, IPlayerState>
|
||||
{
|
||||
{ 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<GameObject>("Player/Weapon/Chopstick");
|
||||
weapon = Instantiate(weaponObject, rightHandTransform);
|
||||
// .GetComponent<WeaponController>();
|
||||
_weaponController = weapon?.GetComponent<WeaponController>();
|
||||
_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
|
||||
}
|
||||
|
@ -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"))
|
||||
|
@ -16,7 +16,7 @@ public class PlayerStateMove : IPlayerState
|
||||
{
|
||||
float inputHorizontal = _playerController.joystick.Horizontal;
|
||||
float inputVertical = _playerController.joystick.Vertical;
|
||||
|
||||
|
||||
// 이동
|
||||
if (inputHorizontal != 0 || inputVertical != 0)
|
||||
{
|
||||
|
3
Assets/JAY/Scripts/Weapon.meta
Normal file
3
Assets/JAY/Scripts/Weapon.meta
Normal file
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e8c373d7c1104f62b6ff1848bcc6b3f1
|
||||
timeCreated: 1745283320
|
10
Assets/JAY/Scripts/Weapon/IObservable.cs
Normal file
10
Assets/JAY/Scripts/Weapon/IObservable.cs
Normal file
@ -0,0 +1,10 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public interface IObservable<T>
|
||||
{
|
||||
public void Subscribe(IObserver<T> observer);
|
||||
public void Unsubscribe(IObserver<T> observer);
|
||||
public void Notify(T value);
|
||||
}
|
3
Assets/JAY/Scripts/Weapon/IObservable.cs.meta
Normal file
3
Assets/JAY/Scripts/Weapon/IObservable.cs.meta
Normal file
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7db2e89701864527b193c3c5b241ca76
|
||||
timeCreated: 1745283381
|
11
Assets/JAY/Scripts/Weapon/IObserver.cs
Normal file
11
Assets/JAY/Scripts/Weapon/IObserver.cs
Normal file
@ -0,0 +1,11 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public interface IObserver<T>
|
||||
{
|
||||
public void OnNext(T value);
|
||||
public void OnError(Exception error);
|
||||
public void OnCompleted();
|
||||
}
|
3
Assets/JAY/Scripts/Weapon/IObserver.cs.meta
Normal file
3
Assets/JAY/Scripts/Weapon/IObserver.cs.meta
Normal file
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 739f14653b804ce4a07632994722e3d6
|
||||
timeCreated: 1745283352
|
183
Assets/JAY/Scripts/WeaponController.cs
Normal file
183
Assets/JAY/Scripts/WeaponController.cs
Normal file
@ -0,0 +1,183 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class WeaponController : MonoBehaviour, IObservable<GameObject>
|
||||
{
|
||||
[Serializable]
|
||||
public class WeaponTriggerZone
|
||||
{
|
||||
public Vector3 position;
|
||||
public float radius;
|
||||
}
|
||||
|
||||
[SerializeField] private WeaponTriggerZone[] _triggerZones;
|
||||
[SerializeField] private LayerMask targetLayerMask;
|
||||
|
||||
private List<IObserver<GameObject>> _observers = new List<IObserver<GameObject>>();
|
||||
|
||||
// 공격 데미지 처리
|
||||
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<Collider> _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<PlayerController>();
|
||||
_previousPositions = new Vector3[_triggerZones.Length];
|
||||
_hitColliders = new HashSet<Collider>();
|
||||
}
|
||||
|
||||
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<GameObject> observer)
|
||||
{
|
||||
if (!_observers.Contains(observer))
|
||||
{
|
||||
_observers.Add(observer);
|
||||
}
|
||||
}
|
||||
|
||||
public void Unsubscribe(IObserver<GameObject> observer)
|
||||
{
|
||||
_observers.Remove(observer);
|
||||
}
|
||||
|
||||
public void Notify(GameObject value)
|
||||
{
|
||||
foreach (var observer in _observers)
|
||||
{
|
||||
observer.OnNext(value);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
var copyObservers = new List<IObserver<GameObject>>(_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
|
||||
|
||||
}
|
3
Assets/JAY/Scripts/WeaponController.cs.meta
Normal file
3
Assets/JAY/Scripts/WeaponController.cs.meta
Normal file
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 14a4a5b667c44deaac42b0a5b624aaaf
|
||||
timeCreated: 1745289551
|
BIN
Assets/Resources/Player/Weapon/Chopstick.prefab
(Stored with Git LFS)
BIN
Assets/Resources/Player/Weapon/Chopstick.prefab
(Stored with Git LFS)
Binary file not shown.
BIN
Assets/StoreAssets/LittleFriends-CartoonAnimals-Lite/Materials/Squirrel_Body_Crying.mat
(Stored with Git LFS)
BIN
Assets/StoreAssets/LittleFriends-CartoonAnimals-Lite/Materials/Squirrel_Body_Crying.mat
(Stored with Git LFS)
Binary file not shown.
BIN
Assets/StoreAssets/LittleFriends-CartoonAnimals-Lite/Materials/Squirrel_Ears.mat
(Stored with Git LFS)
BIN
Assets/StoreAssets/LittleFriends-CartoonAnimals-Lite/Materials/Squirrel_Ears.mat
(Stored with Git LFS)
Binary file not shown.
BIN
Assets/StoreAssets/LittleFriends-CartoonAnimals-Lite/Materials/Squirrel_EyelidsTail.mat
(Stored with Git LFS)
BIN
Assets/StoreAssets/LittleFriends-CartoonAnimals-Lite/Materials/Squirrel_EyelidsTail.mat
(Stored with Git LFS)
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user