ThreeKingdomsSlingshot/Assets/Scripts/OutGame/Data/HeroDb.cs

83 lines
2.8 KiB
C#

using System;
using System.Collections.Generic;
using UnityEngine;
namespace TKS.OutGame
{
/// <summary>
/// 영웅 31 + 병사 유닛 15 정의(heroes.csv) + 승급 단계별 요구 장비 6칸(hero_gear.csv). SOT = Assets/Data/OutGame/*.csv →
/// 메뉴 TKS/Import OutGame Data(직접 고치면 다음 임포트에 덮임). 기존 BalanceConfig.heroes[] 를 대체한다(2026-11-05 #1093).
/// </summary>
public class HeroDb : ScriptableObject
{
[Serializable]
public class Hero
{
public string id;
public string nameKo;
public string hanja;
[Tooltip("shu|wei|wu|other")]
public string faction;
public UnitType type;
[Tooltip("희귀도 1~3 = ★ · 영웅 초기 ★ = 희귀도")]
public int rarity = 1;
public float hpMult = 1f;
public float atkMult = 1f;
public float defMult = 1f;
[Tooltip("Resources/Units/<art>/ · 없으면 도형")]
public string art;
public string skillActive;
public string skillPassive;
[Tooltip("병사 유닛 = 승급·진화 없음 · 중복 = 골드")]
public bool isSoldier;
public string firstStage;
[Tooltip("m|f — 스킬 조건(남성·여성 영웅 · 2026-11-10 #1112)")]
public string gender = "m";
public bool Female
{
get { return gender == "f"; }
}
public List<GearSet> gear = new List<GearSet>();
}
/// <summary>승급 전 등급 grade 에서 채워야 하는 장비 6칸(slot 1~6 → slots[0~5]).</summary>
[Serializable]
public class GearSet
{
public string grade;
public List<string> slots = new List<string>();
}
public List<Hero> heroes = new List<Hero>();
Dictionary<string, Hero> index;
public Hero Get(string id)
{
if (string.IsNullOrEmpty(id)) return null;
if (index == null || index.Count != heroes.Count)
{
index = new Dictionary<string, Hero>();
foreach (var h in heroes) index[h.id] = h;
}
Hero res;
return index.TryGetValue(id, out res) ? res : null;
}
/// <summary>등급 grade 의 요구 장비 6칸(없으면 null = 최고 등급 · 병사).</summary>
public List<string> GearFor(Hero h, string grade)
{
if (h == null) return null;
foreach (var g in h.gear)
if (g.grade == grade) return g.slots;
return null;
}
public void InvalidateIndex()
{
index = null;
}
}
}