public override void Update(GameTime gameTime) { frameCounter++; if (parallelEffect != null) { parallelFrameCounter++; } if (currentEffect != null) { currentEffect.Step(frameCounter); if (currentEffect.IsOver(frameCounter) || (currentEffect is Animation && frameCounter >= ((Animation)currentEffect).StopEarly)) { currentEffect.End(); currentEffect = null; if (queue.Count <= 0 && OnEffectsEnd != null) { OnEffectsEnd(this, null); } } } //So, most of the special effects happen one after the other but for a couple of moves //there's more than one going on at the same time. //Most of this is handled by the start-at and stop-early properties on the Animation class //that makes it so other effects can be inserted in the middle of an ongoing animation //by splitting the animation up. //But this setup couldn't handle the mid-animation screen shaking in Rock Slide. //So, this code is pretty much just for that. if (parallelEffect != null) { parallelEffect.Step(parallelFrameCounter); if (parallelEffect.IsOver(parallelFrameCounter)) { parallelEffect.End(); parallelEffect = null; } } if (currentEffect == null && queue.Count > 0) { currentEffect = queue.Dequeue(); currentEffect.Begin(); frameCounter = currentEffect is Animation ? ((Animation)currentEffect).StartAt : 0; if (currentEffect is TransformScreen && ((TransformScreen)currentEffect).Parallel) { parallelEffect = (TransformScreen)currentEffect; parallelFrameCounter = frameCounter; currentEffect = null; if (queue.Count > 0) { currentEffect = queue.Dequeue(); currentEffect.Begin(); frameCounter = currentEffect is Animation ? ((Animation)currentEffect).StartAt : 0; } } } }
public void UnRegister(ISpecialEffect effect) { if (effect == null) { return; } int type = (int)effect.Type; if (type < 0 && type > specEffects.Length) { return; } specEffects[type] = null; }
public bool Register(ISpecialEffect effect) { if (effect == null) { return(false); } int type = (int)effect.Type; if (type < 0 && type > specEffects.Length) { return(false); } if (specEffects[type] != null) { return(false); } specEffects[type] = effect; return(true); }
public void AddSpecialEffectToWorld(ISpecialEffect specialEffect) { specialEffect.Done += new SpecialEffectEvent(SpecialEffectDone); _specialEffects.Add(specialEffect); }
private void SpecialEffectDone(ISpecialEffect sender) { _specialEffects.Remove(sender); }
public override void Enter(object param) { effect = param as ISpecialEffect; }
public void QueueSpecialEffect(ISpecialEffect effect) { queue.Enqueue(effect); }