Esempio n. 1
0
        protected virtual void OnDisable()
        {
            CameraHandler.RemoveMapRotationListener(OnMapRotationChanged);
            DestroyAttachedEffects();
            if (null != m_playableDirector)
            {
                TimelineContextUtility.ClearFightContext(m_playableDirector);
                m_playableDirector.Stop();
                m_playableDirector.set_playableAsset(null);
            }
            if (m_animationCallback != null)
            {
                m_animationCallback.Release();
                m_animationCallback = null;
            }
            ReleaseAnimator();
            AnimatedCharacterData animatedCharacterData = GetAnimatedCharacterData();

            if (null != animatedCharacterData)
            {
                animatedCharacterData.UnloadTimelineResources();
                ClearAnimatedCharacterData();
                AssetManager.UnloadAssetBundle(AssetBundlesUtility.GetAnimatedCharacterDataBundle(m_animatedCharacterDataBundleCategory));
                m_animatedCharacterDataBundleCategory = BundleCategory.None;
            }
            if (m_activeCharacterDataBundleCategory != 0)
            {
                AssetManager.UnloadAssetBundle(AssetBundlesUtility.GetAnimatedCharacterDataBundle(m_activeCharacterDataBundleCategory));
                m_activeCharacterDataBundleCategory = BundleCategory.None;
            }
        }
Esempio n. 2
0
        public IEnumerator ChangeAnimatedCharacterData(int skinId, Gender gender)
        {
            if (!RuntimeData.characterSkinDefinitions.TryGetValue(skinId, out CharacterSkinDefinition characterSkinDefinition))
            {
                Log.Error($"Could not find character skin definition with id {skinId}.", 211, "C:\\BuildAgents\\AgentB\\work\\cub_client_win64_develop\\client\\DofusCube.Unity\\Assets\\Core\\Code\\Maps\\Objects\\CharacterObject.cs");
                yield break;
            }
            BundleCategory         bundleCategory    = characterSkinDefinition.bundleCategory;
            string                 bundleName        = AssetBundlesUtility.GetAnimatedCharacterDataBundle(bundleCategory);
            AssetBundleLoadRequest bundleLoadRequest = AssetManager.LoadAssetBundle(bundleName);

            m_activeCharacterDataBundleCategory = bundleCategory;
            while (!bundleLoadRequest.get_isDone())
            {
                yield return(null);
            }
            if (AssetManagerError.op_Implicit(bundleLoadRequest.get_error()) != 0)
            {
                Log.Error($"Failed to load asset bundle named '{bundleName}' for character skin {characterSkinDefinition.get_displayName()} ({characterSkinDefinition.get_id()}): {bundleLoadRequest.get_error()}", 230, "C:\\BuildAgents\\AgentB\\work\\cub_client_win64_develop\\client\\DofusCube.Unity\\Assets\\Core\\Code\\Maps\\Objects\\CharacterObject.cs");
                yield break;
            }
            AssetReference animatedCharacterDataReference = characterSkinDefinition.GetAnimatedCharacterDataReference(gender);
            AssetLoadRequest <AnimatedCharacterData> animatedCharacterDataLoadRequest = animatedCharacterDataReference.LoadFromAssetBundleAsync <AnimatedCharacterData>(bundleName);

            while (!animatedCharacterDataLoadRequest.get_isDone())
            {
                yield return(null);
            }
            if (AssetManagerError.op_Implicit(animatedCharacterDataLoadRequest.get_error()) != 0)
            {
                AssetManager.UnloadAssetBundle(bundleName);
                m_activeCharacterDataBundleCategory = BundleCategory.None;
                Log.Error(string.Format("Failed to load requested {0} asset from bundle '{1}' for character skin {2} ({3}): {4}", "AnimatedCharacterData", bundleName, characterSkinDefinition.get_displayName(), characterSkinDefinition.get_id(), animatedCharacterDataLoadRequest.get_error()), 247, "C:\\BuildAgents\\AgentB\\work\\cub_client_win64_develop\\client\\DofusCube.Unity\\Assets\\Core\\Code\\Maps\\Objects\\CharacterObject.cs");
                yield break;
            }
            AnimatedCharacterData newAnimatedCharacterData = animatedCharacterDataLoadRequest.get_asset();

            yield return(newAnimatedCharacterData.LoadTimelineResources());

            AnimatedCharacterData animatedCharacterData = GetAnimatedCharacterData();

            if (null != animatedCharacterData)
            {
                string animatedCharacterDataBundle = AssetBundlesUtility.GetAnimatedCharacterDataBundle(m_animatedCharacterDataBundleCategory);
                animatedCharacterData.UnloadTimelineResources();
                AssetManager.UnloadAssetBundle(animatedCharacterDataBundle);
                m_animatedCharacterDataBundleCategory = BundleCategory.None;
            }
            SetAnimatedCharacterData(newAnimatedCharacterData);
            m_animatedCharacterDataBundleCategory = m_activeCharacterDataBundleCategory;
            m_activeCharacterDataBundleCategory   = BundleCategory.None;
            IAnimator2D animator       = GetAnimator();
            int         animationFrame = animator.get_currentFrame();

            yield return(SetAnimatorDefinition());

            animator.set_currentFrame(animationFrame);
        }
