private void DownloadLocalizedAssetAndDependencies(AssetList.Item node, AssetList assetList)
 {
     if (node == null)
     {
         return;
     }
     if (!node.Exist)
     {
         AssetDownloader.Add(node.IDStr);
     }
     for (int index = 0; index < node.Dependencies.Length; ++index)
     {
         if (!File.Exists(AssetDownloader.CachePath + node.Dependencies[index].IDStr))
         {
             AssetDownloader.Add(node.Dependencies[index].IDStr);
         }
     }
     for (int index = 0; index < node.AdditionalDependencies.Length; ++index)
     {
         string         path = AssetDownloader.CachePath + node.AdditionalDependencies[index].IDStr;
         string         localizedObjectName = AssetManager.GetLocalizedObjectName(node.AdditionalDependencies[index].Path, false);
         AssetList.Item itemByPath          = assetList.FindItemByPath(localizedObjectName);
         if (localizedObjectName == node.AdditionalDependencies[index].Path || itemByPath == null)
         {
             if (!File.Exists(path))
             {
                 AssetDownloader.Add(node.AdditionalDependencies[index].IDStr);
             }
         }
         else if (!File.Exists(AssetDownloader.CachePath + itemByPath.IDStr))
         {
             AssetDownloader.Add(itemByPath.IDStr);
         }
     }
     for (int index = 0; index < node.AdditionalStreamingAssets.Length; ++index)
     {
         string         path = AssetDownloader.CachePath + node.AdditionalStreamingAssets[index].IDStr;
         string         localizedObjectName = AssetManager.GetLocalizedObjectName(node.AdditionalStreamingAssets[index].Path, false);
         AssetList.Item itemByPath          = assetList.FindItemByPath(localizedObjectName);
         if (localizedObjectName == node.AdditionalStreamingAssets[index].Path || itemByPath == null)
         {
             if (!File.Exists(path))
             {
                 AssetDownloader.Add(node.AdditionalStreamingAssets[index].IDStr);
             }
         }
         else if (!File.Exists(AssetDownloader.CachePath + itemByPath.IDStr))
         {
             DebugUtility.LogWarning("Downloading localized streaming dependency: " + localizedObjectName);
             AssetDownloader.Add(itemByPath.IDStr);
         }
     }
 }
