コード例 #1
0
ファイル: SkillManager.cs プロジェクト: SaebaHuang/Y-000
        public BaseSkill GetSkillById(string id)
        {
            BaseSkill skill = null;

            itemDict.TryGetValue(id, out skill);
            return(skill);
        }
コード例 #2
0
ファイル: SkillManager.cs プロジェクト: SaebaHuang/Y-000
        public void LoadFromJson(string path)
        {
            string json = (Resources.Load(path, typeof(TextAsset)) as TextAsset).text;

            itemDict = new Dictionary <string, BaseSkill>();
            var infos = JsonUtility.FromJson <_Skills>(json);

            foreach (var i in infos.data)
            {
                // Reflection
                Type t = Type.GetType("Y00." + i.id);
                if (t == null)
                {
                    Debug.LogWarning("Missing skill script: `" + i.id + "`");
                    continue;
                }
                BaseSkill skill = Activator.CreateInstance(t) as BaseSkill;
                itemDict.Add(i.id, skill);
            }
        }