예제 #1
0
 public void AppendAnimationIntoCycle(List <AnimationInstance> newAnimationList, bool clearAnimationCycle = false)
 {
     if (clearAnimationCycle)
     {
         AnimationCycle.Clear();
     }
     AnimationCycle.AddRange(newAnimationList);
     CreateFlipbookInstances();
 }
예제 #2
0
 public void AppendAnimationIntoCycle(AnimationInstance newAnimation, bool clearAnimationCycle = false)
 {
     if (clearAnimationCycle)
     {
         AnimationCycle.Clear();
     }
     AnimationCycle.Add(newAnimation);
     CreateFlipbookInstances();
 }
예제 #3
0
    public void ChangeCycleTarget(AnimationCycle target)
    {
        if (target == m_walkCycle)
        {
            return;
        }

        bool wasPlaying = m_walkCycle.m_isPlaying;

        m_walkCycle.StopCycle();

        m_walkCycle = target;
        if (wasPlaying)
        {
            m_walkCycle.StartCycle();
        }
    }
예제 #4
0
        public override void Draw(GameTime GameTime, SpriteBatch SpriteBatch)
        {
            FlipbookAnimation fbA = FlipbookAnimationList[currentAnimatedInstanceIndex];

            int currentFrameIndex = fbA.GetNextAnimationIndex(GameTime);

            if (fbA.IsLastFrame && AnimationCycle != null && AnimationCycle.Count > 1)
            {
                if (!repeatAnimationCycle)
                {
                    FlipbookAnimationList.Remove(fbA);
                    AnimationCycle.Remove(fbA.AnimationInstance);
                }

                currentAnimatedInstanceIndex = 0;
            }

            SourceRectangle = new Rectangle(currentFrameIndex % framesPerLine * SpriteWidth, currentFrameIndex / framesPerLine * SpriteHeight, SpriteWidth, SpriteHeight);
            base.Draw(GameTime, SpriteBatch);
        }
예제 #5
0
        public void SetAnimation()
        {
            ushort group = (cbGroup.SelectedItem == null) ? (ushort)1 : (ushort)((int)cbGroup.SelectedItem);
            ushort low   = (cbLow.SelectedItem == null)   ? (ushort)1 : (ushort)((int)cbLow.SelectedItem);
            ushort high  = (cbHigh.SelectedItem == null)  ? (ushort)1 : (ushort)((int)cbHigh.SelectedItem);
            ushort final = (cbFinal.SelectedItem == null) ? (ushort)1 : (ushort)((int)cbFinal.SelectedItem);

            uint period   = Convert.ToUInt32(numInterval.Value);
            int  groupmax = (dataSource.Resource != null) ? dataSource.Resource.FrameSets.Count : 1;

            Animation anim;

            switch (cbType.SelectedIndex)
            {
            // cycle
            case 1:
                anim          = new AnimationCycle(period, low, high);
                anim.GroupMax = groupmax;
                break;

            // once
            case 2:
                anim          = new AnimationOnce(period, low, high, final);
                anim.GroupMax = groupmax;
                break;

            // none (and others)
            default:
                anim          = new AnimationNone(group);
                anim.GroupMax = groupmax;
                break;
            }

            // set color
            dataSource.FirstAnimationType = AnimationType.TRANSLATION;
            dataSource.ColorTranslation   = Convert.ToByte(cbPalette.SelectedIndex);

            // set anim
            dataSource.Animation = anim;
        }
예제 #6
0
 //--------------------------------------------------------------------------------------------------------------------
 // - Dispose (Override)
 //--------------------------------------------------------------------------------------------------------------------
 public new void Dispose()
 {
     AnimationCycle.Dispose();
     base.Dispose();
 }
예제 #7
0
 // Use this for initialization
 public CharacterAnimator(int[] animationCycles, Character myCharacter, float _movementRate)
 {
     AnimationCycle Idle = new AnimationCycle (animationCycles[0], animationCycles[1]);
     AnimationCycle Walk = new AnimationCycle (animationCycles[2], animationCycles[3]);
     AnimationCycle Fall = new AnimationCycle (animationCycles[4], animationCycles[5]);
 }