Exemple #1
0
        AnimationClip LoadAnimation(string path)
        {
            var file      = _pfs.FindFile(path);
            var animation = AnimationFile.Create(file);

            return(new AnimationClip(animation));
        }
        private void SkeletonChanged(string selectedSkeletonPath)
        {
            HeaderText                   = "";
            _skeletonPackFile            = null;
            Skeleton                     = null;
            AnimationsForCurrentSkeleton = new ObservableCollection <AnimationReference>();
            if (!string.IsNullOrWhiteSpace(selectedSkeletonPath))
            {
                _skeletonPackFile = _packFileService.FindFile(selectedSkeletonPath) as PackFile;
                if (_skeletonPackFile == null)
                {
                    HeaderText = "No skeleton";
                }
                else
                {
                    HeaderText = _skeletonPackFile.Name + " - No Animation";
                    AnimationsForCurrentSkeleton = _skeletonAnimationLookUpHelper.GetAnimationsForSkeleton(Path.GetFileNameWithoutExtension(_skeletonPackFile.Name));

                    var skeletonAnimationFile = AnimationFile.Create(_skeletonPackFile);
                    Skeleton = new GameSkeleton(skeletonAnimationFile, Player);
                }
            }

            SelectedAnimation = null;
        }
 public AnimationFile GetSkeletonFileFromName(PackFileService pfs, string skeletonName)
 {
     foreach (var name in SkeletonFileNames)
     {
         if (name.Contains(skeletonName))
         {
             var file = pfs.FindFile(name);
             if (file != null)
             {
                 return(AnimationFile.Create(file as PackFile));
             }
         }
     }
     return(null);
 }
        private void OnEnableChanged(bool isEnabled)
        {
            if (isEnabled && Animation != null)
            {
                var animFile = AnimationFile.Create(Animation);
                var animClip = new AnimationClip(animFile);

                MaxFrames    = animClip.DynamicFrames.Count;
                CurrentFrame = 0;

                Player.SetAnimation(animClip, Skeleton);
            }
            else
            {
                Player.SetAnimation(null, Skeleton);
            }

            Player.IsEnabled = isEnabled;
        }
        private void AnimationChanged(AnimationReference selectedAnimation)
        {
            Animation = null;
            if (selectedAnimation != null)
            {
                Animation = _packFileService.FindFile(selectedAnimation.AnimationFile, selectedAnimation.Container) as PackFile;
            }

            if (Animation != null)
            {
                HeaderText = _skeletonPackFile.Name + " - " + Animation.Name;
            }
            else if (_skeletonPackFile != null)
            {
                HeaderText = _skeletonPackFile.Name + " - No Animation";
            }
            else
            {
                HeaderText = "No Skeleton - No Animation";
            }

            if (Animation != null)
            {
                var animFile = AnimationFile.Create(Animation);
                var animClip = new AnimationClip(animFile);


                Player.SetAnimation(animClip, Skeleton);
                if (Player.IsPlaying && Player.IsEnabled)
                {
                    Player.Play();
                }

                MaxFrames    = Player.FrameCount();
                CurrentFrame = 0;
            }
        }