/// <summary>
        /// Gets the transform information for all object types and calls the relevant apply method for each one.
        /// </summary>
        protected virtual void Animate(float deltaTime)
        {
            FrameData frameData = DataProvider.GetFrameData(Time, deltaTime, factor, CurrentAnimation, NextAnimation);

            if (SpriterConfig.MetadataEnabled)
            {
                Metadata = DataProvider.GetFrameMetadata(Time, deltaTime, factor, CurrentAnimation, NextAnimation);
            }

            for (int i = 0; i < frameData.SpriteData.Count; ++i)
            {
                SpriterObject info = frameData.SpriteData[i];
                int           folderId;
                int           fileId;
                if (!GetSpriteIds(info, out folderId, out fileId))
                {
                    continue;
                }
                TSprite obj = GetFromDict(folderId, fileId, sprites);
                obj = GetSwappedSprite(obj);
                ApplySpriteTransform(obj, info);
            }

            if (SpriterConfig.MetadataEnabled)
            {
                for (int i = 0; i < Metadata.Sounds.Count; ++i)
                {
                    SpriterSound info  = Metadata.Sounds[i];
                    TSound       sound = GetFromDict(info.FolderId, info.FileId, sounds);
                    PlaySound(sound, info);
                }

                var pointE = frameData.PointData.GetEnumerator();
                while (pointE.MoveNext())
                {
                    var e = pointE.Current;
                    ApplyPointTransform(e.Key, e.Value);
                }

                var boxE = frameData.BoxData.GetEnumerator();
                while (boxE.MoveNext())
                {
                    var e = boxE.Current;
                    ApplyBoxTransform(Entity.ObjectInfos[e.Key], e.Value);
                }

                for (int i = 0; i < Metadata.Events.Count; ++i)
                {
                    DispatchEvent(Metadata.Events[i]);
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Gets the transform information for all object types and calls the relevant apply method for each one.
        /// </summary>
        protected virtual void Animate(float deltaTime)
        {
            FrameData = DataProvider.GetFrameData(Time, deltaTime, factor, CurrentAnimation, NextAnimation);

            for (int i = 0; i < FrameData.SpriteData.Count; ++i)
            {
                SpriterObject info   = FrameData.SpriteData[i];
                TSprite       sprite = SpriteProvider.Get(info.FolderId, info.FileId);
                if (sprite != null)
                {
                    ApplySpriteTransform(sprite, info);
                }
            }

            for (int i = 0; i < FrameData.Sounds.Count; ++i)
            {
                SpriterSound info  = FrameData.Sounds[i];
                TSound       sound = SoundProvider.Get(info.FolderId, info.FileId);
                if (sound != null)
                {
                    PlaySound(sound, info);
                }
            }

            var pointE = FrameData.PointData.GetEnumerator();

            while (pointE.MoveNext())
            {
                var e = pointE.Current;
                ApplyPointTransform(e.Key, e.Value);
            }

            var boxE = FrameData.BoxData.GetEnumerator();

            while (boxE.MoveNext())
            {
                var e = boxE.Current;
                ApplyBoxTransform(Entity.ObjectInfos[e.Key], e.Value);
            }

            for (int i = 0; i < FrameData.Events.Count; ++i)
            {
                DispatchEvent(FrameData.Events[i]);
            }
        }
        private static void AddSoundData(SpriterAnimation animation, float targetTime, float deltaTime, FrameMetadata metadata)
        {
            if (animation.Soundlines == null)
            {
                return;
            }

            float previousTime = targetTime - deltaTime;

            foreach (SpriterSoundline soundline in animation.Soundlines)
            {
                foreach (SpriterSoundlineKey key in soundline.Keys)
                {
                    SpriterSound sound = key.SoundObject;
                    if (sound.Trigger && IsTriggered(key, targetTime, previousTime, animation.Length))
                    {
                        metadata.Sounds.Add(sound);
                    }
                }
            }
        }
        protected virtual void AddSoundData(SpriterAnimation animation, float targetTime, float deltaTime)
        {
            if (animation.Soundlines == null)
            {
                return;
            }

            float previousTime = targetTime - deltaTime;

            for (int i = 0; i < animation.Soundlines.Length; ++i)
            {
                SpriterSoundline soundline = animation.Soundlines[i];
                for (int j = 0; j < soundline.Keys.Length; ++j)
                {
                    SpriterSoundlineKey key   = soundline.Keys[j];
                    SpriterSound        sound = key.SoundObject;
                    if (sound.Trigger && IsTriggered(key, targetTime, previousTime, animation.Length))
                    {
                        FrameData.Sounds.Add(sound);
                    }
                }
            }
        }
Esempio n. 5
0
 /// <summary>
 /// Plays the concrete sound isntance.
 /// </summary>
 protected virtual void PlaySound(TSound sound, SpriterSound info)
 {
 }