Exemple #2
0
        private void AddAssets()
        {
            GameManager instanceDirect = MonoSingleton <GameManager> .GetInstanceDirect();

            if (this.mQueue != null)
            {
                for (int index = 0; index < this.mQueue.Count; ++index)
                {
                    AssetDownloader.Add(this.mQueue[index].IDStr);
                }
                this.mQueue = (List <AssetList.Item>)null;
            }
            if (this.Download == (FlowNode_DownloadAssets.DownloadAssets) - 1)
            {
                return;
            }
            if ((this.Download & FlowNode_DownloadAssets.DownloadAssets.Tutorial) != (FlowNode_DownloadAssets.DownloadAssets) 0)
            {
                if ((instanceDirect.Player.TutorialFlags & 1L) != 0L)
                {
                    if (instanceDirect.HasTutorialDLAssets)
                    {
                        instanceDirect.DownloadTutorialAssets();
                    }
                    AssetManager.PrepareAssets("town001");
                }
                else if (BackgroundDownloader.Instance.IsEnabled)
                {
                    this.ProgressBar = false;
                    this.ActivateOutputLinks(10);
                    BackgroundDownloader.Instance.GetRequiredAssets(GameSettings.Instance.Tutorial_Steps[instanceDirect.TutorialStep]);
                }
                else
                {
                    if (instanceDirect.HasTutorialDLAssets)
                    {
                        instanceDirect.DownloadTutorialAssets();
                    }
                    if (!GameUtility.IsDebugBuild || GlobalVars.DebugIsPlayTutorial)
                    {
                        AssetManager.PrepareAssets("PortraitsM/urob");
                        AssetManager.PrepareAssets("op0002exit");
                        AssetManager.PrepareAssets("op0005exit");
                        AssetManager.PrepareAssets("op0006exit");
                    }
                    AssetManager.PrepareAssets("town001");
                    AssetManager.PrepareAssets("UI/QuestAssets");
                }
            }
            if ((this.Download & FlowNode_DownloadAssets.DownloadAssets.OwnUnits) != (FlowNode_DownloadAssets.DownloadAssets) 0 && ((instanceDirect.Player.TutorialFlags & 1L) != 0L || !BackgroundDownloader.Instance.IsEnabled))
            {
                PlayerData player = MonoSingleton <GameManager> .Instance.Player;
                if (player != null)
                {
                    for (int index = 0; index < player.Units.Count; ++index)
                    {
                        DownloadUtility.DownloadUnit(player.Units[index].UnitParam, player.Units[index].Jobs);
                    }
                }
            }
            if ((this.Download & FlowNode_DownloadAssets.DownloadAssets.AllUnits) != (FlowNode_DownloadAssets.DownloadAssets) 0)
            {
                MasterParam masterParam    = MonoSingleton <GameManager> .Instance.MasterParam;
                UnitParam[] unitParamArray = masterParam != null?masterParam.GetAllUnits() : (UnitParam[])null;

                if (unitParamArray != null)
                {
                    for (int index = 0; index < unitParamArray.Length; ++index)
                    {
                        DownloadUtility.DownloadUnit(unitParamArray[index], (JobData[])null);
                    }
                }
            }
            if ((this.Download & FlowNode_DownloadAssets.DownloadAssets.LoginBonus) != (FlowNode_DownloadAssets.DownloadAssets) 0 && ((instanceDirect.Player.TutorialFlags & 1L) != 0L || !BackgroundDownloader.Instance.IsEnabled))
            {
                Json_LoginBonusTable loginBonus28days = MonoSingleton <GameManager> .Instance.Player.LoginBonus28days;
                if (loginBonus28days != null && loginBonus28days.bonus_units != null && loginBonus28days.bonus_units.Length > 0)
                {
                    MasterParam masterParam = MonoSingleton <GameManager> .Instance.MasterParam;
                    foreach (string bonusUnit in loginBonus28days.bonus_units)
                    {
                        DownloadUtility.DownloadUnit(masterParam.GetUnitParam(bonusUnit), (JobData[])null);
                    }
                }
            }
            if ((this.Download & FlowNode_DownloadAssets.DownloadAssets.Artifacts) != (FlowNode_DownloadAssets.DownloadAssets) 0)
            {
                List <ArtifactData> artifacts = MonoSingleton <GameManager> .Instance.Player.Artifacts;
                if (artifacts != null && artifacts.Count > 0)
                {
                    for (int index = 0; index < artifacts.Count; ++index)
                    {
                        DownloadUtility.DownloadArtifact(artifacts[index].ArtifactParam);
                    }
                }
            }
            for (int index = 0; index < this.AssetPaths.Length; ++index)
            {
                if (!string.IsNullOrEmpty(this.AssetPaths[index]))
                {
                    AssetManager.PrepareAssets(this.AssetPaths[index]);
                }
            }
            if (!Object.op_Inequality((Object)instanceDirect, (Object)null))
            {
                return;
            }
            for (int index = 0; index < this.DownloadUnits.Length; ++index)
            {
                if (!string.IsNullOrEmpty(this.DownloadUnits[index]))
                {
                    UnitParam unitParam = instanceDirect.GetUnitParam(this.DownloadUnits[index]);
                    if (unitParam != null)
                    {
                        DownloadUtility.DownloadUnit(unitParam, (JobData[])null);
                    }
                }
            }
            for (int index = 0; index < this.DownloadQuests.Length; ++index)
            {
                if (!string.IsNullOrEmpty(this.DownloadQuests[index]))
                {
                    QuestParam quest = instanceDirect.FindQuest(this.DownloadQuests[index]);
                    if (quest == null)
                    {
                        DebugUtility.LogError("Can't download " + this.DownloadQuests[index]);
                    }
                    else
                    {
                        DownloadUtility.DownloadQuestBase(quest);
                    }
                }
            }
        }
        private void AddAssets()
        {
            GameManager instanceDirect = MonoSingleton <GameManager> .GetInstanceDirect();

            if (this.mQueue != null)
            {
                for (int index = 0; index < this.mQueue.Count; ++index)
                {
                    AssetDownloader.Add(this.mQueue[index].IDStr);
                }
                this.mQueue = (List <AssetList.Item>)null;
            }
            if (this.Download == (FlowNode_DownloadAssets.DownloadAssets) - 1)
            {
                return;
            }
            if ((this.Download & FlowNode_DownloadAssets.DownloadAssets.Tutorial) != (FlowNode_DownloadAssets.DownloadAssets) 0 && instanceDirect.HasTutorialDLAssets)
            {
                instanceDirect.DownloadTutorialAssets();
            }
            if ((this.Download & FlowNode_DownloadAssets.DownloadAssets.OwnUnits) != (FlowNode_DownloadAssets.DownloadAssets) 0)
            {
                PlayerData player = MonoSingleton <GameManager> .Instance.Player;
                if (player != null)
                {
                    for (int index = 0; index < player.Units.Count; ++index)
                    {
                        DownloadUtility.DownloadUnit(player.Units[index].UnitParam, player.Units[index].Jobs);
                        if (player.Units[index].ConceptCard != null)
                        {
                            DownloadUtility.DownloadConceptCard(player.Units[index].ConceptCard.Param);
                        }
                    }
                }
            }
            if ((this.Download & FlowNode_DownloadAssets.DownloadAssets.AllUnits) != (FlowNode_DownloadAssets.DownloadAssets) 0)
            {
                UnitParam[] allUnits = MonoSingleton <GameManager> .Instance.MasterParam?.GetAllUnits();

                if (allUnits != null)
                {
                    for (int index = 0; index < allUnits.Length; ++index)
                    {
                        DownloadUtility.DownloadUnit(allUnits[index], (JobData[])null);
                    }
                }
            }
            if ((this.Download & FlowNode_DownloadAssets.DownloadAssets.LoginBonus) != (FlowNode_DownloadAssets.DownloadAssets) 0)
            {
                Json_LoginBonusTable loginBonus28days = MonoSingleton <GameManager> .Instance.Player.LoginBonus28days;
                if (loginBonus28days != null && loginBonus28days.bonus_units != null && loginBonus28days.bonus_units.Length > 0)
                {
                    MasterParam masterParam = MonoSingleton <GameManager> .Instance.MasterParam;
                    foreach (string bonusUnit in loginBonus28days.bonus_units)
                    {
                        DownloadUtility.DownloadUnit(masterParam.GetUnitParam(bonusUnit), (JobData[])null);
                    }
                }
            }
            if ((this.Download & FlowNode_DownloadAssets.DownloadAssets.Artifacts) != (FlowNode_DownloadAssets.DownloadAssets) 0)
            {
                List <ArtifactData> artifacts = MonoSingleton <GameManager> .Instance.Player.Artifacts;
                if (artifacts != null && artifacts.Count > 0)
                {
                    for (int index = 0; index < artifacts.Count; ++index)
                    {
                        DownloadUtility.DownloadArtifact(artifacts[index].ArtifactParam);
                    }
                }
            }
            if ((this.Download & FlowNode_DownloadAssets.DownloadAssets.OwnConceptCard) != (FlowNode_DownloadAssets.DownloadAssets) 0)
            {
                List <ConceptCardData> conceptCards = MonoSingleton <GameManager> .Instance.Player.ConceptCards;
                if (conceptCards != null && conceptCards.Count > 0)
                {
                    for (int index = 0; index < conceptCards.Count; ++index)
                    {
                        DownloadUtility.DownloadConceptCard(conceptCards[index].Param);
                    }
                }
                List <ConceptCardMaterialData> cardExpMaterials = MonoSingleton <GameManager> .Instance.Player.ConceptCardExpMaterials;
                if (cardExpMaterials != null && cardExpMaterials.Count > 0)
                {
                    for (int index = 0; index < cardExpMaterials.Count; ++index)
                    {
                        DownloadUtility.DownloadConceptCard(cardExpMaterials[index].Param);
                    }
                }
                List <ConceptCardMaterialData> cardTrustMaterials = MonoSingleton <GameManager> .Instance.Player.ConceptCardTrustMaterials;
                if (cardTrustMaterials != null && cardTrustMaterials.Count > 0)
                {
                    for (int index = 0; index < cardTrustMaterials.Count; ++index)
                    {
                        DownloadUtility.DownloadConceptCard(cardTrustMaterials[index].Param);
                    }
                }
            }
            for (int index = 0; index < this.AssetPaths.Length; ++index)
            {
                if (!string.IsNullOrEmpty(this.AssetPaths[index]))
                {
                    AssetManager.PrepareAssets(this.AssetPaths[index]);
                }
            }
            if (!UnityEngine.Object.op_Inequality((UnityEngine.Object)instanceDirect, (UnityEngine.Object)null))
            {
                return;
            }
            for (int index = 0; index < this.DownloadUnits.Length; ++index)
            {
                if (!string.IsNullOrEmpty(this.DownloadUnits[index]))
                {
                    UnitParam unitParam = instanceDirect.GetUnitParam(this.DownloadUnits[index]);
                    if (unitParam != null)
                    {
                        DownloadUtility.DownloadUnit(unitParam, (JobData[])null);
                    }
                }
            }
            for (int index = 0; index < this.DownloadQuests.Length; ++index)
            {
                if (!string.IsNullOrEmpty(this.DownloadQuests[index]))
                {
                    QuestParam quest = instanceDirect.FindQuest(this.DownloadQuests[index]);
                    if (quest == null)
                    {
                        DebugUtility.LogError("Can't download " + this.DownloadQuests[index]);
                    }
                    else
                    {
                        DownloadUtility.DownloadQuestBase(quest);
                    }
                }
            }
        }
    private void AddRequiredAssets(string cacheDir, AssetList.Item[] assets)
    {
        AssetList assetList;
        bool      flag1;

        if (AssetManager.Format == AssetManager.AssetFormats.Text)
        {
            assetList = AssetManager.TxtAssetList;
            flag1     = true;
        }
        else
        {
            assetList = AssetManager.AssetList;
            flag1     = false;
        }
        AssetList.Item obj        = (AssetList.Item)null;
        List <string>  stringList = new List <string>();

        for (int index = 0; index < assets.Length; ++index)
        {
            AssetList.Item asset = assets[index];
            if ((asset.Flags & AssetBundleFlags.Required) != (AssetBundleFlags)0)
            {
                bool flag2 = asset.Size > 0 && !asset.Exist && asset.IsMatchLanguageItem();
                if (GameUtility.Config_Language == "english" || flag1)
                {
                    if (flag2)
                    {
                        stringList.Add(asset.IDStr);
                    }
                }
                else
                {
                    string         localizedObjectName = AssetManager.GetLocalizedObjectName(asset.Path, false);
                    AssetList.Item itemByPath          = assetList.FindItemByPath(localizedObjectName);
                    if (localizedObjectName == asset.Path || itemByPath == null)
                    {
                        if (flag2)
                        {
                            stringList.Add(asset.IDStr);
                        }
                    }
                    else
                    {
                        this.DownloadLocalizedAssetAndDependencies(itemByPath, assetList);
                    }
                }
            }
            else if (asset.Path == "reqAssetPack")
            {
                obj = asset;
            }
        }
        if (obj == null || stringList.Count < 30 || GameUtility.Config_Language != "english")
        {
            using (List <string> .Enumerator enumerator = stringList.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    AssetDownloader.Add(enumerator.Current);
                }
            }
        }
        else
        {
            AssetDownloader.Add(obj.IDStr);
        }
        stringList.Clear();
    }
