Ejemplo n.º 1
0
        public static UnitAnim Load(string save)
        {
            string[] content  = V_Animation.SplitString(save, "#ANIMATION#");
            UnitAnim unitAnim = new UnitAnim(content[1], V_Animation.V_LoadAnimationString(content[0], ANIMATION_FRAME_MULTIPLIER));

            return(unitAnim);
        }
Ejemplo n.º 2
0
        public static V_Skeleton_Anim[] V_LoadAnimationString(string readAllText, int animationFrameMultiplier = 2)
        {
            string[] content = V_Animation.SplitString(readAllText, "#ANIMATION#");
            List <V_Skeleton_Anim> animKeyframes = new List <V_Skeleton_Anim>();

            animKeyframes = V_Animation.Load_List <V_Skeleton_Anim>(content[0], V_Skeleton_Anim.Load, "#SKELETONANIMLIST#");

            // Duplicate frameCount
            foreach (V_Skeleton_Anim anim in animKeyframes)
            {
                foreach (V_Skeleton_Frame frame in anim.frames)
                {
                    frame.frameCount = frame.frameCount * animationFrameMultiplier; // Increase frameCount
                }
                anim.SetFrameRateOriginal(anim.GetFrameRateOriginal() / animationFrameMultiplier);
            }

            // Remake Tweens
            foreach (V_Skeleton_Anim anim in animKeyframes)
            {
                anim.RemakeTween();
            }

            return(animKeyframes.ToArray());
        }
Ejemplo n.º 3
0
        public string Save()
        {
            if (unitAnimList.IndexOf(this) == -1)
            {
                unitAnimList.Add(this);
            }
            List <V_Skeleton_Anim> animKeyframes = new List <V_Skeleton_Anim>();

            foreach (V_Skeleton_Anim anim in GetAnims())
            {
                V_Skeleton_Anim clonedKeyframes = anim.CloneOnlyKeyframes();
                animKeyframes.Add(clonedKeyframes);
            }

            // Reverse Animation Frame Multiplier
            foreach (V_Skeleton_Anim anim in animKeyframes)
            {
                foreach (V_Skeleton_Frame frame in anim.frames)
                {
                    frame.frameCount = frame.frameCount / ANIMATION_FRAME_MULTIPLIER; // Decrease frameCount
                }
                anim.SetFrameRateOriginal(anim.GetFrameRateOriginal() * ANIMATION_FRAME_MULTIPLIER);
            }



            string[] content = new string[] {
                "" + V_Animation.Save_List <V_Skeleton_Anim>(animKeyframes, V_Skeleton_Anim.Save_Static, "#SKELETONANIMLIST#"),
                "" + name,
            };
            return(string.Join("#ANIMATION#", content));
        }
Ejemplo n.º 4
0
        public static V_Skeleton_Anim Load(string save)
        {
            string[] content   = V_Animation.SplitString(save, "#SKELETONANIM#");
            BodyPart bodyPart  = BodyPart.Load(content[0]);
            float    frameRate = float.Parse(content[2]);

            V_Skeleton_Frame[] frames = V_Animation.Load_Array <V_Skeleton_Frame>(content[3], V_Skeleton_Frame.Load, "#SKELETONFRAMELIST#");

            return(new V_Skeleton_Anim(frames, bodyPart, frameRate));
        }
Ejemplo n.º 5
0
            public static HeaderData Load(string header)
            {
                string[]   content = V_Animation.SplitString(header, "#HEADER#");
                HeaderData headerData;

                headerData.saveByteLength    = int.Parse(content[0]);
                headerData.animationVersion  = content[1];
                headerData.date              = content[2];
                headerData.headerDataVersion = content[3];
                return(headerData);
            }
Ejemplo n.º 6
0
 public string Save()
 {
     // Returns a string to be used in savefiles
     string[] content = new string[] {
         "" + bodyPart.Save(),
         "",
         "" + frameRate,
         V_Animation.Save_Array <V_Skeleton_Frame>(frames, V_Skeleton_Frame.Save_Static, "#SKELETONFRAMELIST#")
     };
     return(string.Join("#SKELETONANIM#", content));
 }
Ejemplo n.º 7
0
 public static UnitAnimType GetUnitAnimType(string unitAnimTypeName)
 {
     V_Animation.Init();
     foreach (UnitAnimType unitAnimType in unitAnimTypeList)
     {
         if (unitAnimType.name == unitAnimTypeName)
         {
             return(unitAnimType);
         }
     }
     Debug.LogWarning("#### UNIT ANIM TYPE NOT FOUND: " + unitAnimTypeName);
     return(null);
 }
