示例#1
0
    public void LoadHeroData()
    {
        try
        {
            Debug.Log("영웅 정보 로드 성공");

            /*string jsonData = File.ReadAllText(saveOrLoad(false, false, "heroData"));
             * heroDataFile = JsonUtility.FromJson<heroDataFile>(jsonData);*/

            heroDataFile = JsonUtility.FromJson <HeroDataFile>(Resources.Load <TextAsset>("heroData").ToString());

            for (int i = 0; i < heroDataFile.heroDatas.Count; i++)
            {
                //heroDataFile.heroDatas[i].sprite = loadSprite(heroDataFile.heroDatas[i].spritePath);
                heroDataFile.heroDatas[i].applySprite();
                heroDB.Add(heroDataFile.heroDatas[i]);
            }

            // 딕셔너리에 몬스터 정보 입력
            for (int i = 0; i < heroDB.Count; i++)
            {
                heroDatas.Add(heroDB[i].code, heroDB[i]);
            }
        }
        catch (FileNotFoundException)
        {
            Debug.Log("로드 오류");

            string jsonData = JsonUtility.ToJson(heroDataFile, true);

            File.WriteAllText(SaveOrLoad(false, false, "heroData"), jsonData);
            LoadHeroData();
        }
    }
示例#2
0
    // private string prefabPath = "Images/hero";

    // Start is called before the first frame update
    void Start()
    {
        instance = this;

        heroDataFile           = new HeroDataFile();
        heroDataFile.heroDatas = new List <EntityData>();

        //SaveHeroData();
        LoadHeroData();
    }