Esempio n. 1
0
        private static AnimationSet <CharacterImasMotionAsset> LoadDanceLegacy([NotNull] string filePath, int motionNumber, int formationNumber, out int suggestedPosition)
        {
            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;
                    }
                }
            }

            suggestedPosition = GetSuggestedDancePosition(manager);

            return(AnimationSet.Create(dan, apg, apa, bpg));
        }
Esempio n. 2
0
        public static AnimationSet <CharacterImasMotionAsset> LoadCamera([NotNull] string filePath)
        {
            CharacterImasMotionAsset cam = null, apa = null, apg = null, bpg = null;

            const string defCamEnds         = "_cam.imo";
            const string apaCamEnds         = "_apa.imo";
            const string apgCamEnds         = "_apg.imo";
            const string bpgCamEnds         = "_bpg.imo";
            const string apaPortraitCamEnds = "_tate_apa.imo";
            const string apgPortraitCamEnds = "_tate_apg.imo";
            const string bpgPortraitCamEnds = "_tate_bpg.imo"; // should not exist

            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.");
                    }

                    if (behaviour.m_Name.EndsWith(defCamEnds))
                    {
                        cam = ser.Deserialize <CharacterImasMotionAsset>(behaviour);
                    }
                    else if (behaviour.m_Name.EndsWith(apaCamEnds) && !behaviour.m_Name.EndsWith(apaPortraitCamEnds))
                    {
                        apa = ser.Deserialize <CharacterImasMotionAsset>(behaviour);
                    }
                    else if (behaviour.m_Name.EndsWith(apgCamEnds) && !behaviour.m_Name.EndsWith(apgPortraitCamEnds))
                    {
                        apg = ser.Deserialize <CharacterImasMotionAsset>(behaviour);
                    }
                    else if (behaviour.m_Name.EndsWith(bpgCamEnds) && !behaviour.m_Name.EndsWith(bpgPortraitCamEnds))
                    {
                        bpg = ser.Deserialize <CharacterImasMotionAsset>(behaviour);
                    }

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

            return(AnimationSet.Create(cam, apg, apa, bpg));
        }
Esempio n. 3
0
        private static AnimationSet <AnimationClip> LoadDanceCompiled([NotNull] string filePath, int motionNumber, int formationNumber, out int suggestedPosition)
        {
            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;
                    }
                }
            }

            suggestedPosition = GetSuggestedDancePosition(manager);

            return(AnimationSet.Create(dan, apg, apa, bpg));
        }
Esempio n. 4
0
        public static LoadedDance LoadDance([NotNull] string filePath, int songPosition)
        {
            IBodyAnimationSource danSource = null, apaSource = null, apgSource = null;
            var danceAnimationLoaded = false;
            var suggestedPosition    = InvalidDancePosition;

            // 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.

            if (!danceAnimationLoaded)
            {
                // First try with legacy bundles
                var(dan, apa, apg) = LoadDanceLegacy(filePath, songPosition, out suggestedPosition);

                if (dan != null)
                {
                    danSource            = new LegacyBodyAnimationSource(dan);
                    danceAnimationLoaded = true;
                }

                if (apa != null)
                {
                    apaSource = new LegacyBodyAnimationSource(apa);
                }

                if (apg != null)
                {
                    apgSource = new LegacyBodyAnimationSource(apg);
                }
            }

            if (!danceAnimationLoaded)
            {
                // If failed, try the new one (from ~mid 2018?)
                var(dan, apa, apg) = LoadDanceCompiled(filePath, songPosition, out suggestedPosition);

                if (dan != null)
                {
                    danSource            = new CompiledBodyAnimationSource(dan);
                    danceAnimationLoaded = true;
                }

                if (apa != null)
                {
                    apaSource = new CompiledBodyAnimationSource(apa);
                }

                if (apg != null)
                {
                    apgSource = new CompiledBodyAnimationSource(apg);
                }
            }

            var animationSet = AnimationSet.Create(danSource, apaSource, apgSource);

            return(new LoadedDance(animationSet, suggestedPosition));
        }
Esempio n. 5
0
        public static LoadedDance LoadDance([NotNull] string filePath, int motionNumber, int formationNumber)
        {
            IBodyAnimationSource defaultSource = null, anotherSource = null, specialSource = null, gorgeousSource = null;
            bool anyAnimationLoaded;
            var  suggestedPosition = InvalidDancePosition;

            // 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, out 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, out 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.Create(defaultSource, specialSource, anotherSource, gorgeousSource);

            return(new LoadedDance(animationSet, suggestedPosition));
        }