少年修仙传客户端代码仓库
client_Wu Xijin
2018-11-24 47e3a9e94423e98113482e510fd67c8ddbccd6e8
5038 【1.3】4G环境下,地图分包下载显示优化
5个文件已修改
2个文件已添加
183 ■■■■■ 已修改文件
Core/GameEngine/Model/Config/PriorBundleConfig.cs 5 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Core/GameEngine/Model/Config/PriorBundleConfig.cs.meta 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
Core/GameEngine/Model/TelPartialConfig/PartPriorBundleConfig.cs 25 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
System/AssetVersion/InGameDownLoad.cs 43 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
System/AssetVersion/MapAssetDownLoadProgress.cs 54 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
System/AssetVersion/MapAssetDownLoadProgress.cs.meta 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
System/WorldMap/WorldMapAreaBehaviour.cs 42 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Core/GameEngine/Model/Config/PriorBundleConfig.cs
@@ -1,6 +1,6 @@
//--------------------------------------------------------
//    [Author]:            第二世界
//    [  Date ]:           Thursday, November 01, 2018
//    [  Date ]:           Saturday, November 24, 2018
//--------------------------------------------------------
using UnityEngine;
@@ -15,6 +15,7 @@
        public string AssetABName { get ; private set; } 
        public int AssetType { get ; private set ; }
        public int Prior { get ; private set ; }
        public int mapId { get ; private set ; }
        public override string getKey()
        {
@@ -31,6 +32,8 @@
                AssetType=IsNumeric(rawContents[2]) ? int.Parse(rawContents[2]):0; 
            
                Prior=IsNumeric(rawContents[3]) ? int.Parse(rawContents[3]):0; 
                mapId=IsNumeric(rawContents[4]) ? int.Parse(rawContents[4]):0;
            }
            catch (Exception ex)
            {
Core/GameEngine/Model/Config/PriorBundleConfig.cs.meta
@@ -1,6 +1,6 @@
fileFormatVersion: 2
guid: 949b242ddea04fe418ea4647b082dcb7
timeCreated: 1541037151
timeCreated: 1543053057
licenseType: Pro
MonoImporter:
  serializedVersion: 2
Core/GameEngine/Model/TelPartialConfig/PartPriorBundleConfig.cs
@@ -69,8 +69,31 @@
                default:
                    return 0;
            }
        }
        public static int GetAssetBelongToMap(AssetVersion.AssetCategory category, string fileName)
        {
            if (!inited)
            {
                Init();
            }
            fileName = fileName.ToLower();
            switch (category)
            {
                case AssetVersion.AssetCategory.Scene:
                    return m_Scenes.ContainsKey(fileName) ? m_Scenes[fileName].mapId : 0;
                case AssetVersion.AssetCategory.Mob:
                    return m_Mobs.ContainsKey(fileName) ? m_Mobs[fileName].mapId : 0;
                case AssetVersion.AssetCategory.Effect:
                    return m_Effects.ContainsKey(fileName) ? m_Effects[fileName].mapId : 0;
                case AssetVersion.AssetCategory.Audio:
                    return m_Audios.ContainsKey(fileName) ? m_Audios[fileName].mapId : 0;
                default:
                    return 0;
            }
        }
    }
}
System/AssetVersion/InGameDownLoad.cs
@@ -15,6 +15,7 @@
    List<RemoteFile> workingQueue = new List<RemoteFile>();
    List<AssetVersion> tasks = new List<AssetVersion>();
    Dictionary<int, List<AssetVersion>> mapTasks = new Dictionary<int, List<AssetVersion>>();
    public bool inGameDownLoadAllow = false;
@@ -109,6 +110,20 @@
            totalSize += task.size;
        }
        for (var i = 0; i < tasks.Count; i++)
        {
            var assetVersion = tasks[i];
            var mapId = PriorBundleConfig.GetAssetBelongToMap(assetVersion.GetAssetCategory(), assetVersion.fileName);
            if (mapId != 0)
            {
                if (!mapTasks.ContainsKey(mapId))
                {
                    mapTasks[mapId] = new List<AssetVersion>();
                }
                mapTasks[mapId].Add(assetVersion);
            }
        }
        state = State.None;
        PlayerTaskDatas.Event_MainlineTask -= OnMainTaskChange;
@@ -146,6 +161,32 @@
        send.RewardType = 15;
        send.DataEx = (byte)(_manual ? 0 : 1);
        GameNetSystem.Instance.SendInfo(send);
    }
    public float GetMapAssetDownLoadProgress(int mapId)
    {
        if (!mapTasks.ContainsKey(mapId))
        {
            return 1f;
        }
        var tasks = mapTasks[mapId];
        var total = tasks.Count;
        if (total == 0)
        {
            return 1f;
        }
        var completeCount = 0;
        foreach (var task in tasks)
        {
            if (task.localValid)
            {
                completeCount++;
            }
        }
        return completeCount / (float)total;
    }
    public void TryDownLoad(Dominant _dominant)
