From a8ff9955ed395c250130a06a650d29ac177f6ae0 Mon Sep 17 00:00:00 2001 From: Mingu Kim Date: Wed, 12 Feb 2025 15:43:46 +0900 Subject: [PATCH] =?UTF-8?q?=EB=AA=AC=EC=8A=A4=ED=84=B0=20json=20=EB=A1=9C?= =?UTF-8?q?=EB=93=9C=EB=A5=BC=20=EC=9C=84=ED=95=9C=20=EC=BD=94=EB=93=9C=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Gameton/Resources/GameData/monster.json | 44 ++++++++ .../Resources/GameData/monster.json.meta | 7 ++ .../Gameton/Scripts/GameData/MonsterData.cs | 51 +++++++++ .../{Monster => GameData}/MonsterData.cs.meta | 0 .../Gameton/Scripts/Monster/MonsterData.cs | 34 ------ .../Scripts/Monster/MonsterDataManager.cs | 103 +++++++----------- .../Scripts/Monster/MonsterSkillData.cs | 17 --- .../Scripts/Monster/MonsterSkillData.cs.meta | 11 -- 8 files changed, 141 insertions(+), 126 deletions(-) create mode 100644 Gameton-06/Assets/Gameton/Resources/GameData/monster.json create mode 100644 Gameton-06/Assets/Gameton/Resources/GameData/monster.json.meta create mode 100644 Gameton-06/Assets/Gameton/Scripts/GameData/MonsterData.cs rename Gameton-06/Assets/Gameton/Scripts/{Monster => GameData}/MonsterData.cs.meta (100%) delete mode 100644 Gameton-06/Assets/Gameton/Scripts/Monster/MonsterData.cs delete mode 100644 Gameton-06/Assets/Gameton/Scripts/Monster/MonsterSkillData.cs delete mode 100644 Gameton-06/Assets/Gameton/Scripts/Monster/MonsterSkillData.cs.meta diff --git a/Gameton-06/Assets/Gameton/Resources/GameData/monster.json b/Gameton-06/Assets/Gameton/Resources/GameData/monster.json new file mode 100644 index 00000000..ca9bf40c --- /dev/null +++ b/Gameton-06/Assets/Gameton/Resources/GameData/monster.json @@ -0,0 +1,44 @@ +[ + { + "id": 1, + "name": "blueDragon", + "level": 1, + "hp": 10, + "attackPower": 35, + "defencePower": 36, + "monsterSkillID": "S001", + "patrolRange": 1, + "detectionRange": 1, + "chaseRange": 1, + "moveSpeed": 1, + "attackRange": 1 + }, + { + "id": 2, + "name": "greenDragon", + "level": 1, + "hp": 10, + "attackPower": 35, + "defencePower": 36, + "monsterSkillID": "S001", + "patrolRange": 1, + "detectionRange": 1, + "chaseRange": 1, + "moveSpeed": 1, + "attackRange": 1 + }, + { + "id": 3, + "name": "redDragon", + "level": 1, + "hp": 10, + "attackPower": 35, + "defencePower": 36, + "monsterSkillID": "S001", + "patrolRange": 1, + "detectionRange": 1, + "chaseRange": 1, + "moveSpeed": 1, + "attackRange": 1 + } +] \ No newline at end of file diff --git a/Gameton-06/Assets/Gameton/Resources/GameData/monster.json.meta b/Gameton-06/Assets/Gameton/Resources/GameData/monster.json.meta new file mode 100644 index 00000000..5ec8374a --- /dev/null +++ b/Gameton-06/Assets/Gameton/Resources/GameData/monster.json.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 18f338c4715910e46b8df365a52142db +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Gameton-06/Assets/Gameton/Scripts/GameData/MonsterData.cs b/Gameton-06/Assets/Gameton/Scripts/GameData/MonsterData.cs new file mode 100644 index 00000000..cc301f37 --- /dev/null +++ b/Gameton-06/Assets/Gameton/Scripts/GameData/MonsterData.cs @@ -0,0 +1,51 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace TON +{ + [System.Serializable] + public class MonsterData + { + // 몬스터 아이디 + public int id; + // 몬스터 명 or 프리팹 명? + public string name; + // 몬스터 레벨 + public int level; + // 몬스터 타입 ex : melee, ranged + public string monsterType; + // 몬스터 체력 + public int hp; + // 기본 공격력 + public int attackPower; + // 기본 방어력 + public int defensivePower; + // 몬스터 스킬 ID + public string monsterSkillID; + // 패트롤 범위 + public float patrolRange; + // 인식 범위 + public float detectionRange; + // 추적 범위 + public float chaseRange; + // 공격 범위 + public float attackRange; + + public MonsterData(int id, string name, int level, string monsterType, int hp, int attackPower, int defensivePower, int monsterSkillID, float patrolRange, float detectionRange, float chaseRange, float attackRange) + { + id = id; + name = name; + level = level; + monsterType = monsterType; + hp = hp; + attackPower = attackPower; + defensivePower = defensivePower; + monsterSkillID = monsterSkillID; + patrolRange = patrolRange; + detectionRange = detectionRange; + chaseRange = chaseRange; + attackRange = attackRange; + } + } +} diff --git a/Gameton-06/Assets/Gameton/Scripts/Monster/MonsterData.cs.meta b/Gameton-06/Assets/Gameton/Scripts/GameData/MonsterData.cs.meta similarity index 100% rename from Gameton-06/Assets/Gameton/Scripts/Monster/MonsterData.cs.meta rename to Gameton-06/Assets/Gameton/Scripts/GameData/MonsterData.cs.meta diff --git a/Gameton-06/Assets/Gameton/Scripts/Monster/MonsterData.cs b/Gameton-06/Assets/Gameton/Scripts/Monster/MonsterData.cs deleted file mode 100644 index ca218398..00000000 --- a/Gameton-06/Assets/Gameton/Scripts/Monster/MonsterData.cs +++ /dev/null @@ -1,34 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -namespace TON -{ - [System.Serializable] - public class MonsterData - { - // 몬스터 아이디 - public int id; - // 몬스터 명 or 프리팹 명? - public string name; - // 몬스터 타입 ex : melee, ranged - public string monsterType; - // 몬스터 체력 - public int hp; - - // 기본 공격력 - public int attackPower; - // 기본 방어력 - public int defensivePower; - - public MonsterData(int id, string monsterType, string name, int hp, int attackPower, int defensivePower) - { - id = this.id; - monsterType = this.monsterType == "monster" ? "melle" : "ranged"; - name = this.name; - hp = this.hp; - attackPower = this.attackPower; - defensivePower = this.defensivePower; - } - } -} diff --git a/Gameton-06/Assets/Gameton/Scripts/Monster/MonsterDataManager.cs b/Gameton-06/Assets/Gameton/Scripts/Monster/MonsterDataManager.cs index aec499c1..f70b44ec 100644 --- a/Gameton-06/Assets/Gameton/Scripts/Monster/MonsterDataManager.cs +++ b/Gameton-06/Assets/Gameton/Scripts/Monster/MonsterDataManager.cs @@ -8,72 +8,47 @@ namespace TON using System.IO; using UnityEngine; - public class MonsterDataManager : MonoBehaviour + public class MonsterDataManager : SingletonBase { - public static MonsterDataManager Instance { get; private set; } - public Dictionary monsterDataDict = new Dictionary(); + // 전체 몬스터 데이터 리스트 + public List monstersData { get; private set; } - // void Awake() - // { - // if (Instance == null) - // { - // Instance = this; - // } - // else - // { - // Destroy(gameObject); - // return; - // } - // - // LoadMonsterData("monster_data.csv"); // CSV 파일 이름 - // } + // 현재 선택된 몬스터 데이터 + public MonsterData currentMonster { get; private set; } - // void LoadMonsterData(string fileName) - // { - // List data = ReadCSV(fileName); - // - // // 첫 번째 행은 헤더이므로 건너뜀 - // for (int i = 1; i < data.Count; i++) - // { - // string[] row = data[i]; - // MonsterData monsterData = new MonsterData(); - // - // monsterData.id = int.Parse(row[0]); - // monsterData.name = row[1]; - // monsterData.attackPower = int.Parse(row[2]); - // monsterData.health = int.Parse(row[3]); - // monsterData.speed = float.Parse(row[4]); - // - // monsterDataDict.Add(monsterData.id, monsterData); - // } - // } - // - // List ReadCSV(string fileName) - // { - // List data = new List(); - // TextAsset textAsset = Resources.Load(fileName); // Resources 폴더에서 파일 로드 - // - // using (StringReader reader = new StringReader(textAsset.text)) - // { - // while (!reader.EndOfStream) - // { - // string line = reader.ReadLine(); - // string[] row = line.Split(','); - // data.Add(row); - // } - // } - // - // return data; - // } + protected override void Awake() + { + base.Awake(); + LoadMonsterData(); + } + + private void LoadMonsterData() + { + monstersData = JSONLoader.LoadFromResources>("Monster"); + if (monstersData == null) + { + monstersData = new List(); + Debug.LogError("몬스터 데이터 로드 실패"); + } + } + + public MonsterData GetMonsterData(int monsterId) + { + if (monsterId >= 0 && monsterId < monstersData.Count) + { + currentMonster = monstersData[monsterId]; + return currentMonster; + } + else + { + Debug.LogError($"유효하지 않은 몬스터 ID입니다: {monsterId}"); + return null; + } + } + + public List GetAllMonsterData() + { + return monstersData; + } } -} - -// 몬스터 데이터 클래스 -public class MonsterData -{ - public int id; - public string name; - public int attackPower; - public int health; - public float speed; } \ No newline at end of file diff --git a/Gameton-06/Assets/Gameton/Scripts/Monster/MonsterSkillData.cs b/Gameton-06/Assets/Gameton/Scripts/Monster/MonsterSkillData.cs deleted file mode 100644 index bc537c3a..00000000 --- a/Gameton-06/Assets/Gameton/Scripts/Monster/MonsterSkillData.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -namespace TON -{ - [System.Serializable] - - public class MonsterSkillData - { - public int id; // 몬스터 id - public string skillType; // 스킬 타입(공격, 근거리, 원거리) - public int damage; // 스킬 피해량 - public float coolTime; // 스킬 쿨타임 - public float skillRange; // 스킬 범위(콜라이더 조정) - } -} diff --git a/Gameton-06/Assets/Gameton/Scripts/Monster/MonsterSkillData.cs.meta b/Gameton-06/Assets/Gameton/Scripts/Monster/MonsterSkillData.cs.meta deleted file mode 100644 index 8aa39ef4..00000000 --- a/Gameton-06/Assets/Gameton/Scripts/Monster/MonsterSkillData.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 68285054ac94bb741b8b33e422a9e28c -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: