스킬 발사체에 데미지 적용하는 로직 추가

This commit is contained in:
aube.lee
2025-02-05 00:06:25 +09:00
parent 8600811a47
commit 6f779c21a0
8 changed files with 91 additions and 2 deletions

View File

@@ -0,0 +1,16 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace TON
{
public class damageTest : MonoBehaviour, IDamage
{
public float hp = 1000;
public void ApplyDamage(float damage)
{
hp -= damage;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 1c8ade3f04687f649901ed5d76803892
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -9,9 +9,15 @@ namespace TON
private float elapsedTime; // 경과 시간 저장 변수 private float elapsedTime; // 경과 시간 저장 변수
public float destoryTime = 2f; public float destoryTime = 2f;
public float attackPower;
public float damage;
public string id = "K0003";
void OnEnable() void OnEnable()
{ {
elapsedTime = 0f; // 오브젝트가 활성화될 때 초기화 elapsedTime = 0f; // 오브젝트가 활성화될 때 초기화
damage = SkillDataManager.Singleton.GetSkillData(id).damage;
attackPower = PlayerDataManager.Singleton.player.attackPower;
} }
void Update() void Update()
@@ -29,7 +35,7 @@ namespace TON
{ {
if (collision.CompareTag("Monster")) // 적과 충돌 시 제거 if (collision.CompareTag("Monster")) // 적과 충돌 시 제거
{ {
// collision.gameObject.Damage(); collision.GetComponent<IDamage>().ApplyDamage(damage * attackPower);
ReleaseObject(); ReleaseObject();
} }
} }

View File

@@ -10,9 +10,15 @@ namespace TON
private float elapsedTime; // 경과 시간 저장 변수 private float elapsedTime; // 경과 시간 저장 변수
public float destoryTime = 2f; public float destoryTime = 2f;
public float attackPower;
public float damage;
public string id = "K0001";
void OnEnable() void OnEnable()
{ {
elapsedTime = 0f; // 오브젝트가 활성화될 때 초기화 elapsedTime = 0f; // 오브젝트가 활성화될 때 초기화
damage = SkillDataManager.Singleton.GetSkillData(id).damage;
attackPower = PlayerDataManager.Singleton.player.attackPower;
} }
void Update() void Update()
@@ -30,6 +36,7 @@ namespace TON
{ {
if (collision.CompareTag("Monster")) // 적과 충돌 시 제거 if (collision.CompareTag("Monster")) // 적과 충돌 시 제거
{ {
collision.GetComponent<IDamage>().ApplyDamage(damage * attackPower);
ReleaseObject(); ReleaseObject();
} }
} }

View File

@@ -9,9 +9,15 @@ namespace TON
private float elapsedTime; // 경과 시간 저장 변수 private float elapsedTime; // 경과 시간 저장 변수
public float destoryTime = 2f; public float destoryTime = 2f;
public float attackPower;
public float damage;
public string id = "K0002";
void OnEnable() void OnEnable()
{ {
elapsedTime = 0f; // 오브젝트가 활성화될 때 초기화 elapsedTime = 0f; // 오브젝트가 활성화될 때 초기화
damage = SkillDataManager.Singleton.GetSkillData(id).damage;
attackPower = PlayerDataManager.Singleton.player.attackPower;
} }
void Update() void Update()
@@ -29,6 +35,7 @@ namespace TON
{ {
if (collision.CompareTag("Monster")) // 적과 충돌 시 제거 if (collision.CompareTag("Monster")) // 적과 충돌 시 제거
{ {
collision.GetComponent<IDamage>().ApplyDamage(damage * attackPower);
ReleaseObject(); ReleaseObject();
} }
} }

View File

@@ -0,0 +1,31 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace TON
{
public class SkillDataManager : SingletonBase<SkillDataManager>
{
public List<SkillData> skillDatas { get; private set; }
protected override void Awake()
{
base.Awake();
LoadSkillData();
}
private void LoadSkillData()
{
skillDatas = JSONLoader.LoadFromResources<List<SkillData>>("Skill");
if (skillDatas == null)
{
skillDatas = new List<SkillData>();
}
}
public SkillData GetSkillData(string skillId)
{
return skillDatas.Find(v => v.id == skillId);
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 6eedee4d78efcd0409acbbe2ca1da519
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -8,7 +8,7 @@ namespace TON
public class SkillData public class SkillData
{ {
public int characterId; public int characterId;
public int id; public string id;
public int mp; public int mp;
public float damage; public float damage;
public int cooltime; public int cooltime;