diff --git a/Gameton-06/Assets/Gameton/Resources/Animation/Monster/Dragon/BlueDragon/BlueDragon Animation Controller.controller b/Gameton-06/Assets/Gameton/Resources/Animation/Monster/Dragon/BlueDragon/BlueDragon Animation Controller.controller index a919b7dd..253e2713 100644 --- a/Gameton-06/Assets/Gameton/Resources/Animation/Monster/Dragon/BlueDragon/BlueDragon Animation Controller.controller +++ b/Gameton-06/Assets/Gameton/Resources/Animation/Monster/Dragon/BlueDragon/BlueDragon Animation Controller.controller @@ -261,7 +261,7 @@ AnimatorStateTransition: m_HasFixedDuration: 1 m_InterruptionSource: 0 m_OrderedInterruption: 1 - m_CanTransitionToSelf: 1 + m_CanTransitionToSelf: 0 --- !u!1102 &8693684011770968853 AnimatorState: serializedVersion: 6 diff --git a/Gameton-06/Assets/Gameton/Resources/Animation/Monster/Dragon/Monster Animation Controller.controller b/Gameton-06/Assets/Gameton/Resources/Animation/Monster/Dragon/Monster Animation Controller.controller index f831d52f..20395317 100644 --- a/Gameton-06/Assets/Gameton/Resources/Animation/Monster/Dragon/Monster Animation Controller.controller +++ b/Gameton-06/Assets/Gameton/Resources/Animation/Monster/Dragon/Monster Animation Controller.controller @@ -36,12 +36,11 @@ AnimatorState: m_Name: Walk m_Speed: 1 m_CycleOffset: 0 - m_Transitions: - - {fileID: 5118717445711135838} + m_Transitions: [] m_StateMachineBehaviours: [] m_Position: {x: 50, y: 50, z: 0} m_IKOnFeet: 0 - m_WriteDefaultValues: 1 + m_WriteDefaultValues: 0 m_Mirror: 0 m_SpeedParameterActive: 0 m_MirrorParameterActive: 0 @@ -53,31 +52,6 @@ AnimatorState: m_MirrorParameter: m_CycleOffsetParameter: m_TimeParameter: ---- !u!1101 &-2104665456298266282 -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: Walk - m_EventTreshold: 0 - m_DstStateMachine: {fileID: 0} - m_DstState: {fileID: -2826469442554405870} - m_Solo: 0 - m_Mute: 0 - m_IsExit: 0 - serializedVersion: 3 - m_TransitionDuration: 0 - m_TransitionOffset: 0 - m_ExitTime: 0.673913 - m_HasExitTime: 0 - m_HasFixedDuration: 1 - m_InterruptionSource: 0 - m_OrderedInterruption: 1 - m_CanTransitionToSelf: 1 --- !u!1102 &-206161041863570739 AnimatorState: serializedVersion: 6 @@ -190,56 +164,6 @@ AnimatorState: m_MirrorParameter: m_CycleOffsetParameter: m_TimeParameter: ---- !u!1101 &5118717445711135838 -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: Walk - m_EventTreshold: 0 - m_DstStateMachine: {fileID: 0} - m_DstState: {fileID: 8974360202922242318} - m_Solo: 0 - m_Mute: 0 - m_IsExit: 0 - serializedVersion: 3 - m_TransitionDuration: 0 - m_TransitionOffset: 0 - m_ExitTime: 0.42307693 - m_HasExitTime: 0 - m_HasFixedDuration: 1 - m_InterruptionSource: 0 - m_OrderedInterruption: 1 - m_CanTransitionToSelf: 1 ---- !u!1101 &5247037302422454140 -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: Attack - m_EventTreshold: 0 - m_DstStateMachine: {fileID: 0} - m_DstState: {fileID: 8693684011770968853} - 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!1102 &8693684011770968853 AnimatorState: serializedVersion: 6 @@ -276,8 +200,7 @@ AnimatorState: m_Name: Idle m_Speed: 1 m_CycleOffset: 0 - m_Transitions: - - {fileID: -2104665456298266282} + m_Transitions: [] m_StateMachineBehaviours: [] m_Position: {x: 50, y: 50, z: 0} m_IKOnFeet: 0 @@ -324,8 +247,7 @@ AnimatorStateMachine: m_State: {fileID: -206161041863570739} m_Position: {x: 570, y: 420, z: 0} m_ChildStateMachines: [] - m_AnyStateTransitions: - - {fileID: 5247037302422454140} + m_AnyStateTransitions: [] m_EntryTransitions: [] m_StateMachineTransitions: {} m_StateMachineBehaviours: [] diff --git a/Gameton-06/Assets/Gameton/Resources/Animation/Monster/Dragon/RedDragon/Attack.anim b/Gameton-06/Assets/Gameton/Resources/Animation/Monster/Dragon/RedDragon/Attack.anim index 41b9096a..2bb39f58 100644 --- a/Gameton-06/Assets/Gameton/Resources/Animation/Monster/Dragon/RedDragon/Attack.anim +++ b/Gameton-06/Assets/Gameton/Resources/Animation/Monster/Dragon/RedDragon/Attack.anim @@ -77,7 +77,7 @@ AnimationClip: outWeight: 0 - serializedVersion: 3 time: 0.5 - value: 4.267051e-22 + value: 3.3254636e-12 inSlope: Infinity outSlope: Infinity tangentMode: 103 @@ -191,7 +191,7 @@ AnimationClip: outWeight: 0 - serializedVersion: 3 time: 0.5 - value: 4.267051e-22 + value: 3.3254636e-12 inSlope: Infinity outSlope: Infinity tangentMode: 103 diff --git a/Gameton-06/Assets/Gameton/Resources/Animation/Monster/Dragon/RedDragon/RedDragon Animator Controller.controller b/Gameton-06/Assets/Gameton/Resources/Animation/Monster/Dragon/RedDragon/RedDragon Animator Controller.controller index fc111985..717a9a33 100644 --- a/Gameton-06/Assets/Gameton/Resources/Animation/Monster/Dragon/RedDragon/RedDragon Animator Controller.controller +++ b/Gameton-06/Assets/Gameton/Resources/Animation/Monster/Dragon/RedDragon/RedDragon Animator Controller.controller @@ -17,10 +17,9 @@ AnimatorStateMachine: m_Position: {x: 570, y: 110, z: 0} - serializedVersion: 1 m_State: {fileID: -6655501467506089146} - m_Position: {x: 320, y: 20, z: 0} + m_Position: {x: 460, y: 20, z: 0} m_ChildStateMachines: [] - m_AnyStateTransitions: - - {fileID: 5818298720468040081} + m_AnyStateTransitions: [] m_EntryTransitions: [] m_StateMachineTransitions: {} m_StateMachineBehaviours: [] @@ -39,8 +38,7 @@ AnimatorState: m_Name: Idle m_Speed: 1 m_CycleOffset: 0 - m_Transitions: - - {fileID: -3472015035896594382} + m_Transitions: [] m_StateMachineBehaviours: [] m_Position: {x: 50, y: 50, z: 0} m_IKOnFeet: 0 @@ -66,8 +64,7 @@ AnimatorState: m_Name: Attack m_Speed: 1 m_CycleOffset: 0 - m_Transitions: - - {fileID: -5713359683907962938} + m_Transitions: [] m_StateMachineBehaviours: [] m_Position: {x: 50, y: 50, z: 0} m_IKOnFeet: 0 @@ -83,56 +80,6 @@ AnimatorState: m_MirrorParameter: m_CycleOffsetParameter: m_TimeParameter: ---- !u!1101 &-5713359683907962938 -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: Walk - m_EventTreshold: 0 - m_DstStateMachine: {fileID: 0} - m_DstState: {fileID: -6701309803678357875} - m_Solo: 0 - m_Mute: 0 - m_IsExit: 0 - serializedVersion: 3 - m_TransitionDuration: 0.25 - m_TransitionOffset: 0 - m_ExitTime: 0.5 - m_HasExitTime: 1 - m_HasFixedDuration: 1 - m_InterruptionSource: 0 - m_OrderedInterruption: 1 - m_CanTransitionToSelf: 1 ---- !u!1101 &-3472015035896594382 -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: Walk - m_EventTreshold: 0 - m_DstStateMachine: {fileID: 0} - m_DstState: {fileID: 1882972568344343729} - m_Solo: 0 - m_Mute: 0 - m_IsExit: 0 - serializedVersion: 3 - m_TransitionDuration: 0 - m_TransitionOffset: 0 - m_ExitTime: 0.75 - m_HasExitTime: 0 - m_HasFixedDuration: 1 - m_InterruptionSource: 0 - m_OrderedInterruption: 1 - m_CanTransitionToSelf: 1 --- !u!91 &9100000 AnimatorController: m_ObjectHideFlags: 0 @@ -154,6 +101,12 @@ AnimatorController: m_DefaultInt: 0 m_DefaultBool: 0 m_Controller: {fileID: 9100000} + - m_Name: Idle + m_Type: 4 + m_DefaultFloat: 0 + m_DefaultInt: 0 + m_DefaultBool: 0 + m_Controller: {fileID: 9100000} m_AnimatorLayers: - serializedVersion: 5 m_Name: Base Layer @@ -177,8 +130,7 @@ AnimatorState: m_Name: Walk m_Speed: 1 m_CycleOffset: 0 - m_Transitions: - - {fileID: 5575444626708920409} + m_Transitions: [] m_StateMachineBehaviours: [] m_Position: {x: 50, y: 50, z: 0} m_IKOnFeet: 0 @@ -194,53 +146,3 @@ AnimatorState: m_MirrorParameter: m_CycleOffsetParameter: m_TimeParameter: ---- !u!1101 &5575444626708920409 -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: Walk - m_EventTreshold: 0 - m_DstStateMachine: {fileID: 0} - m_DstState: {fileID: -6701309803678357875} - m_Solo: 0 - m_Mute: 0 - m_IsExit: 0 - serializedVersion: 3 - m_TransitionDuration: 0 - m_TransitionOffset: 0 - m_ExitTime: 0.5 - m_HasExitTime: 0 - m_HasFixedDuration: 1 - m_InterruptionSource: 0 - m_OrderedInterruption: 1 - m_CanTransitionToSelf: 1 ---- !u!1101 &5818298720468040081 -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: Attack - m_EventTreshold: 0 - m_DstStateMachine: {fileID: 0} - m_DstState: {fileID: -6655501467506089146} - m_Solo: 0 - m_Mute: 0 - m_IsExit: 0 - serializedVersion: 3 - m_TransitionDuration: 0 - m_TransitionOffset: 0 - m_ExitTime: 0.75 - m_HasExitTime: 1 - m_HasFixedDuration: 1 - m_InterruptionSource: 0 - m_OrderedInterruption: 1 - m_CanTransitionToSelf: 1 diff --git a/Gameton-06/Assets/Gameton/Scenes/Personal Scenes/dev_mingu/Ingame.unity b/Gameton-06/Assets/Gameton/Scenes/Personal Scenes/dev_mingu/Ingame.unity index 700dd72f..70caa9cf 100644 --- a/Gameton-06/Assets/Gameton/Scenes/Personal Scenes/dev_mingu/Ingame.unity +++ b/Gameton-06/Assets/Gameton/Scenes/Personal Scenes/dev_mingu/Ingame.unity @@ -13507,8 +13507,9 @@ GameObject: m_Component: - component: {fileID: 336376026} - component: {fileID: 336376025} + - component: {fileID: 336376027} m_Layer: 3 - m_Name: Collider + m_Name: Eyesight m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 @@ -13543,12 +13544,12 @@ CircleCollider2D: m_CallbackLayers: serializedVersion: 2 m_Bits: 4294967295 - m_IsTrigger: 0 + m_IsTrigger: 1 m_UsedByEffector: 0 m_UsedByComposite: 0 m_Offset: {x: 0, y: 0} serializedVersion: 2 - m_Radius: 0.5 + m_Radius: 1 --- !u!4 &336376026 Transform: m_ObjectHideFlags: 0 @@ -13564,6 +13565,19 @@ Transform: m_Children: [] m_Father: {fileID: 585265470} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &336376027 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 336376024} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 0eeefb865ea9d4749bbb4de3d1100f3e, type: 3} + m_Name: + m_EditorClassIdentifier: + _monsterBase: {fileID: 585265463} --- !u!213 &345793892 Sprite: m_ObjectHideFlags: 0 @@ -22338,7 +22352,7 @@ Animator: m_GameObject: {fileID: 585265462} m_Enabled: 1 m_Avatar: {fileID: 0} - m_Controller: {fileID: 9100000, guid: fcd7ead41abcd7f458edb6a3cdfdd564, type: 2} + m_Controller: {fileID: 22100000, guid: 651e27074ab33cf47886fbe008de917d, type: 2} m_CullingMode: 0 m_UpdateMode: 0 m_ApplyRootMotion: 0 @@ -22518,6 +22532,7 @@ Transform: m_Children: - {fileID: 1574532559} - {fileID: 336376026} + - {fileID: 2003670963} m_Father: {fileID: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!114 &589876486 @@ -71855,6 +71870,87 @@ Sprite: m_PhysicsShape: [] m_Bones: [] m_SpriteID: +--- !u!1 &2003670962 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 2003670963} + - component: {fileID: 2003670964} + - component: {fileID: 2003670965} + m_Layer: 3 + m_Name: AttackRange + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &2003670963 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2003670962} + serializedVersion: 2 + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 9, y: 1, z: 11} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 585265470} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!58 &2003670964 +CircleCollider2D: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2003670962} + m_Enabled: 1 + m_Density: 1 + m_Material: {fileID: 0} + m_IncludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_ExcludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_LayerOverridePriority: 0 + m_ForceSendLayers: + serializedVersion: 2 + m_Bits: 4294967295 + m_ForceReceiveLayers: + serializedVersion: 2 + m_Bits: 4294967295 + m_ContactCaptureLayers: + serializedVersion: 2 + m_Bits: 4294967295 + m_CallbackLayers: + serializedVersion: 2 + m_Bits: 4294967295 + m_IsTrigger: 1 + m_UsedByEffector: 0 + m_UsedByComposite: 0 + m_Offset: {x: 0, y: 0} + serializedVersion: 2 + m_Radius: 0.5 +--- !u!114 &2003670965 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2003670962} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 0913d8f50c531ce4585705c1366b8351, type: 3} + m_Name: + m_EditorClassIdentifier: + _monsterBase: {fileID: 585265463} --- !u!213 &2010724901 Sprite: m_ObjectHideFlags: 0 @@ -75135,6 +75231,63 @@ Sprite: m_PhysicsShape: [] m_Bones: [] m_SpriteID: +--- !u!1001 &2131259786 +PrefabInstance: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_Modification: + serializedVersion: 3 + m_TransformParent: {fileID: 0} + m_Modifications: + - target: {fileID: 1762751622269960499, guid: c28b253474f28e54ebeca15f342c2482, type: 3} + propertyPath: m_Name + value: SpriteEffect + objectReference: {fileID: 0} + - target: {fileID: 1762751622269960500, guid: c28b253474f28e54ebeca15f342c2482, type: 3} + propertyPath: m_LocalPosition.x + value: -4 + objectReference: {fileID: 0} + - target: {fileID: 1762751622269960500, guid: c28b253474f28e54ebeca15f342c2482, type: 3} + propertyPath: m_LocalPosition.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 1762751622269960500, guid: c28b253474f28e54ebeca15f342c2482, type: 3} + propertyPath: m_LocalPosition.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 1762751622269960500, guid: c28b253474f28e54ebeca15f342c2482, type: 3} + propertyPath: m_LocalRotation.w + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 1762751622269960500, guid: c28b253474f28e54ebeca15f342c2482, type: 3} + propertyPath: m_LocalRotation.x + value: -0 + objectReference: {fileID: 0} + - target: {fileID: 1762751622269960500, guid: c28b253474f28e54ebeca15f342c2482, type: 3} + propertyPath: m_LocalRotation.y + value: -0 + objectReference: {fileID: 0} + - target: {fileID: 1762751622269960500, guid: c28b253474f28e54ebeca15f342c2482, type: 3} + propertyPath: m_LocalRotation.z + value: -0 + objectReference: {fileID: 0} + - target: {fileID: 1762751622269960500, guid: c28b253474f28e54ebeca15f342c2482, type: 3} + propertyPath: m_LocalEulerAnglesHint.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 1762751622269960500, guid: c28b253474f28e54ebeca15f342c2482, type: 3} + propertyPath: m_LocalEulerAnglesHint.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 1762751622269960500, guid: c28b253474f28e54ebeca15f342c2482, type: 3} + propertyPath: m_LocalEulerAnglesHint.z + value: 0 + objectReference: {fileID: 0} + m_RemovedComponents: [] + m_RemovedGameObjects: [] + m_AddedGameObjects: [] + m_AddedComponents: [] + m_SourcePrefab: {fileID: 100100000, guid: c28b253474f28e54ebeca15f342c2482, type: 3} --- !u!114 &2132150059 MonoBehaviour: m_ObjectHideFlags: 0 @@ -75979,3 +76132,4 @@ SceneRoots: - {fileID: 1494770074} - {fileID: 957750499} - {fileID: 585265470} + - {fileID: 2131259786} diff --git a/Gameton-06/Assets/Gameton/Scripts/Monster/Attack.cs b/Gameton-06/Assets/Gameton/Scripts/Monster/Attack.cs new file mode 100644 index 00000000..271f48d2 --- /dev/null +++ b/Gameton-06/Assets/Gameton/Scripts/Monster/Attack.cs @@ -0,0 +1,20 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace TON +{ + public class Attack : MonoBehaviour + { + [SerializeField] + private MonsterBase _monsterBase; + + private void OnTriggerEnter2D(Collider2D other) + { + if (other.CompareTag("Player")) + { + _monsterBase.Attack(other.gameObject); + } + } + } +} diff --git a/Gameton-06/Assets/Gameton/Scripts/Monster/Attack.cs.meta b/Gameton-06/Assets/Gameton/Scripts/Monster/Attack.cs.meta new file mode 100644 index 00000000..46009945 --- /dev/null +++ b/Gameton-06/Assets/Gameton/Scripts/Monster/Attack.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 0913d8f50c531ce4585705c1366b8351 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Gameton-06/Assets/Gameton/Scripts/Monster/Eyesight.cs b/Gameton-06/Assets/Gameton/Scripts/Monster/Eyesight.cs new file mode 100644 index 00000000..f7761782 --- /dev/null +++ b/Gameton-06/Assets/Gameton/Scripts/Monster/Eyesight.cs @@ -0,0 +1,50 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace TON +{ + public class Eyesight : MonoBehaviour + { + [SerializeField] + private MonsterBase _monsterBase; + // private bool _isDetect; + + + private void OnTriggerEnter2D(Collider2D other) + { + if (other.CompareTag("Player")) + { + // TODO : 플레이어 감지하면 따라가기 + + _monsterBase.IsDetect = true; + Debug.Log("감지됨"); + + if (_monsterBase.IsDetect) + { + _monsterBase.Detect(other.gameObject); + + // _monsterBase.IsWalking = false; + } + } + } + + // 단순 플레이어 태그 기준 따라가는 코드 + private void FixedUpdate() + { + // 타겟의 위치에서 내 현제 위치를 뺌 + // UnityEngine.Vector2 direction = target.transform.position - transform.position; + + // 방향 * 속도 * 시간간격 + // transform.Translate(direction.normalized * speed * Time.deltaTime); + // animator.SetBool("Iidle", true); + + } + + private void OnTriggerExit2D(Collider2D other) + { + _monsterBase.IsDetect = false; + _monsterBase.IsWalking = true; + } + } +} diff --git a/Gameton-06/Assets/Gameton/Scripts/Monster/Eyesight.cs.meta b/Gameton-06/Assets/Gameton/Scripts/Monster/Eyesight.cs.meta new file mode 100644 index 00000000..eab48d4b --- /dev/null +++ b/Gameton-06/Assets/Gameton/Scripts/Monster/Eyesight.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 0eeefb865ea9d4749bbb4de3d1100f3e +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Gameton-06/Assets/Gameton/Scripts/Monster/MonsterBase.cs b/Gameton-06/Assets/Gameton/Scripts/Monster/MonsterBase.cs index d23627aa..8bf60ef9 100644 --- a/Gameton-06/Assets/Gameton/Scripts/Monster/MonsterBase.cs +++ b/Gameton-06/Assets/Gameton/Scripts/Monster/MonsterBase.cs @@ -1,5 +1,6 @@ using System; using System.Collections; +using System.Collections.Concurrent; using System.Collections.Generic; using System.IO; using System.Numerics; @@ -45,7 +46,26 @@ namespace TON private Collider2D _collider; public float defencePower; + + // 애니메이션 관련 선언들 + private string currentState; + const string AniIdle = "Idle"; + const string AniWalk = "Walk"; + const string AniAttack = "Attack"; + + public bool IsWalking + { + get => _isWalking; + set => _isWalking = value; + } + + public bool IsDetect + { + get => _isDetect; + set => _isDetect = value; + } + public Dictionary dicMonster = new Dictionary(); // 초기화 [System.Serializable] @@ -62,12 +82,13 @@ namespace TON // Start is called before the first frame update void Start() { + ReadCSV(); // dicMonster 사용 예시 if (dicMonster.ContainsKey("1")) // 키 존재 확인 { - Debug.Log(dicMonster["1"].name); + // Debug.Log(dicMonster["1"].name); } _currentTime = Time.realtimeSinceStartup; @@ -83,6 +104,13 @@ namespace TON defencePower = 10f; } + void ChangeAnimationState(string newState) + { + if(currentState == newState) return; + + _animator.Play(newState); + } + private void ReadCSV() { TextAsset csvFile = Resources.Load("Monster"); @@ -134,18 +162,17 @@ namespace TON // Update is called once per frame void Update() { - // todo : 타겟 감지 >> 몬스터의 원형 시야 안에 플레이어가 충돌했는지 여부 - // todo : 충돌 했으면 attack 전환 (바로 그냥 공격하게 따라가지 말고) // todo : 시야를 벗어났으면 idle 전환 if (_isWalking) { // walking 상태에서 walkingTime을 초과할 경우 idle 애니메이션 재생 transform.Translate(_direction * speed * Time.deltaTime); - + if (Time.realtimeSinceStartup - _currentTime >= walkingTime) { _isWalking = false; + ChangeAnimationState(AniIdle); _currentTime = Time.realtimeSinceStartup; } } @@ -164,22 +191,13 @@ namespace TON } _isWalking = true; + ChangeAnimationState(AniWalk); } } - _animator.SetBool("Walk", _isWalking); // 걷기 애니메이션 - } - - // 단순 플레이어 태그 기준 따라가는 코드 - private void FixedUpdate() - { - // 타겟의 위치에서 내 현제 위치를 뺌 - // UnityEngine.Vector2 direction = target.transform.position - transform.position; - - // 방향 * 속도 * 시간간격 - // transform.Translate(direction.normalized * speed * Time.deltaTime); - // animator.SetBool("Iidle", true); - + // 걷기 애니메이션으로 변경 + // ChangeAnimationState(AniWalk); + // _animator.SetBool("Walk", _isWalking); // 걷기 애니메이션 } public void ApplyDamage(float damage) @@ -203,8 +221,10 @@ namespace TON } } - void MonsterAttack(GameObject player) + public void Attack(GameObject player) { + ChangeAnimationState(AniAttack); + // _animator.Play("Attack"); _animator.SetTrigger("Attack"); // 임시 반영 수정 예정 DamageCalculator damageCalculator = new DamageCalculator(); @@ -218,27 +238,32 @@ namespace TON Debug.Log($" 몬스터 공격! 최종 데미지: {damage}"); } - - private void OnCollisionEnter2D(Collision2D other) + + public void Detect(GameObject target) { - if (other.collider.CompareTag("Player")) + if (target == null) return; // 타겟이 null이면 함수 종료 + + // 타겟의 위치에서 내 현재 위치를 빼서 방향 벡터를 구함 + UnityEngine.Vector2 direction = target.transform.position - transform.position; + + // 방향 벡터의 크기가 0이 아니면 (즉, 타겟이 존재하면) 이동 + if (direction.magnitude > 0) { - _isDetect = true; - _animator.SetTrigger("Attack"); - if (_isDetect) - { - _isWalking = false; - } - MonsterAttack(other.gameObject); // 플레이어에게 공격 - Debug.Log("감지됨"); + // 방향 벡터를 정규화하여 길이를 1로 만들고, 속도를 곱하여 이동 + transform.Translate(direction.normalized * speed * Time.deltaTime); + + // 걷기 애니메이션 재생 + _animator.SetBool("Walk", true); + + // 타겟 방향으로 몬스터 이미지 뒤집기 + _spriteRenderer.flipX = direction.x < 0; + } + else + { + // 타겟과 몬스터가 같은 위치에 있으면 걷기 애니메이션 중지 + _animator.SetBool("Walk", false); } } - - private void OnCollisionExit2D(Collision2D other) - { - _isDetect = false; - - _isWalking = true; - } } + } diff --git a/Gameton-06/Assets/PixelFantasy/PixelMonsters/BossPack1/Dragon/GreenDragon.asset b/Gameton-06/Assets/PixelFantasy/PixelMonsters/BossPack1/Dragon/GreenDragon.asset index c67e20c4..edafac04 100644 --- a/Gameton-06/Assets/PixelFantasy/PixelMonsters/BossPack1/Dragon/GreenDragon.asset +++ b/Gameton-06/Assets/PixelFantasy/PixelMonsters/BossPack1/Dragon/GreenDragon.asset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:9ff79dfddf380e47d62577e58ea20962a466f7ebe7ac1460f631f9015782d3c3 -size 6361 +oid sha256:4a41c1eccaeaeab9f2e43013c2e089754fdebbfe2348db34a7d27f67c88f678e +size 6216 diff --git a/Gameton-06/Assets/PixelFantasy/PixelMonsters/Common/Prefabs/Canvas.prefab b/Gameton-06/Assets/PixelFantasy/PixelMonsters/Common/Prefabs/Canvas.prefab index 190d24de..2f3dca92 100644 --- a/Gameton-06/Assets/PixelFantasy/PixelMonsters/Common/Prefabs/Canvas.prefab +++ b/Gameton-06/Assets/PixelFantasy/PixelMonsters/Common/Prefabs/Canvas.prefab @@ -32,7 +32,6 @@ RectTransform: m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 8589673606415132978} - m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 1, y: 1} @@ -131,7 +130,6 @@ RectTransform: - {fileID: 8589673606200230253} - {fileID: 8589673608165470554} m_Father: {fileID: 8589673608144055963} - m_RootOrder: 1 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0.5, y: 0} m_AnchorMax: {x: 0.5, y: 0} @@ -265,7 +263,6 @@ RectTransform: m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 8589673608144055963} - m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0.5} m_AnchorMax: {x: 1, y: 0.5} @@ -364,7 +361,6 @@ RectTransform: - {fileID: 8589673607930580844} - {fileID: 8589673606415132978} m_Father: {fileID: 0} - m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 0} @@ -390,6 +386,7 @@ Canvas: m_SortingBucketNormalizedSize: 0 m_VertexColorAlwaysGammaSpace: 0 m_AdditionalShaderChannelsFlag: 0 + m_UpdateRectTransformForStandalone: 0 m_SortingLayerID: 0 m_SortingOrder: 0 m_TargetDisplay: 0 @@ -432,7 +429,7 @@ MonoBehaviour: m_BlockingObjects: 0 m_BlockingMask: serializedVersion: 2 - m_Bits: 4294967295 + m_Bits: 127 --- !u!1 &8589673608165470555 GameObject: m_ObjectHideFlags: 0 @@ -465,7 +462,6 @@ RectTransform: m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 8589673606415132978} - m_RootOrder: 1 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 1, y: 1} diff --git a/Gameton-06/ProjectSettings/Physics2DSettings.asset b/Gameton-06/ProjectSettings/Physics2DSettings.asset index 7545903d..a8777a18 100644 --- a/Gameton-06/ProjectSettings/Physics2DSettings.asset +++ b/Gameton-06/ProjectSettings/Physics2DSettings.asset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:f5c002e55b63e91280e069d9029607b2fd7d0e4fa2a02d6e4df916495cef9328 +oid sha256:531861618163b01648a075414f6e864506ad8fe0a0d4d0096aa1fbbfcd3937dc size 1635