Ejemplo n.º 1
0
        private static DanceAnimationSet <CharacterImasMotionAsset> LoadDanceLegacy([NotNull] string filePath, int motionNumber, int formationNumber)
        {
            CharacterImasMotionAsset dan = null, apa = null, apg = null, bpg = null;

            var danComp = $"{motionNumber:00}_dan.imo";
            var apaComp = $"{formationNumber:00}_apa.imo";
            var apgComp = $"{formationNumber:00}_apg.imo";
            var bpgComp = $"{formationNumber:00}_bpg.imo";

            var manager = new AssetsManager();

            manager.LoadFiles(filePath);

            var ser     = new ScriptableObjectSerializer();

            foreach (var assetFile in manager.assetsFileList)
            {
                foreach (var obj in assetFile.Objects)
                {
                    if (obj.type != ClassIDType.MonoBehaviour)
                    {
                        continue;
                    }

                    var behaviour = obj as MonoBehaviour;

                    if (behaviour == null)
                    {
                        throw new ArgumentException("An object serialized as MonoBehaviour is actually not a MonoBehaviour.");
                    }

                    // Can't use EndsWith() here: some bundles have ".asset" postfixes (alstar_01.imo.unity3d: _apa.imo, _dan_imo.asset, _apg.imo.asset)
                    if (behaviour.m_Name.Contains(danComp))
                    {
                        dan = ser.Deserialize <CharacterImasMotionAsset>(behaviour);
                    }
                    else if (behaviour.m_Name.Contains(apaComp))
                    {
                        apa = ser.Deserialize <CharacterImasMotionAsset>(behaviour);
                    }
                    else if (behaviour.m_Name.Contains(apgComp))
                    {
                        apg = ser.Deserialize <CharacterImasMotionAsset>(behaviour);
                    }
                    else if (behaviour.m_Name.Contains(bpgComp))
                    {
                        bpg = ser.Deserialize <CharacterImasMotionAsset>(behaviour);
                    }

                    if (dan != null && apa != null && apg != null && bpg != null)
                    {
                        break;
                    }
                }
            }

            var suggestedPosition = GetSuggestedDancePosition(manager);

            return(AnimationSet.CreateDance(suggestedPosition, dan, apg, apa, bpg));
        }
Ejemplo n.º 2
0
        private static DanceAnimationSet <AnimationClip> LoadDanceCompiled([NotNull] string filePath, int motionNumber, int formationNumber)
        {
            AnimationClip dan = null, apa = null, apg = null, bpg = null;

            var danComp = $"{motionNumber:00}_dan";
            var apaComp = $"{formationNumber:00}_apa";
            var apgComp = $"{formationNumber:00}_apg";
            var bpgComp = $"{formationNumber:00}_bpg";

            var manager = new AssetsManager();

            manager.LoadFiles(filePath);

            foreach (var assetFile in manager.assetsFileList)
            {
                foreach (var obj in assetFile.Objects)
                {
                    if (obj.type != ClassIDType.AnimationClip)
                    {
                        continue;
                    }

                    var clip = obj as AnimationClip;

                    if (clip == null)
                    {
                        throw new ArgumentNullException(nameof(clip), "One animation clip is null.");
                    }

                    if (clip.m_Name.Contains(danComp))
                    {
                        dan = clip;
                    }
                    else if (clip.m_Name.Contains(apaComp))
                    {
                        apa = clip;
                    }
                    else if (clip.m_Name.Contains(apgComp))
                    {
                        apg = clip;
                    }
                    else if (clip.m_Name.Contains(bpgComp))
                    {
                        bpg = clip;
                    }

                    if (dan != null && apa != null && apg != null && bpg != null)
                    {
                        break;
                    }
                }
            }

            var suggestedPosition = GetSuggestedDancePosition(manager);

            return(AnimationSet.CreateDance(suggestedPosition, dan, apg, apa, bpg));
        }
Ejemplo n.º 3
0
        public static DanceAnimationSet <IBodyAnimationSource> LoadDance([NotNull] string filePath, int motionNumber, int formationNumber)
        {
            IBodyAnimationSource defaultSource = null, anotherSource = null, specialSource = null, gorgeousSource = null;
            bool anyAnimationLoaded;
            int  suggestedPosition;

            // About number of main dance animations and special/another appeal animations:
            // Most songs have 1 dance animation (i.e. animation for 1 idol, multiplied by 3/4/5 etc.) and 1 appeal animation
            // (i.e. for 1 idol when player completes FC before the big note). Or, n dance animation and n appeal animations
            // (e.g. 虹色letters [nijile], n=2 for position 1 and 2). Some songs have 1 dance animation and n appeal animations
            // (e.g. クルリウタ [kururi], n=3 for position 1, 2 and 3). Rarely a song has n dance animations and 1 appeal animation
            // (i.e. RE@DY!! [ready0], n=5). For each dance animation, there is a dan_ object; for each appeal animation, there
            // is an apa_ or apg_ object. So there isn't really a guarantee when dan, apa or apg is non-null.

            {
                // First try with legacy bundles
                var loaded = LoadDanceLegacy(filePath, motionNumber, formationNumber);

                suggestedPosition  = loaded.SuggestedPosition;
                anyAnimationLoaded = loaded.Default != null || loaded.Special != null || loaded.Another != null || loaded.Gorgeous != null;

                if (loaded.Default != null)
                {
                    defaultSource = new LegacyBodyAnimationSource(loaded.Default);
                }

                if (loaded.Special != null)
                {
                    specialSource = new LegacyBodyAnimationSource(loaded.Special);
                }

                if (loaded.Another != null)
                {
                    anotherSource = new LegacyBodyAnimationSource(loaded.Another);
                }

                if (loaded.Gorgeous != null)
                {
                    gorgeousSource = new LegacyBodyAnimationSource(loaded.Gorgeous);
                }
            }

            if (!anyAnimationLoaded)
            {
                // If failed, try the new one (from ~mid 2018?)
                var loaded = LoadDanceCompiled(filePath, motionNumber, formationNumber);

                suggestedPosition = loaded.SuggestedPosition;

                if (loaded.Default != null)
                {
                    defaultSource = new CompiledBodyAnimationSource(loaded.Default);
                }

                if (loaded.Special != null)
                {
                    specialSource = new CompiledBodyAnimationSource(loaded.Special);
                }

                if (loaded.Another != null)
                {
                    anotherSource = new CompiledBodyAnimationSource(loaded.Another);
                }

                if (loaded.Gorgeous != null)
                {
                    gorgeousSource = new CompiledBodyAnimationSource(loaded.Gorgeous);
                }
            }

            var animationSet = AnimationSet.CreateDance(suggestedPosition, defaultSource, specialSource, anotherSource, gorgeousSource);

            return(animationSet);
        }