Ejemplo n.º 8
0
 public string Save()
 {
     //Returns a string to be used in savefiles
     string[] content = new string[] {
         "" + 99,
         V_Animation.Save_Array <Vector2>(uvs, delegate(Vector2 vec) { return(V_Animation.Save_Vector2(vec)); }, "#VECTOR2ARR#"),
         "" + customName,
         "" + id,
         "" + textureName,
         "" + textureWidth,
         "" + textureHeight,
     };
     return(string.Join("#UVTYPE#", content));
 }
Ejemplo n.º 9
0
        public static BodyPart Load(string save)
        {
            if (!save.Contains("#BODYPART#"))
            {
                // OLD Enum based BodyPart
                Old_BodyPart oldBodyPart = V_Animation.GetEnumFromString <Old_BodyPart>(save);
                return(new BodyPart((int)oldBodyPart));
            }
            string[] content = V_Animation.SplitString(save, "#BODYPART#");

            int preset = V_Animation.Parse_Int(content[0]);

            V_Animation.StringArrPushIfIndex(1, ref content, ((Old_BodyPart)preset).ToString());
            string customName = content[1];

            return(new BodyPart(preset, customName));
        }
Ejemplo n.º 10
0
        public V_UnitSkeleton(float frameRateMod, DelConvertLocalPositionToWorldPosition ConvertLocalPositionToWorldPosition, Action <Mesh> SetMesh)
        {
            V_Animation.Init();
            this.frameRateMod = frameRateMod;
            this.ConvertLocalPositionToWorldPosition = ConvertLocalPositionToWorldPosition;
            mesh = new Mesh();
            List <Vector3> vertices  = new List <Vector3>();
            List <Vector2> uvs       = new List <Vector2>();
            List <int>     triangles = new List <int>();

            mesh.triangles = null;
            mesh.vertices  = vertices.ToArray();
            mesh.uv        = uvs.ToArray();
            mesh.triangles = triangles.ToArray();

            SetMesh(mesh);

            PlayAnim(UnitAnim.DefaultAnimation, 1f, null, null, null);
        }
Ejemplo n.º 11
0
        public static UnitAnimType Load(string save)
        {
            string[] content = V_Animation.SplitString(save, "#UNITANIMTYPE#");

            UnitAnimType unitAnimType = new UnitAnimType(content[0]);

            unitAnimType.SetAnims(
                UnitAnim.Load(content[1]),
                UnitAnim.Load(content[2]),
                UnitAnim.Load(content[3]),
                UnitAnim.Load(content[4]),
                UnitAnim.Load(content[5]),
                UnitAnim.Load(content[6]),
                UnitAnim.Load(content[7]),
                UnitAnim.Load(content[8])
                );

            return(unitAnimType);
        }
Ejemplo n.º 12
0
 public string Save()
 {
     //Returns a string to be used in savefiles
     string[] content = new string[] {
         "" + frameCount,
         "" + V_Animation.Save_Vector3(pos),
         "" + size,
         "" + (int)rot,
         trigger,
         uvType.Save(),
         "" + scaleX,
         "" + scaleY,
         "" + sortingOrder,
         "" + V_Animation.Save_Vector2(pivot),
         "" + V_Animation.Save_Vector3(v00offset),
         "" + V_Animation.Save_Vector3(v01offset),
         "" + V_Animation.Save_Vector3(v10offset),
         "" + V_Animation.Save_Vector3(v11offset),
     };
     return(string.Join("#SKELETONFRAME#", content));
 }
Ejemplo n.º 13
0
        public static V_Skeleton_Frame Load(string save)
        {
            string[] content    = V_Animation.SplitString(save, "#SKELETONFRAME#");
            int      frameCount = int.Parse(content[0]);
            Vector3  pos        = V_Animation.Load_Vector3(content[1]);
            float    size       = float.Parse(content[2]);
            int      rot        = int.Parse(content[3]);

            V_Animation.StringArrPushIfIndex(4, ref content, "");
            string trigger = content[4];

            V_Animation.StringArrPushIfIndex(5, ref content, "");
            UVType uvType = UVType.Load(content[5]);

            V_Animation.StringArrPushIfIndex(6, ref content, "1");
            float scaleX = float.Parse(content[6]);

            V_Animation.StringArrPushIfIndex(7, ref content, "1");
            float scaleY = float.Parse(content[7]);

            V_Animation.StringArrPushIfIndex(8, ref content, "-100");
            int sortingOrder = int.Parse(content[8]);

            V_Animation.StringArrPushIfIndex(9, ref content, "0,0");
            Vector2 pivot = V_Animation.Load_Vector2(content[9]);

            V_Animation.StringArrPushIfIndex(10, ref content, "0,0");
            Vector2 v00offset = V_Animation.Load_Vector2(content[10]);

            V_Animation.StringArrPushIfIndex(11, ref content, "0,0");
            Vector2 v01offset = V_Animation.Load_Vector2(content[11]);

            V_Animation.StringArrPushIfIndex(12, ref content, "0,0");
            Vector2 v10offset = V_Animation.Load_Vector2(content[12]);

            V_Animation.StringArrPushIfIndex(13, ref content, "0,0");
            Vector2 v11offset = V_Animation.Load_Vector2(content[13]);

            return(new V_Skeleton_Frame(frameCount, pos, size, rot, trigger, uvType, scaleX, scaleY, sortingOrder, pivot, v00offset, v01offset, v10offset, v11offset));
        }