Esempio n. 3
0
        private IEnumerator LoadCharacterSkin()
        {
            if (!string.IsNullOrEmpty(m_lastLoadedCharacterBundle))
            {
                this.UnloadAssetBundle(m_lastLoadedCharacterBundle, true, true);
                m_lastLoadedCharacterBundle = null;
            }
            PlayerData instance = PlayerData.instance;
            Gender     gender   = instance.gender;
            Id <CharacterSkinDefinition> skin = instance.Skin;

            if (skin == null || !RuntimeData.characterSkinDefinitions.TryGetValue(skin.value, out CharacterSkinDefinition characterSkinDefinition))
            {
                yield break;
            }
            BundleCategory         bundleCategory    = characterSkinDefinition.bundleCategory;
            string                 bundleName        = m_lastLoadedCharacterBundle = AssetBundlesUtility.GetAnimatedCharacterDataBundle(bundleCategory);
            AssetBundleLoadRequest bundleLoadRequest = this.LoadAssetBundle(bundleName);

            while (!bundleLoadRequest.get_isDone())
            {
                yield return(null);
            }
            if (AssetManagerError.op_Implicit(bundleLoadRequest.get_error()) != 0)
            {
                Log.Error($"Failed to load asset bundle named '{bundleName}' for character skin {characterSkinDefinition.get_displayName()} ({characterSkinDefinition.get_id()}): {bundleLoadRequest.get_error()}", 253, "C:\\BuildAgents\\AgentB\\work\\cub_client_win64_develop\\client\\DofusCube.Unity\\Assets\\Core\\Code\\States\\HavreDimension\\HavreDimensionMainState.cs");
                yield break;
            }
            AssetReference animatedCharacterDataReference = characterSkinDefinition.GetAnimatedCharacterDataReference(gender);
            AssetLoadRequest <AnimatedCharacterData> animatedCharacterDataLoadRequest = animatedCharacterDataReference.LoadFromAssetBundleAsync <AnimatedCharacterData>(bundleName);

            while (!animatedCharacterDataLoadRequest.get_isDone())
            {
                yield return(null);
            }
            if (AssetManagerError.op_Implicit(animatedCharacterDataLoadRequest.get_error()) != 0)
            {
                this.UnloadAssetBundle(bundleName, true, true);
                Log.Error(string.Format("Failed to load {0} asset from bundle '{1}' for character skin {2} ({3}): {4}", "AnimatedCharacterData", bundleName, characterSkinDefinition.get_displayName(), characterSkinDefinition.get_id(), animatedCharacterDataLoadRequest.get_error()), 269, "C:\\BuildAgents\\AgentB\\work\\cub_client_win64_develop\\client\\DofusCube.Unity\\Assets\\Core\\Code\\States\\HavreDimension\\HavreDimensionMainState.cs");
                yield break;
            }
            AnimatedCharacterData animatedCharacterData = animatedCharacterDataLoadRequest.get_asset();

            yield return(animatedCharacterData.LoadTimelineResources());

            AnimatedFightCharacterData animatedFightCharacterData = animatedCharacterData as AnimatedFightCharacterData;
            AnimatedObjectDefinition   animatedObjectDefinition   = animatedFightCharacterData.animatedObjectDefinition;

            m_havreMap.character.SetCharacterData(animatedFightCharacterData, animatedObjectDefinition);
            m_loadCharacterCoroutine = null;
        }
 public static string GetAnimatedCharacterDataBundle(BundleCategory bundleCategory)
 {
     return("core/characters/" + bundleCategory.GetBundleName());
 }
		public static string GetBundleName(this BundleCategory value)
		{
			return s_bundleSubCategoryToBundleName[value];
		}