Exemple #5
0
    public static void PrepareAssets(string resourcePath)
    {
        string localizedObjectName1 = AssetManager.GetLocalizedObjectName(resourcePath, false);
        bool   flag = resourcePath != localizedObjectName1;

        if (flag)
        {
            resourcePath = localizedObjectName1;
        }
        if (!AssetManager.mInstanceCreated)
        {
            return;
        }
        AssetList.Item itemByPath1 = AssetManager.mAssetListRef.FindItemByPath(resourcePath);
        if (itemByPath1 == null)
        {
            return;
        }
        if (!itemByPath1.Exist)
        {
            AssetDownloader.Add(itemByPath1.IDStr);
        }
        for (int index = 0; index < itemByPath1.Dependencies.Length; ++index)
        {
            if (!File.Exists(AssetDownloader.CachePath + itemByPath1.Dependencies[index].IDStr))
            {
                AssetDownloader.Add(itemByPath1.Dependencies[index].IDStr);
            }
        }
        for (int index = 0; index < itemByPath1.AdditionalDependencies.Length; ++index)
        {
            string path = AssetDownloader.CachePath + itemByPath1.AdditionalDependencies[index].IDStr;
            if (!flag)
            {
                if (!File.Exists(path))
                {
                    AssetDownloader.Add(itemByPath1.AdditionalDependencies[index].IDStr);
                }
            }
            else
            {
                string localizedObjectName2 = AssetManager.GetLocalizedObjectName(itemByPath1.AdditionalDependencies[index].Path, false);
                if (localizedObjectName2 == itemByPath1.AdditionalDependencies[index].Path)
                {
                    if (!File.Exists(path))
                    {
                        AssetDownloader.Add(itemByPath1.AdditionalDependencies[index].IDStr);
                    }
                }
                else
                {
                    AssetList.Item itemByPath2 = AssetManager.mAssetListRef.FindItemByPath(localizedObjectName2);
                    if (itemByPath2 == null)
                    {
                        if (!File.Exists(path))
                        {
                            AssetDownloader.Add(itemByPath1.AdditionalDependencies[index].IDStr);
                        }
                    }
                    else if (!File.Exists(AssetDownloader.CachePath + itemByPath2.IDStr))
                    {
                        AssetDownloader.Add(itemByPath2.IDStr);
                    }
                }
            }
        }
        for (int index = 0; index < itemByPath1.AdditionalStreamingAssets.Length; ++index)
        {
            string path = AssetDownloader.CachePath + itemByPath1.AdditionalStreamingAssets[index].IDStr;
            string localizedObjectName2 = AssetManager.GetLocalizedObjectName(itemByPath1.AdditionalStreamingAssets[index].Path, false);
            if (localizedObjectName2 == itemByPath1.AdditionalStreamingAssets[index].Path)
            {
                if (!File.Exists(path))
                {
                    AssetDownloader.Add(itemByPath1.AdditionalStreamingAssets[index].IDStr);
                }
            }
            else
            {
                DebugUtility.LogWarning("Checking localized streaming dependency: " + localizedObjectName2);
                AssetList.Item itemByPath2 = AssetManager.mAssetListRef.FindItemByPath(localizedObjectName2);
                if (itemByPath2 == null)
                {
                    if (!File.Exists(path))
                    {
                        AssetDownloader.Add(itemByPath1.AdditionalStreamingAssets[index].IDStr);
                    }
                }
                else if (!File.Exists(AssetDownloader.CachePath + itemByPath2.IDStr))
                {
                    DebugUtility.LogWarning("Downloading localized streaming dependency: " + localizedObjectName2);
                    AssetDownloader.Add(itemByPath2.IDStr);
                }
            }
        }
    }