Ejemplo n.º 14
0
        private static void LoadFromResources()
        {
            //TextAsset animationResourceTreeTextAsset = Resources.Load<TextAsset>("AnimationData/animationResourceTreeTextAsset");
            //string folderCSV = animationResourceTreeTextAsset.text;
            string folderCSV = "_Default/Animations,Animations";//,AnimationTypes";

            string[] folderArr = V_Animation.SplitString(folderCSV, ",");
            foreach (string folder in folderArr)
            {
                if (folder != "")
                {
                    // Load resources in folder
                    TextAsset[] textAssetArr = Resources.LoadAll <TextAsset>("AnimationData/" + folder);
                    //Debug.Log("Animations folder: "+folder+"; Found Animations: "+ textAssetArr.Length);
                    foreach (TextAsset textAsset in textAssetArr)
                    {
                        //Debug.Log("Loading: "+textAsset.name);
                        byte[] byteArr = textAsset.bytes;

                        string readAllText;
                        SaveSystem.FileData fileData;
                        if (SaveSystem.Load(byteArr, out fileData))
                        {
                            // Loaded!
                            readAllText = fileData.save;
                        }
                        else
                        {
                            // Load failed!
                            readAllText = null;
                        }
                        UnitAnim unitAnim = UnitAnim.Load(readAllText);

                        unitAnimList.Add(unitAnim);
                    }
                }
            }
        }
Ejemplo n.º 15
0
        public static UVType Load(string save)
        {
            if (!save.Contains("#UVTYPE#"))
            {
                // OLD Enum based UVType
                //Debug.LogError("OLD Enum based UVType");

                //Old_UVType oldUvType = MyUtils.GetEnumFromString<Old_UVType>(save);
                //return new UVType((int)oldUvType);

                switch (save)
                {
                case "Foot":        return(UVType.dFoot);

                case "Body_Down":   return(UVType.dBodyDown);

                case "Body_Up":     return(UVType.dBodyUp);

                case "Body_Left":   return(UVType.dBodyLeft);

                case "Body_Right":  return(UVType.dBodyRight);

                case "Head_Down":   return(UVType.dHeadDown);

                case "Head_Up":     return(UVType.dHeadUp);

                case "Head_Left":   return(UVType.dHeadLeft);

                case "Head_Right":  return(UVType.dHeadRight);

                case "Hand":        return(UVType.dHand);

                case "Sword":       return(UVType.dWeapon);

                case "Sword_InvertH":   return(UVType.dWeapon_InvertH);
                }

                return(new UVType(save, 0f, 0f, 1f, 1f, "defaultSpriteSheet", 512, 512));
            }
            string[] content = V_Animation.SplitString(save, "#UVTYPE#");

            int preset = V_Animation.Parse_Int(content[0]);

            Vector2[] uvs = V_Animation.Load_Array <Vector2>(content[1], delegate(string str) { return(V_Animation.Load_Vector2(str)); }, "#VECTOR2ARR#");
            //MyUtils.StringArrPushIfIndex(2, ref content, ((Old_UVType)preset).ToString());
            V_Animation.StringArrPushIfIndex(2, ref content, "Head_Down");
            string customName = content[2];

            V_Animation.StringArrPushIfIndex(3, ref content, "0");
            int id = V_Animation.Parse_Int(content[3]);

            V_Animation.StringArrPushIfIndex(4, ref content, "");
            string textureName = content[4];

            V_Animation.StringArrPushIfIndex(5, ref content, "1024");
            int textureWidth = V_Animation.Parse_Int(content[5]);

            V_Animation.StringArrPushIfIndex(6, ref content, "1024");
            int textureHeight = V_Animation.Parse_Int(content[6]);

            return(new UVType(uvs, customName, id, textureName, textureWidth, textureHeight));
        }