using System; using System.Collections.Generic; using Logic.Action; using UnityEngine; using Logic.Multilingual; public enum TechType { None, Climbing,Meditation,Mining,Philosophy,Smithery, Organization,Strategy,Farming,Diplomacy,Construction, Riding,FreeSpirit,Chivalry,Roads,Trade, Hunting,Forestry,Archery,Mathematics,Spiritualism, Fishing,Ramming,Sailing,Aquatism,Navigation, EgyptFlandre,EgyptRemilia,EgyptMeiling,EgyptPatchouli,EgyptSakuya } [Serializable] [CreateAssetMenu(fileName = "TechDataAssets", menuName = "TH1 Game Data/Tech Data Asset")] public class TechDataAssets : ScriptableObject { public List TechList = new List(); [NonSerialized] private bool _initialized; private Dictionary _techInfoDict = new Dictionary(); private void Init() { if (_initialized) return; foreach (var tech in TechList) _techInfoDict.Add(tech.TechType,tech); _initialized = true; } public TechInfo GetTechInfo(TechType techType) { Init(); return _techInfoDict[techType]; } public bool GetTechDesc(TechType techType, out string ret) { Init(); ret = ""; if (_techInfoDict.TryGetValue(techType, out var info)) { ret = info.Description; return true; } return false; } // 获取科技的所有后继科技 (非伟人科技) public HashSet GetNextTechs(TechType techType) { var nextTechs = new HashSet(); while (GetNextTechs(techType, nextTechs)) { } return nextTechs; } // 获取科技的后继科技 (非伟人科技) public bool GetNextTechs(TechType techType, HashSet set) { bool isFound = false; foreach (var techInfo in TechList) { if (techInfo.GiantTech) continue; if (set.Contains(techInfo.TechType)) continue; if (techType != techInfo.FatherTechType && !set.Contains(techInfo.FatherTechType)) continue; set.Add(techInfo.TechType); isFound = true; } return isFound; } } [Serializable] public class TechInfo { public TechType TechType; // 唯一ID [MultilingualField] public string TechName; // 显示名称 [MultilingualField] public string Description; // 描述 public Sprite icon; // 图标 public int CostLevel; // 消耗等级(1,2,3) public bool GiantTech; //是否是巨人科技 public List GiantTechSet; //巨人科技需要的科技池子 public TechType FatherTechType; // 前置科技(用techId关联) public List techActions; // 解锁action }