public bool Update(float deltaTime) { bool allLooped = true; if (hasVariableSortingOrder) { for (int i = 0; i < animsLength; i++) { for (int j = i + 1; j < animsLength; j++) { if (anims[j].GetCurrentFrame().sortingOrder < anims[i].GetCurrentFrame().sortingOrder) { V_Skeleton_Anim tmp = anims[j]; anims[j] = anims[i]; anims[i] = tmp; } } } } for (int i = 0; i < animsLength; i++) { V_Skeleton_Anim anim = anims[i]; anim.Update(deltaTime); allLooped = allLooped && anim.looped; } return(allLooped); }
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)); }
public void ApplyAimDir(Vector3 dir, Vector3 positionOffset, int bonusSortingOrder) { // Anim default dir is pointing RIGHT = Vector3(1, 0); float aimAngle = GetAngleFromVectorFloat(dir); //foreach (V_Skeleton_Anim skeletonAnim in anims) { for (int i = 0; i < anims.Length; i++) { V_Skeleton_Anim skeletonAnim = anims[i]; // Make sure the skeleton updater that will use this anim knows the sorting order might change //skeletonAnim.defaultHasVariableSortingOrder = true; V_Skeleton_Frame[] skeletonFrameArr = skeletonAnim.GetFrames(); for (int j = 0; j < skeletonFrameArr.Length; j++) { V_Skeleton_Frame skeletonFrame = skeletonFrameArr[j]; // Rotate based on base position Vector3 framePosition = skeletonFrame.GetBasePosition(); Vector3 newFramePosition = ApplyRotationToVector(framePosition, dir); skeletonFrame.ApplyTemporaryPosition(newFramePosition + positionOffset); // Rotate based on base rotation skeletonFrame.ApplyBonusRotation(aimAngle); // Apply bonus sorting order skeletonFrame.ApplyBonusSortingOrder(bonusSortingOrder); } } }
public void AddAnim(V_Skeleton_Anim skeletonAnim) { List <V_Skeleton_Anim> animList = new List <V_Skeleton_Anim>(anims); animList.Add(skeletonAnim); SetAnimsArr(animList.ToArray()); }
private static void LoadOldVersionSaves() { // Load Old Version saves string dirPath = V_Animation.LOC_ANIMATIONS + "OldVersion/"; DirectoryInfo dir = new DirectoryInfo(dirPath); List <FileInfo> fileInfoList = new List <FileInfo>(dir.GetFiles("*.txt")); foreach (FileInfo fileInfo in fileInfoList) { string readAllText = File.ReadAllText(fileInfo.FullName); UnitAnim unitAnim = UnitAnim.Load(readAllText); string prefix = "dSwordTwoHandedBack_"; unitAnim.name = prefix + unitAnim.name.Replace(" ", ""); V_Skeleton_Anim[] anims = unitAnim.GetAnims(); for (int i = 0; i < anims.Length; i++) { V_Skeleton_Anim skeletonAnim = anims[i]; foreach (V_Skeleton_Frame frame in skeletonAnim.frames) { switch (skeletonAnim.bodyPart.customName) { case "FootL": frame.SetNewSize(frame.GetSize() * .5f); break; case "FootR": frame.SetNewSize(frame.GetSize() * .5f); break; case "Body": frame.SetNewSize(frame.GetSize() * 0.85f); break; case "Head": frame.SetNewSize(frame.GetSize() * 0.916f); break; case "Sword": frame.SetNewSize(frame.GetSize() * 1.03f); break; case "HandL": frame.SetNewSize(frame.GetSize() * .5f); break; case "HandR": frame.SetNewSize(frame.GetSize() * .5f); break; } frame.RefreshVertices(); } skeletonAnim.RemakeTween(); } List <V_Skeleton_Anim> animsList = new List <V_Skeleton_Anim>(anims); for (int i = 0; i < animsList.Count; i++) { V_Skeleton_Anim skeletonAnim = animsList[i]; if (skeletonAnim.bodyPart.customName == "Pointer_1" || skeletonAnim.bodyPart.customName == "Pointer_2" || skeletonAnim.bodyPart.customName == "Pointer_3") { animsList.RemoveAt(i); i--; } } unitAnim = new UnitAnim(unitAnim.name, animsList.ToArray()); string saveString = unitAnim.Save(); SaveSystem.Save(V_Animation.LOC_ANIMATIONS, unitAnim.name + "." + V_Animation.fileExtention_Animation, SaveSystem.FileData.FileType.Animation, saveString); } }
public UnitAnim CloneDeep() { V_Skeleton_Anim[] skeletonAnimArray = new V_Skeleton_Anim[anims.Length]; for (int i = 0; i < anims.Length; i++) { skeletonAnimArray[i] = anims[i].CloneDeep(); } UnitAnim clone = new UnitAnim(name, skeletonAnimArray); return(clone); }
public void ReplaceAnimOnBodyPart(string bodyPartName, V_Skeleton_Anim anim) { for (int i = 0; i < anims.Length; i++) { if (anims[i].bodyPart.customName == bodyPartName) { anims[i] = anim; bodyPartNameAnimDic[anim.bodyPart.customName] = anim; } } }
public Vector3 GetBodyPartPosition(string bodyPartName) { V_Skeleton_Anim bodyPartAnim = GetSkeletonUpdater().GetAnimWithBodyPartName(bodyPartName); if (bodyPartAnim != null) { Vector3 pos = bodyPartAnim.GetCurrentAnimFrame().pos; return(ConvertLocalPositionToWorldPosition(pos)); } else { return(ConvertLocalPositionToWorldPosition(Vector3.zero)); } }
public bool TryReplaceAnimOnBodyPart(string bodyPartName, V_Skeleton_Anim anim) { bool ret = false; for (int i = 0; i < anims.Length; i++) { if (anims[i].bodyPart.customName == bodyPartName) { anims[i] = anim; bodyPartNameAnimDic[anim.bodyPart.customName] = anim; ret = true; } } return(ret); }
public void SetFramesToSame(V_Skeleton_Anim[] previousAnims) { //Set frames to same for (int j = 0; j < previousAnims.Length; j++) { V_Skeleton_Anim anim = previousAnims[j]; for (int i = 0; i < previousAnims.Length; i++) { V_Skeleton_Anim newAnim = anims[i]; if (anim.bodyPart.Equals(newAnim.bodyPart)) { //Same bodyPart newAnim.SetCurrentFrame(anim.GetCurrentFrameNumberIndex()); } } } Play(); }
private void Play() { int verticesIndex = 0; int uvsIndex = 0; int trianglesIndex = 0; for (int i = 0; i < animsLength; i++) { V_Skeleton_Anim anim = anims[i]; V_Skeleton_Frame frame = anim.GetCurrentAnimFrame(); V_UnitSkeleton.AddSquare(i, verticesIndex, verticesArr, uvsIndex, uvsArr, trianglesIndex, trianglesArr, frame.pos, frame.v00 + frame.v00offset, frame.v01 + frame.v01offset, frame.v10 + frame.v10offset, frame.v11 + frame.v11offset, V_UnitSkeleton.GetUV_Type(frame.uvType)); verticesIndex = verticesIndex + 4; uvsIndex = uvsIndex + 4; trianglesIndex = trianglesIndex + 6; } //mesh.triangles = null; mesh.Clear(); mesh.vertices = verticesArr; mesh.uv = uvsArr; mesh.triangles = trianglesArr; }
public V_Skeleton_Updater(Mesh mesh, V_Skeleton_Anim[] loadAnims, float frameRateMod, float frameRateModModifier, V_UnitSkeleton.OnAnimTrigger onAnimTrigger, V_UnitSkeleton.OnAnimTrigger OnAnyAnimTrigger, int id = -1) { this.mesh = mesh; this.id = id; List <V_Skeleton_Anim> tmpAnims = new List <V_Skeleton_Anim>(); hasVariableSortingOrder = false; for (int i = 0; i < loadAnims.Length; i++) { V_Skeleton_Anim clone = loadAnims[i].Clone(); if (!hasVariableSortingOrder && clone.HasVariableSortingOrder()) { hasVariableSortingOrder = true; } clone.SetFrameRateMod(frameRateMod * frameRateModModifier); clone.onAnimTrigger = onAnimTrigger; clone.onAnimTrigger += OnAnyAnimTrigger; tmpAnims.Add(clone); } bodyPartNameAnimDic = new Dictionary <string, V_Skeleton_Anim>(); anims = tmpAnims.ToArray(); foreach (V_Skeleton_Anim anim in anims) { bodyPartNameAnimDic[anim.bodyPart.customName] = anim; } animsLength = anims.Length; verticesArr = new Vector3[animsLength * 4]; uvsArr = new Vector2[animsLength * 4]; trianglesArr = new int[animsLength * 6]; Play(); }
public bool TryReplaceBodyPartSkeletonAnim(V_Skeleton_Anim anim) { return(GetSkeletonUpdater().TryReplaceAnimOnBodyPart(anim.bodyPart.customName, anim)); }
public bool TryReplaceBodyPartSkeletonAnim(string bodyPartName, V_Skeleton_Anim anim) { return(GetSkeletonUpdater().TryReplaceAnimOnBodyPart(bodyPartName, anim)); }
public static string Save_Static(V_Skeleton_Anim single) { return(single.Save()); }
public void ReplaceBodyPartSkeletonAnim(string bodyPartName, V_Skeleton_Anim anim) { GetSkeletonUpdater().ReplaceAnimOnBodyPart(bodyPartName, anim); }