private async void animate(ITextureOffsetComponent textureOffset) { if (_isClosed) { return; } var player = _game.State.Player; setConfig(player, ScaleUpFilters.Nearest, TextureWrap.Repeat, TextureWrap.Repeat); await Task.Delay(2000); setConfig(player, ScaleUpFilters.Nearest, TextureWrap.Repeat, TextureWrap.MirroredRepeat); await Task.Delay(2000); setConfig(player, ScaleUpFilters.Nearest, TextureWrap.Clamp, TextureWrap.MirroredRepeat); await Task.Delay(2000); setConfig(player, ScaleUpFilters.Linear, TextureWrap.Clamp, TextureWrap.MirroredRepeat); await Task.Delay(2000); setConfig(player, ScaleUpFilters.Linear, TextureWrap.Repeat, TextureWrap.MirroredRepeat); _label.Text = "Animating texture offset"; await textureOffset.TweenX(3f, 2f, Ease.Linear).Task; await textureOffset.TweenY(3f, 2f, Ease.Linear).Task; await Task.Delay(2000); var task1 = textureOffset.TweenX(0f, 2f, Ease.QuadIn).Task; var task2 = textureOffset.TweenY(0f, 2f, Ease.QuadIn).Task; await Task.WhenAll(task1, task2); animate(textureOffset); }
public override void Init() { base.Init(); Entity.Bind <IModelMatrixComponent>(c => { c.OnMatrixChanged.Subscribe(_onHitTextBoxShouldChangeCallback); _matrix = c; }, c => { c.OnMatrixChanged.Unsubscribe(_onHitTextBoxShouldChangeCallback); _matrix = null; }); Entity.Bind <ICropSelfComponent>(c => { c.PropertyChanged += _onCropShouldChangeCallback; _crop = c; }, c => { c.PropertyChanged -= _onCropShouldChangeCallback; _crop = null; }); Entity.Bind <IImageComponent>(c => { _image = c; c.PropertyChanged += _onImageChangedCallback; }, c => { _image = null; c.PropertyChanged -= _onImageChangedCallback; }); Entity.Bind <IScaleComponent>(c => _scale = c, _ => _scale = null); Entity.Bind <IDrawableInfoComponent>(c => { c.PropertyChanged += _onDrawableChangedCallback; _drawable = c; }, c => { c.PropertyChanged -= _onDrawableChangedCallback; _drawable = null; }); Entity.Bind <ITextureOffsetComponent>(c => { c.PropertyChanged += _onTextureOffsetChangedCallback; _textureOffset = c; onAllViewportsShouldChange(); }, c => { c.PropertyChanged -= _onTextureOffsetChangedCallback; _textureOffset = null; onAllViewportsShouldChange(); }); }
/// <summary> /// Tweens the y offset of a texture. /// <example> /// <code language="lang-csharp"> /// var tween = texture.TweenY(0.5f, 2f, Ease.CubeIn); /// await tween.Task; /// </code> /// </example> /// <seealso cref="Tween"/> /// <seealso cref="ITextureOffsetComponent"/> /// </summary> /// <returns>The tween.</returns> /// <param name="offset">Texture offset component.</param> /// <param name="toY">To y.</param> /// <param name="timeInSeconds">Time in seconds.</param> /// <param name="easing">Easing function.</param> public static Tween TweenY(this ITextureOffsetComponent offset, float toY, float timeInSeconds, Func <float, float> easing = null) { return(Tween.Run(offset.TextureOffset.Y, toY, y => offset.TextureOffset = new PointF(offset.TextureOffset.X, y), timeInSeconds, easing)); }
public override void Init(IEntity entity) { _entity = entity; base.Init(entity); entity.Bind <IModelMatrixComponent>(c => { c.OnMatrixChanged.Subscribe(onHitTextBoxShouldChange); _matrix = c; }, c => { c.OnMatrixChanged.Unsubscribe(onHitTextBoxShouldChange); _matrix = null; }); entity.Bind <ICropSelfComponent>(c => { c.PropertyChanged += onCropShouldChange; _crop = c; }, c => { c.PropertyChanged -= onCropShouldChange; _crop = null; }); entity.Bind <IImageComponent>(c => c.PropertyChanged += onImageChanged, c => c.PropertyChanged -= onImageChanged); entity.Bind <IAnimationComponent>(c => _animation = c, _animation => _animation = null); entity.Bind <IDrawableInfoComponent>(c => { c.PropertyChanged += onDrawableChanged; _drawable = c; }, c => { c.PropertyChanged -= onDrawableChanged; _drawable = null; }); entity.Bind <ITextureOffsetComponent>(c => { c.PropertyChanged += onTextureOffsetChanged; _textureOffset = c; onAllViewportsShouldChange(); }, c => { c.PropertyChanged -= onTextureOffsetChanged; _textureOffset = null; onAllViewportsShouldChange(); }); }