@@ -377,7 +418,6 @@
        }
    }
    bool m_SimulateWifi = true;
    public bool simulateWifi {
        get { return m_SimulateWifi; }
@@ -409,7 +449,6 @@
        }
    }
    float netCheckTimer = 0f;
System/AssetVersion/MapAssetDownLoadProgress.cs
New file
@@ -0,0 +1,54 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using System;
public class MapAssetDownLoadProgress : MonoBehaviour
{
    [SerializeField] Image m_SliderProgress;
    [SerializeField] Text m_Progress;
    public int mapId = 0;
    Action onComplete;
    public void OnComplete(Action onComplete)
    {
        this.onComplete = onComplete;
    }
    private void Start()
    {
        var progress = InGameDownLoad.Instance.GetMapAssetDownLoadProgress(mapId);
        if (progress >= 0.9999f)
        {
            Destroy(this.gameObject);
        }
        else
        {
            m_Progress.text = StringUtility.Contact(Mathf.Clamp(progress * 100, 0, 100), "%");
            m_SliderProgress.fillAmount = Mathf.Clamp01(progress + 0.2f);
        }
    }
    void Update()
    {
        var progress = InGameDownLoad.Instance.GetMapAssetDownLoadProgress(mapId);
        if (progress > 0.9999f)
        {
            if (this.onComplete != null)
            {
                this.onComplete();
                this.onComplete = null;
                Destroy(this.gameObject);
            }
        }
        else
        {
            m_Progress.text = StringUtility.Contact(Mathf.Clamp(progress * 100, 0, 100), "%");
            m_SliderProgress.fillAmount = Mathf.Clamp01(progress + 0.2f);
        }
    }
}
System/AssetVersion/MapAssetDownLoadProgress.cs.meta
New file
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 44c74a9a36ca1a348a5c08244bd44eaf
timeCreated: 1543058092
licenseType: Pro
MonoImporter:
  serializedVersion: 2
  defaultReferences: []
  executionOrder: 0
  icon: {instanceID: 0}
  userData:
  assetBundleName:
  assetBundleVariant:
System/WorldMap/WorldMapAreaBehaviour.cs
@@ -37,15 +37,12 @@
            get { return m_NewUnLockArrowPoint; }
        }
        public Transform playerHead {
            get {
                return m_PlayerHead;
            }
        }
        public Transform playerHead { get { return m_PlayerHead; } }
        WorldMapArea m_MapArea;
        float downTime = 0f;
        MapAssetDownLoadProgress mapAssetDownLoadProgress;
        MapModel model { get { return ModelCenter.Instance.GetModel<MapModel>(); } }
        TreasureModel treasureModel { get { return ModelCenter.Instance.GetModel<TreasureModel>(); } }
@@ -100,6 +97,10 @@
        private void OnDisable()
        {
            if (mapAssetDownLoadProgress != null)
            {
                mapAssetDownLoadProgress.OnComplete(null);
            }
            StopAllCoroutines();
        }
@@ -138,7 +139,36 @@
                        }
                        MapTransferUtility.Instance.Clear();
                        model.RequestMapTransport(m_MapArea.id);
                        var assetDownLoadProgress = InGameDownLoad.Instance.GetMapAssetDownLoadProgress(m_MapArea.id);
                        if (assetDownLoadProgress < 1f)
                        {
                            if (mapAssetDownLoadProgress != null)
                            {
                                var behaviour = UIUtility.CreateWidget("MapAssetDownLoadProgress", "MapAssetDownLoadProgress");
                                mapAssetDownLoadProgress = behaviour.GetComponent<MapAssetDownLoadProgress>();
                                behaviour.transform.SetParentEx(m_Conainter.transform, Vector3.zero, Vector3.zero, Vector3.one);
                            }
                            mapAssetDownLoadProgress.mapId = m_MapArea.id;
                            mapAssetDownLoadProgress.OnComplete(() =>
                            {
                                model.RequestMapTransport(m_MapArea.id);
                            });
                            if (InGameDownLoad.Instance.state == InGameDownLoad.State.DownLoad)
                            {
                                SysNotifyMgr.Instance.ShowTip("MapAssetDowning");
                            }
                            else
                            {
                                InGameDownLoad.Instance.TryDownLoad(InGameDownLoad.Dominant.Whole);
                            }
                        }
                        else
                        {
                            model.RequestMapTransport(m_MapArea.id);
                        }
                    }
                }
            }