protected override void UpdateCore(AnimationContext context) { var vectorContext = (VectorAnimationContext)context; vectorContext.Sprite.ScaleX = Function.GetValue(vectorContext.Time, vectorContext.StartX, vectorContext.FinalX, Duration); vectorContext.Sprite.ScaleY = Function.GetValue(vectorContext.Time, vectorContext.StartY, vectorContext.FinalY, Duration); }
protected override void UpdateCore(AnimationContext context) { var colorContext = (ColorAnimationContext)context; colorContext.Sprite.ColorR = Function.GetValue(colorContext.Time, colorContext.StartR, colorContext.FinalR, Duration); colorContext.Sprite.ColorG = Function.GetValue(colorContext.Time, colorContext.StartG, colorContext.FinalG, Duration); colorContext.Sprite.ColorB = Function.GetValue(colorContext.Time, colorContext.StartB, colorContext.FinalB, Duration); }
public override IEnumerable <AnimationContext> Get(BaseSprite sprite) { AnimationContext context = null; if (m_dictionary.TryGetValue(sprite, out context)) { yield return(context); } }
public void Clear() { if (m_container != null) { m_container.Clear(); } else if (m_context != null) { m_context = null; } }
public void Update(GameTime gameTime) { if (m_container != null) { foreach (var context in m_container.All()) { if (!context.IsBegin) { OnBegin(context); } UpdateContext(context, gameTime); if (IsContextEnd(context)) { m_contextsToRemove.Add(context); } } m_container.Remove(IsContextEnd, m_contextsToRemove); foreach (var contextToRemove in m_contextsToRemove) { OnComplete(contextToRemove); } m_contextsToRemove.Clear(); } else if (m_context != null) { if (!m_context.IsBegin) { OnBegin(m_context); } UpdateContext(m_context, gameTime); if (IsContextEnd(m_context)) { var context = m_context; m_context = null; OnComplete(context); } } }
public void Apply(BaseSprite sprite, bool reverse = false, Action onComplete = null, Action onBegin = null) { var context = ApplyCore(sprite); context.Sprite = sprite; context.Reverse = reverse; context.Begin = onBegin; context.Complete = onComplete; context.Time = (context.Reverse ? Duration : 0); if (m_container != null) { m_container.Add(context); } else if (m_context == null) { m_context = context; } else { m_contextsToRemove = new List <AnimationContext>(); switch (m_containerType) { case ContainerType.List: m_container = new ListContainer(); break; case ContainerType.Dictionary: m_container = new DictionaryContainer(); break; default: break; } m_container.Add(m_context); m_context = null; m_container.Add(context); } }
void UpdateContext(AnimationContext context, GameTime gameTime) { UpdateCore(context); if (!context.IsBegin) { context.IsBegin = true; } if (context.Reverse) { if (context.Time <= 0) { context.IsEnd = true; return; } context.Time -= gameTime.ElapsedGameTime.TotalMilliseconds; if (context.Time < 0) { context.Time = 0; } } else { if (context.Time >= Duration) { context.IsEnd = true; return; } context.Time += gameTime.ElapsedGameTime.TotalMilliseconds; if (context.Time > Duration) { context.Time = Duration; } } }
protected virtual void OnBeginCore(AnimationContext context) { }
protected virtual void UpdateCore(AnimationContext context) { }
void OnComplete(AnimationContext context) { context.Complete?.Invoke(); OnCompleteCore(context); }
void OnBegin(AnimationContext context) { context.Begin?.Invoke(); OnBeginCore(context); }
public abstract void Add(AnimationContext context);
protected override void UpdateCore(AnimationContext context) { var colorContext = (ValueAnimationContext)context; colorContext.Sprite.Alpha = Function.GetValue(colorContext.Time, colorContext.StartValue, colorContext.FinalValue, Duration); }
public override void Add(AnimationContext context) { m_list.Add(context); }
protected virtual void OnCompleteCore(AnimationContext context) { }
bool IsContextEnd(AnimationContext context) { return(context.IsEnd); }
public override void Add(AnimationContext context) { m_dictionary.Add(context.Sprite, context); }