コード例 #1
0
        private static bool restoreSaveData(BattleSuspend.Data data)
        {
            if (data == null || !data.ivl)
            {
                return(false);
            }
            SceneBattle instance = SceneBattle.Instance;

            if (!UnityEngine.Object.op_Implicit((UnityEngine.Object)instance))
            {
                return(false);
            }
            BattleCore battle = instance.Battle;

            if (battle == null)
            {
                return(false);
            }
            BattleSuspend.Data.Header hdr = data.hdr;
            if (hdr.apv != Application.get_version())
            {
                DebugUtility.LogWarning("BattleSuspend/Restoration failure! Version is different.");
                return(false);
            }
            if (hdr.arv != AssetManager.AssetRevision)
            {
                DebugUtility.LogWarning("BattleSuspend/Restoration failure! Revision is different.");
                return(false);
            }
            if (hdr.qid != battle.QuestID)
            {
                DebugUtility.LogWarning("BattleSuspend/Restoration failure! QuestID is different.");
                return(false);
            }
            if (hdr.bid != battle.BtlID)
            {
                DebugUtility.LogWarning("BattleSuspend/Restoration failure! BattleID is different.");
                return(false);
            }
            GameUtility.Config_AutoMode_Treasure.Value     = hdr.cat;
            GameUtility.Config_AutoMode_DisableSkill.Value = hdr.cad;
            for (int count = battle.AllUnits.Count; count < data.uil.Count; ++count)
            {
                BattleSuspend.Data.UnitInfo unitInfo = data.uil[count];
                if (!string.IsNullOrEmpty(unitInfo.boi))
                {
                    battle.BreakObjCreate(unitInfo.boi, unitInfo.ugx, unitInfo.ugy, (Unit)null, (LogSkill)null, 0);
                }
            }
            for (int index = 0; index < data.uil.Count && index < battle.AllUnits.Count; ++index)
            {
                BattleSuspend.Data.UnitInfo unit_info = data.uil[index];
                Unit allUnit = battle.AllUnits[index];
                if (!(allUnit.UnitName != unit_info.nam))
                {
                    allUnit.SetupSuspend(battle, unit_info);
                }
            }
            BattleCore.Record questRecord = battle.GetQuestRecord();
            using (List <BattleSuspend.Data.UsedItem> .Enumerator enumerator = data.itl.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    BattleSuspend.Data.UsedItem current = enumerator.Current;
                    questRecord.used_items[(OString)current.iti] = (OInt)current.num;
                    ItemData inventoryByItemId = battle.FindInventoryByItemID(current.iti);
                    if (inventoryByItemId != null)
                    {
                        inventoryByItemId.Used(current.num);
                    }
                }
            }
            TrickData.ClearEffect();
            using (List <BattleSuspend.Data.TrickInfo> .Enumerator enumerator = data.trl.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    BattleSuspend.Data.TrickInfo current = enumerator.Current;
                    Unit unitFromAllUnits = BattleSuspend.GetUnitFromAllUnits(battle, current.cun);
                    TrickData.SuspendEffect(current.tid, current.grx, current.gry, current.tag, unitFromAllUnits, current.ccl, current.rnk, current.rcp, current.rac);
                }
            }
            using (List <BattleSuspend.Data.SkillExecLogInfo> .Enumerator enumerator = data.sel.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    BattleSuspend.Data.SkillExecLogInfo current      = enumerator.Current;
                    BattleCore.SkillExecLog             skillExecLog = new BattleCore.SkillExecLog();
                    skillExecLog.Restore(current);
                    battle.SkillExecLogs.Add(current.inm, skillExecLog);
                }
            }
            BattleSuspend.Data.Variables var = data.var;
            battle.WinTriggerCount   = var.wtc;
            battle.LoseTriggerCount  = var.ltc;
            battle.ActionCount       = var.act;
            battle.Killstreak        = var.kls;
            battle.MaxKillstreak     = var.mks;
            battle.TotalHeal         = var.thl;
            battle.TotalDamagesTaken = var.tdt;
            battle.TotalDamages      = var.tdm;
            battle.NumUsedItems      = var.nui;
            battle.NumUsedSkills     = var.nus;
            battle.ClockTime         = var.ctm;
            battle.ClockTimeTotal    = var.ctt;
            battle.ContinueCount     = var.coc;
            battle.FinisherIname     = var.fns;
            instance.GoldCount       = var.glc;
            instance.RestoreTreasureCount(var.trc);
            battle.Seed              = var.rsd;
            battle.PlayByManually    = var.pbm;
            battle.IsUseAutoPlayMode = var.uam;
            if (var.ris != null)
            {
                for (int index = 0; index < var.ris.Length; ++index)
                {
                    battle.SetRandSeed(index, var.ris[index]);
                }
            }
            if (var.gsl.Count == battle.GimmickEventList.Count)
            {
                for (int index = 0; index < var.gsl.Count; ++index)
                {
                    BattleSuspend.Data.Variables.GimmickEvent gimmickEvent = var.gsl[index];
                    battle.GimmickEventList[index].count       = gimmickEvent.ctr;
                    battle.GimmickEventList[index].IsCompleted = gimmickEvent.cmp != 0;
                }
            }
            if (var.ssl.Count != 0)
            {
                battle.EventTriggers = new bool[var.ssl.Count];
                for (int index = 0; index < var.ssl.Count; ++index)
                {
                    BattleSuspend.Data.Variables.ScriptEvent scriptEvent = var.ssl[index];
                    battle.EventTriggers[index] = scriptEvent.trg;
                }
            }
            Dictionary <string, int> dictionary1 = new Dictionary <string, int>();
            int num1 = Math.Min(var.tkk.Length, var.tkv.Length);

            for (int index = 0; index < num1; ++index)
            {
                dictionary1.Add(var.tkk[index], var.tkv[index]);
            }
            battle.TargetKillstreak = dictionary1;
            Dictionary <string, int> dictionary2 = new Dictionary <string, int>();
            int num2 = Math.Min(var.mtk.Length, var.mtv.Length);

            for (int index = 0; index < num2; ++index)
            {
                dictionary2.Add(var.mtk[index], var.mtv[index]);
            }
            battle.MaxTargetKillstreak = dictionary2;
            BattleSuspend.Data.Variables.WeatherInfo wti = var.wti;
            if (!string.IsNullOrEmpty(wti.wid))
            {
                Unit unitFromAllUnits = BattleSuspend.GetUnitFromAllUnits(battle, wti.mun);
                WeatherData.SuspendWeather(wti.wid, battle.Units, unitFromAllUnits, wti.rnk, wti.rcp, wti.ccl);
            }
            return(true);
        }