Exemplo n.º 1
0
        // Token: 0x06000055 RID: 85 RVA: 0x00004BB0 File Offset: 0x00002DB0
        public static tk2dSpriteAnimationClip BuildAnimation(AIAnimator aiAnimator, string name, string spriteDirectory, int fps)
        {
            tk2dSpriteCollectionData tk2dSpriteCollectionData = aiAnimator.GetComponent <tk2dSpriteCollectionData>();
            bool flag = !tk2dSpriteCollectionData;

            if (flag)
            {
                tk2dSpriteCollectionData = SpriteBuilder.ConstructCollection(aiAnimator.gameObject, aiAnimator.name + "_collection");
            }
            string[]   resourceNames = ResourceExtractor.GetResourceNames();
            List <int> list          = new List <int>();

            for (int i = 0; i < resourceNames.Length; i++)
            {
                bool flag2 = resourceNames[i].StartsWith(spriteDirectory.Replace('/', '.'), StringComparison.OrdinalIgnoreCase);
                if (flag2)
                {
                    list.Add(SpriteBuilder.AddSpriteToCollection(resourceNames[i], tk2dSpriteCollectionData));
                }
            }
            bool flag3 = list.Count == 0;

            if (flag3)
            {
                Tools.PrintError <string>("No sprites found for animation " + name, "FF0000");
            }
            tk2dSpriteAnimationClip tk2dSpriteAnimationClip = SpriteBuilder.AddAnimation(aiAnimator.spriteAnimator, tk2dSpriteCollectionData, list, name, tk2dSpriteAnimationClip.WrapMode.Loop);

            tk2dSpriteAnimationClip.fps = (float)fps;
            return(tk2dSpriteAnimationClip);
        }
Exemplo n.º 2
0
        public static tk2dSpriteAnimationClip BuildAnimation(AIAnimator aiAnimator, string name, string spriteDirectory, int fps)
        {
            tk2dSpriteCollectionData collection = aiAnimator.GetComponent <tk2dSpriteCollectionData>();

            if (!collection)
            {
                collection = SpriteBuilder.ConstructCollection(aiAnimator.gameObject, $"{aiAnimator.name}_collection");
            }

            string[]   resources = ResourceExtractor.GetResourceNames();
            List <int> indices   = new List <int>();

            for (int i = 0; i < resources.Length; i++)
            {
                if (resources[i].StartsWith(spriteDirectory.Replace('/', '.'), StringComparison.OrdinalIgnoreCase))
                {
                    indices.Add(SpriteBuilder.AddSpriteToCollection(resources[i], collection));
                }
            }
            if (indices.Count == 0)
            {
                Tools.PrintError($"No sprites found for animation {name}");
            }
            tk2dSpriteAnimationClip clip = SpriteBuilder.AddAnimation(aiAnimator.spriteAnimator, collection, indices, name, tk2dSpriteAnimationClip.WrapMode.Loop);

            clip.fps = fps;
            return(clip);
        }