캐릭터 스킬 공격 투사체 적용
This commit is contained in:
@@ -247,5 +247,6 @@ MonoBehaviour:
|
|||||||
maxSP: 0
|
maxSP: 0
|
||||||
speed: 3
|
speed: 3
|
||||||
jumpForce: 8
|
jumpForce: 8
|
||||||
|
firePoint: {fileID: 3571909985532505043}
|
||||||
animator: {fileID: 0}
|
animator: {fileID: 0}
|
||||||
rb: {fileID: 4986202531950816680}
|
rb: {fileID: 4986202531950816680}
|
||||||
|
|||||||
@@ -216,6 +216,7 @@ MonoBehaviour:
|
|||||||
maxSP: 0
|
maxSP: 0
|
||||||
speed: 3
|
speed: 3
|
||||||
jumpForce: 8
|
jumpForce: 8
|
||||||
|
firePoint: {fileID: 3204799031628172313}
|
||||||
animator: {fileID: 0}
|
animator: {fileID: 0}
|
||||||
rb: {fileID: 4986202531950816680}
|
rb: {fileID: 4986202531950816680}
|
||||||
--- !u!1 &8790121653688035716
|
--- !u!1 &8790121653688035716
|
||||||
|
|||||||
@@ -764,6 +764,22 @@ PrefabInstance:
|
|||||||
propertyPath: m_Name
|
propertyPath: m_Name
|
||||||
value: Skill Button
|
value: Skill Button
|
||||||
objectReference: {fileID: 0}
|
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_RemovedComponents: []
|
||||||
m_RemovedGameObjects: []
|
m_RemovedGameObjects: []
|
||||||
m_AddedGameObjects: []
|
m_AddedGameObjects: []
|
||||||
@@ -1029,6 +1045,22 @@ PrefabInstance:
|
|||||||
propertyPath: m_Name
|
propertyPath: m_Name
|
||||||
value: Skill Button
|
value: Skill Button
|
||||||
objectReference: {fileID: 0}
|
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_RemovedComponents: []
|
||||||
m_RemovedGameObjects: []
|
m_RemovedGameObjects: []
|
||||||
m_AddedGameObjects: []
|
m_AddedGameObjects: []
|
||||||
@@ -1135,6 +1167,22 @@ PrefabInstance:
|
|||||||
propertyPath: m_Name
|
propertyPath: m_Name
|
||||||
value: Skill Button
|
value: Skill Button
|
||||||
objectReference: {fileID: 0}
|
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_RemovedComponents: []
|
||||||
m_RemovedGameObjects: []
|
m_RemovedGameObjects: []
|
||||||
m_AddedGameObjects: []
|
m_AddedGameObjects: []
|
||||||
|
|||||||
@@ -16,6 +16,10 @@ namespace TON
|
|||||||
public float speed;
|
public float speed;
|
||||||
public float jumpForce = 5f; // 점프 힘
|
public float jumpForce = 5f; // 점프 힘
|
||||||
private bool isGrounded = true; // 플레이어가 바닥에 있는지 여부를 판단
|
private bool isGrounded = true; // 플레이어가 바닥에 있는지 여부를 판단
|
||||||
|
private float lastDirection = 1f; // 기본적으로 오른쪽(1) 바라보는 상태
|
||||||
|
|
||||||
|
|
||||||
|
public Transform firePoint; // 스킬 발사 위치
|
||||||
|
|
||||||
public Animator animator;
|
public Animator animator;
|
||||||
|
|
||||||
@@ -70,6 +74,12 @@ namespace TON
|
|||||||
// 캐릭터가 양방향으로 이동시에 알맞은 방향을 바라보도록 적용
|
// 캐릭터가 양방향으로 이동시에 알맞은 방향을 바라보도록 적용
|
||||||
private void Turn(float direction)
|
private void Turn(float direction)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
if (direction != 0)
|
||||||
|
{
|
||||||
|
lastDirection = Mathf.Sign(direction); // 마지막 이동 방향 저장
|
||||||
|
}
|
||||||
|
|
||||||
var scale = transform.localScale;
|
var scale = transform.localScale;
|
||||||
|
|
||||||
scale.x = Mathf.Sign(direction) * Mathf.Abs(scale.x);
|
scale.x = Mathf.Sign(direction) * Mathf.Abs(scale.x);
|
||||||
@@ -105,6 +115,27 @@ namespace TON
|
|||||||
animator.Play("Default Attack");
|
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<Rigidbody2D>();
|
||||||
|
skillRb.velocity = new Vector2(lastDirection * 5f, 0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public void ApplyDamage(float damage)
|
public void ApplyDamage(float damage)
|
||||||
{
|
{
|
||||||
|
|||||||
8
Gameton-06/Assets/Gameton/Scripts/Character/Skill.meta
Normal file
8
Gameton-06/Assets/Gameton/Scripts/Character/Skill.meta
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: dab915d74078caf41bf985d45e8dbb81
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 46951a2e33fdd5a409f1579de9b7acfa
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 26dd04ed34a3c4042bfbe12766af2d60
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
35
Gameton-06/Assets/Gameton/Scripts/Character/Skill/IceBall.cs
Normal file
35
Gameton-06/Assets/Gameton/Scripts/Character/Skill/IceBall.cs
Normal file
@@ -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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: aa5541b68c81e2347960b5eeaf373bf4
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -23,5 +23,10 @@ namespace TON
|
|||||||
{
|
{
|
||||||
linkedCharactor.Attack();
|
linkedCharactor.Attack();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void OnClickSkillButton(string skill)
|
||||||
|
{
|
||||||
|
linkedCharactor.SkillAttack(skill);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user