Esempio n. 1
0
    void SaveTest()
    {
        if (battleGroupList.Count == 0)
        {
            return;
        }

        BattleGroup b = battleGroupList[0];

        //------------------------- 테스트 -----------------------
        BattleSaveDataStage stageData = null;

        if (b != null)
        {
            stageData = new BattleSaveDataStage(b);
        }

        stageData.id = "Battle_2";

        JsonWriter jsonWriter = new JsonWriter();

        jsonWriter.PrettyPrint = true;
        JsonMapper.ToJson(stageData, jsonWriter);
        string json = jsonWriter.ToString();

        //string json2 = JsonUtility.ToJson(data);  //이걸로 하면 몇몇 타입의 필드가 json에서 누락됨

        Debug.Log(json);

        string fileName = Application.persistentDataPath + "/" + stageData.id + "_" + User.Instance.userID + "_Stage.dat";

        File.WriteAllText(fileName, json);
    }
Esempio n. 2
0
    void OnLoadData(BattleGroup _battleGroup, BattleSaveDataStage data)
    {
        if (battleGroup != _battleGroup)
        {
            return;
        }

        //Debug.Log(data.dungeonID + ", exp: " + data.totalExp);
        double result = 0;

        if (double.TryParse(data.totalExp, out result))
        {
            totalExp = result;
        }
    }
Esempio n. 3
0
    static public void SaveStageInfo(BattleGroup battleGroup)
    {
        BattleSaveDataStage data = new BattleSaveDataStage(battleGroup);

        //stageData.id = "Battle_2";
        //Debug.Log("스테이지 저장");
        JsonWriter jsonWriter = new JsonWriter();

        jsonWriter.PrettyPrint = true;
        JsonMapper.ToJson(data, jsonWriter);
        string json = jsonWriter.ToString();
        //string json2 = JsonUtility.ToJson(data);  //이걸로 하면 몇몇 타입의 필드가 json에서 누락됨

        string fileName = Application.persistentDataPath + "/" + battleGroup.battleType + "_" + User.Instance.userID + "_Stage.dat";

        File.WriteAllText(fileName, json);
        SaveHeroProficiency(battleGroup);
    }
Esempio n. 4
0
    void LoadAndCreateBattleGroups()
    {
        List <BattleSaveDataStage> battleSaveDataList = new List <BattleSaveDataStage>();

        for (int i = 0; i < battleIDList.Count; i++)
        {
            string fileName = Application.persistentDataPath + "/" + battleIDList[i] + "_" + User.Instance.userID + "_Stage.dat";

            if (!File.Exists(fileName))
            {
                //첫 실행 할 때 첫번째 배틀그룹에 콜라 내보내기
                if (i == 0)
                {
                    List <HeroData> list           = new List <HeroData>();
                    HeroData        heroDataBattle = HeroManager.heroDataList.Find(x => x.heroID == "Knight_02_Hero");
                    if (heroDataBattle != null)
                    {
                        list.Add(heroDataBattle);
                        CreateBattleGroup(battleIDList[0], list);
                    }
                }

                continue;
            }

            string json = File.ReadAllText(fileName);

            //Debug.Log(json);

            BattleSaveDataStage saveData = JsonUtility.FromJson <BattleSaveDataStage>(json);
            battleSaveDataList.Add(saveData);

            List <HeroData> heroDataList = GetHeroDataListFromSaveData(json);
            if (heroDataList == null || heroDataList.Count == 0)
            {
                continue;
            }

            CreateBattleGroup(saveData.id, heroDataList, saveData.stage, saveData);
        }
    }
Esempio n. 5
0
    void LoadTest()
    {
        string fileName = Application.persistentDataPath + "/" + "Battle_2" + "_" + User.Instance.userID + "_Stage.dat";

        if (!File.Exists(fileName))
        {
            return;
        }

        string json = File.ReadAllText(fileName);

        Debug.Log(json);

        BattleSaveDataStage saveData = new BattleSaveDataStage();

        saveData = JsonUtility.FromJson <BattleSaveDataStage>(json);

        JsonData jsonData = JsonMapper.ToObject(json);

        Debug.Log(jsonData["battleHeroList"]);

        Debug.Log(saveData.battleHeroList.Count);
    }
Esempio n. 6
0
    /// <summary> 전투가 진행중인 배틀 그룹을 씬에 생성 </summary>
    static public void CreateBattleGroup(string battleGroupID, List <HeroData> heroList, int stage = 1, BattleSaveDataStage battleSaveData = null)
    {
        if (!Instance)
        {
            return;
        }

        currentBattleGroupID = battleGroupID;

        GameObject  go          = Instantiate(Instance.battleGroupPrefab, Instance.battleList.position, Quaternion.identity, Instance.battleList) as GameObject;
        BattleGroup battleGroup = go.GetComponent <BattleGroup>();

        if (battleSaveData != null)
        {
            battleGroup.Init(battleGroupID, heroList, stage, battleSaveData);
            battleGroup.isRenderingActive = false;
        }

        else
        {
            battleGroup.Init(battleGroupID, heroList, stage);
        }

        //리스트에 추가
        battleGroupList.Add(battleGroup);

        if (onChangedBattleGroupList != null)
        {
            onChangedBattleGroupList();
        }
    }
Esempio n. 7
0
    public IEnumerator InitHero(BattleType _battleType, List <HeroData> heroList, int _stage = 1, BattleSaveDataStage saveData = null)
    {
        battleType = _battleType;
        if (saveData != null)
        {
            stage = saveData.stage;

            dungeonID = saveData.dungeonID;
            while (!artifactController && !battleLevelUpController)
            {
                yield return(null);
            }

            if (onLoadData != null)
            {
                onLoadData(this, saveData);
            }
        }
        else
        {
            stage = _stage;

            List <string> dungeonIDList = GameDataManager.dungeonBaseDataDic.Keys.ToList();
            int           r             = UnityEngine.Random.Range(0, dungeonIDList.Count);
            dungeonID = dungeonIDList[r];
        }
        yield return(StartCoroutine(battleTeamList[0].InitCoroutine(this, BattleUnit.Team.Red, heroList)));

        isInitialized = true;

        while (!Battle.Instance.isInitialized)
        {
            yield return(null);
        }

        if (battleType == BattleType.PvP)
        {
            yield break;
        }

        if (saveData == null)
        {
            Battle.SaveStageInfo(this);
        }
    }
Esempio n. 8
0
 public void Init(BattleType _battleType, List <HeroData> heroList, int _stage = 1, BattleSaveDataStage saveData = null)
 {
     StartCoroutine(InitHero(_battleType, heroList, _stage = 1, saveData));
 }