| | |
| | | {
|
| | | public static int targetMapResId = 0;
|
| | |
|
| | | [SerializeField] RectTransform m_ContainerNormal;
|
| | | [SerializeField] Image m_BackGround;
|
| | | [SerializeField] RectTransform m_ContainerFunctions;
|
| | | [SerializeField] LoadingFunctionShow[] m_FunctionShows;
|
| | |
| | | [SerializeField] RectTransform m_ContainerMapDescription;
|
| | | [SerializeField] Image m_MapDescription;
|
| | |
|
| | | [SerializeField] RectTransform m_CrossServerOneVsOne;
|
| | | [SerializeField] Image m_MyPortrayal;
|
| | | [SerializeField] Image m_OpponentPortrayal;
|
| | | [SerializeField] Text m_MyName;
|
| | | [SerializeField] Text m_OpponentName;
|
| | |
|
| | | float refProgress = 0f;
|
| | | float expectDuration = 5f;
|
| | |
|
| | | LoadingType loadingType = LoadingType.Normal;
|
| | |
|
| | | #region Built-in
|
| | | protected override void BindController()
|
| | |
| | |
|
| | | protected override void OnPreOpen()
|
| | | {
|
| | | var useDefautBackGround = false;
|
| | | if (!AssetSource.uiFromEditor)
|
| | | if (!CrossServerLogin.Instance.oneVsOnePlayerData.alreadyLogin)
|
| | | {
|
| | | var assetVersion = AssetVersionUtility.GetAssetVersion("ui/sprite/loadingbg");
|
| | | if (assetVersion == null || !assetVersion.localValid)
|
| | | {
|
| | | useDefautBackGround = true;
|
| | | }
|
| | | }
|
| | |
|
| | | if (useDefautBackGround)
|
| | | {
|
| | | var sprite = BuiltInLoader.LoadSprite("Launch_1");
|
| | | m_BackGround.overrideSprite = sprite;
|
| | | m_ContainerMapName.gameObject.SetActive(false);
|
| | | m_ContainerMapDescription.gameObject.SetActive(false);
|
| | | m_ContainerFunctions.gameObject.SetActive(false);
|
| | | loadingType = LoadingType.CrossServerOneOne;
|
| | | }
|
| | | else
|
| | | {
|
| | | var playerLevel = PlayerDatas.Instance.baseData.LV == 0 ? PlayerDatas.Instance.loginInfo.LV : PlayerDatas.Instance.baseData.LV;
|
| | | var mapResConfig = Config.Instance.Get<MapResourcesConfig>(targetMapResId);
|
| | | if (mapResConfig != null)
|
| | | loadingType = LoadingType.Normal;
|
| | | }
|
| | |
|
| | | if (loadingType == LoadingType.CrossServerOneOne)
|
| | | {
|
| | | m_ContainerNormal.gameObject.SetActive(false);
|
| | | m_CrossServerOneVsOne.gameObject.SetActive(true);
|
| | |
|
| | | m_MyName.text = CrossServerLogin.Instance.oneVsOnePlayerData.myName;
|
| | | m_OpponentName.text = CrossServerLogin.Instance.oneVsOnePlayerData.opponentName;
|
| | | }
|
| | | else
|
| | | {
|
| | | m_ContainerNormal.gameObject.SetActive(true);
|
| | | m_CrossServerOneVsOne.gameObject.SetActive(false);
|
| | | var useDefautBackGround = false;
|
| | | if (!AssetSource.uiFromEditor)
|
| | | {
|
| | | var loadingBackGroudConfig = LoadingBackGroundConfig.Get(mapResConfig.DataID, mapResConfig.LineID);
|
| | | if (loadingBackGroudConfig != null && loadingBackGroudConfig.icons.Length > 0)
|
| | | var assetVersion = AssetVersionUtility.GetAssetVersion("ui/sprite/loadingbg");
|
| | | if (assetVersion == null || !assetVersion.localValid)
|
| | | {
|
| | | var icons = new List<string>();
|
| | | var json = JsonMapper.ToObject(loadingBackGroudConfig.levelLimit);
|
| | | useDefautBackGround = true;
|
| | | }
|
| | | }
|
| | |
|
| | | for (var i = 0; i < loadingBackGroudConfig.icons.Length; i++)
|
| | | if (useDefautBackGround)
|
| | | {
|
| | | var sprite = BuiltInLoader.LoadSprite("Launch_1");
|
| | | m_BackGround.overrideSprite = sprite;
|
| | | m_ContainerMapName.gameObject.SetActive(false);
|
| | | m_ContainerMapDescription.gameObject.SetActive(false);
|
| | | m_ContainerFunctions.gameObject.SetActive(false);
|
| | | }
|
| | | else
|
| | | {
|
| | | var playerLevel = PlayerDatas.Instance.baseData.LV == 0 ? PlayerDatas.Instance.loginInfo.LV : PlayerDatas.Instance.baseData.LV;
|
| | | var mapResConfig = Config.Instance.Get<MapResourcesConfig>(targetMapResId);
|
| | | if (mapResConfig != null)
|
| | | {
|
| | | var loadingBackGroudConfig = LoadingBackGroundConfig.Get(mapResConfig.DataID, mapResConfig.LineID);
|
| | | if (loadingBackGroudConfig != null && loadingBackGroudConfig.icons.Length > 0)
|
| | | {
|
| | | var icon = loadingBackGroudConfig.icons[i];
|
| | | if (json.Keys.Contains(icon))
|
| | | var icons = new List<string>();
|
| | | var json = JsonMapper.ToObject(loadingBackGroudConfig.levelLimit);
|
| | |
|
| | | for (var i = 0; i < loadingBackGroudConfig.icons.Length; i++)
|
| | | {
|
| | | var min = 0;
|
| | | var max = int.MaxValue;
|
| | | var levelLimit = json[icon].ToString();
|
| | | var levelsMatch = Regex.Matches(levelLimit, "\\d+");
|
| | | if (levelsMatch.Count > 0)
|
| | | var icon = loadingBackGroudConfig.icons[i];
|
| | | if (json.Keys.Contains(icon))
|
| | | {
|
| | | min = int.Parse(levelsMatch[0].Value);
|
| | | }
|
| | | var min = 0;
|
| | | var max = int.MaxValue;
|
| | | var levelLimit = json[icon].ToString();
|
| | | var levelsMatch = Regex.Matches(levelLimit, "\\d+");
|
| | | if (levelsMatch.Count > 0)
|
| | | {
|
| | | min = int.Parse(levelsMatch[0].Value);
|
| | | }
|
| | |
|
| | | if (levelsMatch.Count > 1)
|
| | | {
|
| | | max = int.Parse(levelsMatch[1].Value);
|
| | | }
|
| | | if (levelsMatch.Count > 1)
|
| | | {
|
| | | max = int.Parse(levelsMatch[1].Value);
|
| | | }
|
| | |
|
| | | if (playerLevel > min && playerLevel < max)
|
| | | if (playerLevel > min && playerLevel < max)
|
| | | {
|
| | | icons.Add(icon);
|
| | | }
|
| | | }
|
| | | else
|
| | | {
|
| | | icons.Add(icon);
|
| | | }
|
| | | }
|
| | |
|
| | | var randomIndex = UnityEngine.Random.Range(0, loadingBackGroudConfig.icons.Length > 1 ? icons.Count + 1 : 1);
|
| | | if (randomIndex == icons.Count)
|
| | | {
|
| | | m_BackGround.SetSprite(GeneralDefine.LoadLV);
|
| | | m_ContainerFunctions.gameObject.SetActive(true);
|
| | | var functions = GetShowFunctions(playerLevel);
|
| | | for (int i = 0; i < m_FunctionShows.Length; i++)
|
| | | {
|
| | | var show = m_FunctionShows[i];
|
| | | show.Display(functions[i]);
|
| | | }
|
| | | }
|
| | | else
|
| | | {
|
| | | icons.Add(icon);
|
| | | m_BackGround.SetSprite(icons[randomIndex]);
|
| | | m_ContainerFunctions.gameObject.SetActive(false);
|
| | | }
|
| | | }
|
| | |
|
| | | var randomIndex = UnityEngine.Random.Range(0, loadingBackGroudConfig.icons.Length > 1 ? icons.Count + 1 : 1);
|
| | | if (randomIndex == icons.Count)
|
| | | {
|
| | | m_BackGround.SetSprite(GeneralDefine.LoadLV);
|
| | | m_ContainerFunctions.gameObject.SetActive(true);
|
| | | var functions = GetShowFunctions(playerLevel);
|
| | | for (int i = 0; i < m_FunctionShows.Length; i++)
|
| | | if (loadingBackGroudConfig != null && !string.IsNullOrEmpty(loadingBackGroudConfig.name))
|
| | | {
|
| | | var show = m_FunctionShows[i];
|
| | | show.Display(functions[i]);
|
| | | m_ContainerMapName.gameObject.SetActive(true);
|
| | | m_MapName.SetSprite(loadingBackGroudConfig.name);
|
| | | }
|
| | | }
|
| | | else
|
| | | {
|
| | | m_BackGround.SetSprite(icons[randomIndex]);
|
| | | m_ContainerFunctions.gameObject.SetActive(false);
|
| | | }
|
| | | else
|
| | | {
|
| | | m_ContainerMapName.gameObject.SetActive(false);
|
| | | }
|
| | |
|
| | | if (loadingBackGroudConfig != null && !string.IsNullOrEmpty(loadingBackGroudConfig.name))
|
| | | {
|
| | | m_ContainerMapName.gameObject.SetActive(true);
|
| | | m_MapName.SetSprite(loadingBackGroudConfig.name);
|
| | | }
|
| | | else
|
| | | {
|
| | | m_ContainerMapName.gameObject.SetActive(false);
|
| | | }
|
| | | if (loadingBackGroudConfig != null && !string.IsNullOrEmpty(loadingBackGroudConfig.description))
|
| | | {
|
| | | m_ContainerMapDescription.gameObject.SetActive(true);
|
| | | m_MapDescription.SetSprite(loadingBackGroudConfig.description);
|
| | | }
|
| | | else
|
| | | {
|
| | | m_ContainerMapDescription.gameObject.SetActive(false);
|
| | | }
|
| | |
|
| | | if (loadingBackGroudConfig != null && !string.IsNullOrEmpty(loadingBackGroudConfig.description))
|
| | | {
|
| | | m_ContainerMapDescription.gameObject.SetActive(true);
|
| | | m_MapDescription.SetSprite(loadingBackGroudConfig.description);
|
| | | }
|
| | | else
|
| | | {
|
| | | m_ContainerMapDescription.gameObject.SetActive(false);
|
| | | }
|
| | |
|
| | | }
|
| | | }
|
| | |
|
| | | if (Application.platform == RuntimePlatform.IPhonePlayer)
|
| | | {
|
| | | m_ContainerProgress.gameObject.SetActive(false);
|
| | | }
|
| | | else
|
| | | {
|
| | | m_ContainerProgress.gameObject.SetActive(true);
|
| | | m_ProgressSlider.value = refProgress = 0f;
|
| | | StageManager.Instance.loadingProgressEvent += UpdateLoadingProgress;
|
| | | }
|
| | | }
|
| | |
|
| | | if (Application.platform == RuntimePlatform.IPhonePlayer)
|
| | | {
|
| | | m_ContainerProgress.gameObject.SetActive(false);
|
| | | }
|
| | | else
|
| | | {
|
| | | m_ContainerProgress.gameObject.SetActive(true);
|
| | | m_ProgressSlider.value = refProgress = 0f;
|
| | | StageManager.Instance.loadingProgressEvent += UpdateLoadingProgress;
|
| | | }
|
| | |
|
| | |
|
| | | }
|
| | |
|
| | | protected override void OnAfterOpen()
|
| | |
| | | {
|
| | | base.LateUpdate();
|
| | |
|
| | | refProgress = Mathf.Clamp01(refProgress + Time.deltaTime / expectDuration);
|
| | | m_ProgressSlider.value = refProgress;
|
| | | if (loadingType == LoadingType.Normal)
|
| | | {
|
| | | refProgress = Mathf.Clamp01(refProgress + Time.deltaTime / expectDuration);
|
| | | m_ProgressSlider.value = refProgress;
|
| | | }
|
| | | }
|
| | |
|
| | | void UpdateLoadingProgress(float _progress)
|
| | |
| | | return functions;
|
| | | }
|
| | |
|
| | |
|
| | | public enum LoadingType
|
| | | {
|
| | | Normal,
|
| | | CrossServerOneOne,
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | }
|