diff --git a/Gameton-06/Assets/Gameton/Resources/Player/TON.Player_B.prefab b/Gameton-06/Assets/Gameton/Resources/Player/TON.Player_B.prefab index baa714a5..9992fc44 100644 --- a/Gameton-06/Assets/Gameton/Resources/Player/TON.Player_B.prefab +++ b/Gameton-06/Assets/Gameton/Resources/Player/TON.Player_B.prefab @@ -247,5 +247,6 @@ MonoBehaviour: maxSP: 0 speed: 3 jumpForce: 8 + firePoint: {fileID: 3571909985532505043} animator: {fileID: 0} rb: {fileID: 4986202531950816680} diff --git a/Gameton-06/Assets/Gameton/Resources/Player/TON.Player_W.prefab b/Gameton-06/Assets/Gameton/Resources/Player/TON.Player_W.prefab index 44b29a14..79e1b5cc 100644 --- a/Gameton-06/Assets/Gameton/Resources/Player/TON.Player_W.prefab +++ b/Gameton-06/Assets/Gameton/Resources/Player/TON.Player_W.prefab @@ -216,6 +216,7 @@ MonoBehaviour: maxSP: 0 speed: 3 jumpForce: 8 + firePoint: {fileID: 3204799031628172313} animator: {fileID: 0} rb: {fileID: 4986202531950816680} --- !u!1 &8790121653688035716 diff --git a/Gameton-06/Assets/Gameton/Resources/UI/Prefabs/UI.ControllerUI.prefab b/Gameton-06/Assets/Gameton/Resources/UI/Prefabs/UI.ControllerUI.prefab index af039d36..19cc79bf 100644 --- a/Gameton-06/Assets/Gameton/Resources/UI/Prefabs/UI.ControllerUI.prefab +++ b/Gameton-06/Assets/Gameton/Resources/UI/Prefabs/UI.ControllerUI.prefab @@ -764,6 +764,22 @@ PrefabInstance: propertyPath: m_Name value: Skill Button objectReference: {fileID: 0} + - target: {fileID: 8637807277690663409, guid: f023329ca96ab444ca7c60781e310d59, type: 3} + propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[0].m_Mode + value: 5 + objectReference: {fileID: 0} + - target: {fileID: 8637807277690663409, guid: f023329ca96ab444ca7c60781e310d59, type: 3} + propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[0].m_Target + value: + objectReference: {fileID: -4577297331876422106} + - target: {fileID: 8637807277690663409, guid: f023329ca96ab444ca7c60781e310d59, type: 3} + propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[0].m_MethodName + value: OnClickSkillButton + objectReference: {fileID: 0} + - target: {fileID: 8637807277690663409, guid: f023329ca96ab444ca7c60781e310d59, type: 3} + propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[0].m_Arguments.m_StringArgument + value: DarknessBall + objectReference: {fileID: 0} m_RemovedComponents: [] m_RemovedGameObjects: [] m_AddedGameObjects: [] @@ -1029,6 +1045,22 @@ PrefabInstance: propertyPath: m_Name value: Skill Button objectReference: {fileID: 0} + - target: {fileID: 8637807277690663409, guid: f023329ca96ab444ca7c60781e310d59, type: 3} + propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[0].m_Mode + value: 5 + objectReference: {fileID: 0} + - target: {fileID: 8637807277690663409, guid: f023329ca96ab444ca7c60781e310d59, type: 3} + propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[0].m_Target + value: + objectReference: {fileID: -4577297331876422106} + - target: {fileID: 8637807277690663409, guid: f023329ca96ab444ca7c60781e310d59, type: 3} + propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[0].m_MethodName + value: OnClickSkillButton + objectReference: {fileID: 0} + - target: {fileID: 8637807277690663409, guid: f023329ca96ab444ca7c60781e310d59, type: 3} + propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[0].m_Arguments.m_StringArgument + value: FireBall + objectReference: {fileID: 0} m_RemovedComponents: [] m_RemovedGameObjects: [] m_AddedGameObjects: [] @@ -1135,6 +1167,22 @@ PrefabInstance: propertyPath: m_Name value: Skill Button objectReference: {fileID: 0} + - target: {fileID: 8637807277690663409, guid: f023329ca96ab444ca7c60781e310d59, type: 3} + propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[0].m_Mode + value: 5 + objectReference: {fileID: 0} + - target: {fileID: 8637807277690663409, guid: f023329ca96ab444ca7c60781e310d59, type: 3} + propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[0].m_Target + value: + objectReference: {fileID: -4577297331876422106} + - target: {fileID: 8637807277690663409, guid: f023329ca96ab444ca7c60781e310d59, type: 3} + propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[0].m_MethodName + value: OnClickSkillButton + objectReference: {fileID: 0} + - target: {fileID: 8637807277690663409, guid: f023329ca96ab444ca7c60781e310d59, type: 3} + propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[0].m_Arguments.m_StringArgument + value: IceBall + objectReference: {fileID: 0} m_RemovedComponents: [] m_RemovedGameObjects: [] m_AddedGameObjects: [] diff --git a/Gameton-06/Assets/Gameton/Scripts/Character/CharacterBase.cs b/Gameton-06/Assets/Gameton/Scripts/Character/CharacterBase.cs index 3310878b..853d27f4 100644 --- a/Gameton-06/Assets/Gameton/Scripts/Character/CharacterBase.cs +++ b/Gameton-06/Assets/Gameton/Scripts/Character/CharacterBase.cs @@ -16,6 +16,10 @@ namespace TON public float speed; public float jumpForce = 5f; // 점프 힘 private bool isGrounded = true; // 플레이어가 바닥에 있는지 여부를 판단 + private float lastDirection = 1f; // 기본적으로 오른쪽(1) 바라보는 상태 + + + public Transform firePoint; // 스킬 발사 위치 public Animator animator; @@ -70,6 +74,12 @@ namespace TON // 캐릭터가 양방향으로 이동시에 알맞은 방향을 바라보도록 적용 private void Turn(float direction) { + + if (direction != 0) + { + lastDirection = Mathf.Sign(direction); // 마지막 이동 방향 저장 + } + var scale = transform.localScale; scale.x = Mathf.Sign(direction) * Mathf.Abs(scale.x); @@ -105,6 +115,27 @@ namespace TON animator.Play("Default Attack"); } + public void SkillAttack(string skillName) + { + animator.Play("Skill Attack"); + + // 총알 생성 + GameObject skill = ObjectPoolManager.Instance.GetEffect(skillName); + + // skill.transform.SetParent(firePoint); + skill.transform.SetPositionAndRotation(firePoint.position, firePoint.rotation); + + + // 🔥 총알 방향 반전 + var bulletScale = skill.transform.localScale; + bulletScale.x = Mathf.Abs(bulletScale.x) * lastDirection; + skill.transform.localScale = bulletScale; + + // 총알 이동 방향 설정 + Rigidbody2D skillRb = skill.GetComponent(); + skillRb.velocity = new Vector2(lastDirection * 5f, 0f); + } + public void ApplyDamage(float damage) { diff --git a/Gameton-06/Assets/Gameton/Scripts/Character/Skill.meta b/Gameton-06/Assets/Gameton/Scripts/Character/Skill.meta new file mode 100644 index 00000000..62bcfa31 --- /dev/null +++ b/Gameton-06/Assets/Gameton/Scripts/Character/Skill.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: dab915d74078caf41bf985d45e8dbb81 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Gameton-06/Assets/Gameton/Scripts/Character/Skill/DarknessBall.cs b/Gameton-06/Assets/Gameton/Scripts/Character/Skill/DarknessBall.cs new file mode 100644 index 00000000..03467d29 --- /dev/null +++ b/Gameton-06/Assets/Gameton/Scripts/Character/Skill/DarknessBall.cs @@ -0,0 +1,35 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace TON +{ + public class DarknessBall : PoolAble + { + private float elapsedTime; // 경과 시간 저장 변수 + + void OnEnable() + { + elapsedTime = 0f; // 오브젝트가 활성화될 때 초기화 + } + + void Update() + { + elapsedTime += Time.deltaTime; // 경과 시간 누적 + + // 2초가 지나면 오브젝트 풀에 반환 + if (elapsedTime >= 2f) + { + ReleaseObject(); + } + } + + private void OnTriggerEnter2D(Collider2D collision) + { + if (collision.CompareTag("Monster")) // 적과 충돌 시 제거 + { + ReleaseObject(); + } + } + } +} diff --git a/Gameton-06/Assets/Gameton/Scripts/Character/Skill/DarknessBall.cs.meta b/Gameton-06/Assets/Gameton/Scripts/Character/Skill/DarknessBall.cs.meta new file mode 100644 index 00000000..da5a5998 --- /dev/null +++ b/Gameton-06/Assets/Gameton/Scripts/Character/Skill/DarknessBall.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 46951a2e33fdd5a409f1579de9b7acfa +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Gameton-06/Assets/Gameton/Scripts/Character/Skill/FireBall.cs b/Gameton-06/Assets/Gameton/Scripts/Character/Skill/FireBall.cs new file mode 100644 index 00000000..eed2b161 --- /dev/null +++ b/Gameton-06/Assets/Gameton/Scripts/Character/Skill/FireBall.cs @@ -0,0 +1,37 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace TON +{ + public class FireBall : PoolAble + { + + private float elapsedTime; // 경과 시간 저장 변수 + + void OnEnable() + { + elapsedTime = 0f; // 오브젝트가 활성화될 때 초기화 + } + + void Update() + { + elapsedTime += Time.deltaTime; // 경과 시간 누적 + + // 2초가 지나면 오브젝트 풀에 반환 + if (elapsedTime >= 2f) + { + ReleaseObject(); + } + } + + private void OnTriggerEnter2D(Collider2D collision) + { + if (collision.CompareTag("Monster")) // 적과 충돌 시 제거 + { + ReleaseObject(); + } + } + } +} diff --git a/Gameton-06/Assets/Gameton/Scripts/Character/Skill/FireBall.cs.meta b/Gameton-06/Assets/Gameton/Scripts/Character/Skill/FireBall.cs.meta new file mode 100644 index 00000000..8795f6d1 --- /dev/null +++ b/Gameton-06/Assets/Gameton/Scripts/Character/Skill/FireBall.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 26dd04ed34a3c4042bfbe12766af2d60 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Gameton-06/Assets/Gameton/Scripts/Character/Skill/IceBall.cs b/Gameton-06/Assets/Gameton/Scripts/Character/Skill/IceBall.cs new file mode 100644 index 00000000..1295645a --- /dev/null +++ b/Gameton-06/Assets/Gameton/Scripts/Character/Skill/IceBall.cs @@ -0,0 +1,35 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace TON +{ + public class IceBall : PoolAble + { + private float elapsedTime; // 경과 시간 저장 변수 + + void OnEnable() + { + elapsedTime = 0f; // 오브젝트가 활성화될 때 초기화 + } + + void Update() + { + elapsedTime += Time.deltaTime; // 경과 시간 누적 + + // 2초가 지나면 오브젝트 풀에 반환 + if (elapsedTime >= 2f) + { + ReleaseObject(); + } + } + + private void OnTriggerEnter2D(Collider2D collision) + { + if (collision.CompareTag("Monster")) // 적과 충돌 시 제거 + { + ReleaseObject(); + } + } + } +} diff --git a/Gameton-06/Assets/Gameton/Scripts/Character/Skill/IceBall.cs.meta b/Gameton-06/Assets/Gameton/Scripts/Character/Skill/IceBall.cs.meta new file mode 100644 index 00000000..a5caf122 --- /dev/null +++ b/Gameton-06/Assets/Gameton/Scripts/Character/Skill/IceBall.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: aa5541b68c81e2347960b5eeaf373bf4 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Gameton-06/Assets/Gameton/Scripts/UI/ControllerUI.cs b/Gameton-06/Assets/Gameton/Scripts/UI/ControllerUI.cs index 5df9c4c1..92c8e07c 100644 --- a/Gameton-06/Assets/Gameton/Scripts/UI/ControllerUI.cs +++ b/Gameton-06/Assets/Gameton/Scripts/UI/ControllerUI.cs @@ -23,5 +23,10 @@ namespace TON { linkedCharactor.Attack(); } + + public void OnClickSkillButton(string skill) + { + linkedCharactor.SkillAttack(skill); + } } }