public void PlayAnim(UnitAnim unitAnim, float frameRateModModifier, OnAnimComplete onAnimComplete, OnAnimTrigger onAnimTrigger, OnAnimInterrupted onAnimInterrupted)
        {
            if (this.onAnimInterrupted != null)
            {
                OnAnimInterrupted tmpAnimInterrupted = this.onAnimInterrupted;
                this.onAnimInterrupted = null;
                tmpAnimInterrupted(lastUnitAnim, unitAnim, alreadyLooped);
                if (OnAnyAnimInterrupted != null)
                {
                    OnAnyAnimInterrupted(lastUnitAnim, unitAnim, alreadyLooped);
                }
            }

            this.onAnimComplete    = onAnimComplete;
            this.onAnimTrigger     = onAnimTrigger;
            this.onAnimInterrupted = onAnimInterrupted;

            lastUnitAnim = unitAnim;

            alreadyLooped = false;

            // Dynamic anim
            V_Skeleton_Updater newSkeletonUpdater = new V_Skeleton_Updater(mesh, unitAnim.GetAnims(), frameRateMod, frameRateModModifier, onAnimTrigger, OnAnyAnimTrigger);

            newSkeletonUpdater.TestFirstFrameTrigger();
            skeletonUpdater = newSkeletonUpdater;


            if (OnAnyPlayAnim != null)
            {
                OnAnyPlayAnim(unitAnim);
            }
        }
Exemple #2
0
        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 void PlayAnimContinueFrames(UnitAnim unitAnim, float frameRateModModifier)
        {
            //Play new anim starting from same frames
            lastUnitAnim = unitAnim;

            alreadyLooped = false;

            // Dynamic anim
            if (skeletonUpdater is V_Skeleton_Updater)
            {
                // Continuing from normal updater
                V_Skeleton_Updater newSkeletonUpdater = new V_Skeleton_Updater(mesh, unitAnim.GetAnims(), frameRateMod, frameRateModModifier, onAnimTrigger, OnAnyAnimTrigger);
                newSkeletonUpdater.SetFramesToSame((skeletonUpdater as V_Skeleton_Updater).GetAnims());
                skeletonUpdater = newSkeletonUpdater;
            }
            else
            {
                // Previous was cached updater, ignore continue frames
                skeletonUpdater = new V_Skeleton_Updater(mesh, unitAnim.GetAnims(), frameRateMod, frameRateModModifier, onAnimTrigger, OnAnyAnimTrigger);
            }
        }
 // All body parts in this UnitAnim get replaced in the current anim, if one doesnt exist it is added
 public void ReplaceAllBodyPartsInAnimation(UnitAnim unitAnim)
 {
     foreach (V_Skeleton_Anim skeletonAnim in unitAnim.GetAnims())
     {
         bool replaced = TryReplaceBodyPartSkeletonAnim(skeletonAnim);
         if (!replaced)
         {
             // Didn't replace, body part doesn't exist, add
             GetSkeletonUpdater().AddAnim(skeletonAnim);
         }
     }
 }
        public void PlayAnimContinueFrames(UnitAnim unitAnim, float frameRateModModifier, OnAnimComplete onAnimComplete, OnAnimTrigger onAnimTrigger, OnAnimInterrupted onAnimInterrupted)
        {
            //Play new anim starting from same frames
            if (this.onAnimInterrupted != null)
            {
                OnAnimInterrupted tmpAnimInterrupted = this.onAnimInterrupted;
                this.onAnimInterrupted = null;
                tmpAnimInterrupted(lastUnitAnim, unitAnim, alreadyLooped);
                if (OnAnyAnimInterrupted != null)
                {
                    OnAnyAnimInterrupted(lastUnitAnim, unitAnim, alreadyLooped);
                }
            }

            this.onAnimComplete    = onAnimComplete;
            this.onAnimTrigger     = onAnimTrigger;
            this.onAnimInterrupted = onAnimInterrupted;

            lastUnitAnim = unitAnim;

            alreadyLooped = false;

            // Dynamic anim
            if (skeletonUpdater is V_Skeleton_Updater)
            {
                // Continuing from normal updater
                V_Skeleton_Updater newSkeletonUpdater = new V_Skeleton_Updater(mesh, unitAnim.GetAnims(), frameRateMod, frameRateModModifier, onAnimTrigger, OnAnyAnimTrigger);
                newSkeletonUpdater.SetFramesToSame((skeletonUpdater as V_Skeleton_Updater).GetAnims());
                skeletonUpdater = newSkeletonUpdater;
            }
            else
            {
                // Previous was cached updater, ignore continue frames
                skeletonUpdater = new V_Skeleton_Updater(mesh, unitAnim.GetAnims(), frameRateMod, frameRateModModifier, onAnimTrigger, OnAnyAnimTrigger);
            }
        }