private void initAnimations() { ShrinkAnimator shrinkAnimator = new ShrinkAnimator(TimeSpan.FromSeconds(k_AnnimationLength)); BlinkAnimator blinkAnimator = new BlinkAnimator(TimeSpan.FromSeconds(k_BlinkRate), TimeSpan.FromSeconds(k_AnnimationLength)); FadeAnimator fadeAnimator = new FadeAnimator(TimeSpan.FromSeconds(k_AnnimationLength)); shrinkAnimator.Finished += gotHit; this.Animations.Add(shrinkAnimator); this.Animations.Add(blinkAnimator); this.Animations.Add(fadeAnimator); }
private void createDeathAnimator() { TimeSpan animationLength = TimeSpan.FromSeconds(k_DeathAnimatorDuration); RotateAnimator rotateAnimator = new RotateAnimator(k_NumOfRotationsOnDeathPerSecond, animationLength); FadeAnimator fadeAnimator = new FadeAnimator(animationLength); CompositeAnimator deathAnimator = new CompositeAnimator( "Death Animator", animationLength, this, rotateAnimator, fadeAnimator); this.Animations.AddWithoutEnabling(deathAnimator); Death += animations_Death; }
private void initAnimations() { BlinkAnimator blinkAnimator = new BlinkAnimator("LoosingSoul", TimeSpan.FromSeconds(0.1), TimeSpan.FromSeconds(2.5)); this.Animations.Add(blinkAnimator); RoataterAnimator roataterAnimator = new RoataterAnimator(4, TimeSpan.FromSeconds(2.5)); FadeAnimator fadeAnimator = new FadeAnimator(TimeSpan.FromSeconds(2.5)); CompositeAnimator DestroyAnimator = new CompositeAnimator("Destroy", TimeSpan.FromSeconds(2.5), this, fadeAnimator, roataterAnimator); this.Animations.Add(DestroyAnimator); }
private void initAnimations() { BlinkAnimator blinkAnimator = new BlinkAnimator(TimeSpan.FromSeconds(0.1), TimeSpan.FromSeconds(2.2)); FadeAnimator fadeAnimator = new FadeAnimator(TimeSpan.FromSeconds(2.2)); ShrinkAnimator shrinkAnimator = new ShrinkAnimator(TimeSpan.FromSeconds(2.2)); CompositeAnimator DestroyAnimator2 = new CompositeAnimator("DestroyMother", TimeSpan.FromSeconds(2.2), this, fadeAnimator, blinkAnimator, shrinkAnimator); this.Animations.Add(DestroyAnimator2); Animations["DestroyMother"].Finished += new EventHandler(this.destroyed_Finished); }
public double OpacityValueEnd(FadeMode fadeMode) { FadeAnimator animator = new FadeAnimator(fadeMode) { OpacityDeltaPerSecond = 1 }; BitmapSource inBitmap = new RenderTargetBitmap(1, 1, 96, 96, PixelFormats.Pbgra32); BitmapSource outBitmap; animator.RenderNextFrame(inBitmap, DateTime.Now.AddSeconds(-1), out outBitmap); return(animator.CurrentOpacity); }
private void createDeathAnimator() { TimeSpan animationLength = TimeSpan.FromSeconds(k_DeathAnimatorDuration); TimeSpan blinkDuration = TimeSpan.FromSeconds(k_DeathBlinkDuration); ShrinkAnimator shrinkAnimator = new ShrinkAnimator(animationLength); FadeAnimator fadeAnimator = new FadeAnimator(animationLength); BlinkAnimator blinkAnimator = new BlinkAnimator(blinkDuration, animationLength); CompositeAnimator deathAnimator = new CompositeAnimator( "Death Animator", animationLength, this, shrinkAnimator, fadeAnimator, blinkAnimator); this.Animations.Add(deathAnimator); Death += Animations_Death; }
private void initAnimations() { m_AnimatorForHit = new CompositeAnimator(this, "ShipBlink"); m_AnimatorForDestruction = new CompositeAnimator(this, "KillShip"); RotateAnimator rotateAnimator = new RotateAnimator(TimeSpan.FromSeconds(k_RotaionLength), k_RotaionPerSec); BlinkAnimator blinkAnimator = new BlinkAnimator(TimeSpan.FromSeconds(k_BlinkLength), TimeSpan.FromSeconds(k_AnimationBlinkLength)); FadeAnimator fadeAnimator = new FadeAnimator(TimeSpan.FromSeconds(k_FadeLength)); rotateAnimator.Finished += onkillSpaceShip; blinkAnimator.Finished += onFinsihAfterHit; m_AnimatorForHit.Add(blinkAnimator); m_AnimatorForDestruction.Add(fadeAnimator); m_AnimatorForDestruction.Add(rotateAnimator); this.Animations = m_AnimatorForHit; }
private void initAnimations() { BlinkAnimator blinkAnimator = new BlinkAnimator("LoosingSoul", TimeSpan.FromSeconds(0.1), TimeSpan.FromSeconds(2.5));//TODO: numbers? this.Animations.Add(blinkAnimator); FadeAnimator fadeAnimator = new FadeAnimator(TimeSpan.FromSeconds(4.5)); SpriteAnimator[] destriyAnimations = { fadeAnimator }; CompositeAnimator spaceShipDestroyAnimator = new CompositeAnimator("Destroy", TimeSpan.FromSeconds(2.5), this, destriyAnimations); spaceShipDestroyAnimator.ResetAfterFinish = false; m_Animations.Add(spaceShipDestroyAnimator); this.Animations.Enabled = true; }
public void AnimationEventBusy() { FadeAnimator animator = new FadeAnimator(FadeMode.FadeIn) { OpacityDeltaPerSecond = 0.0001 }; bool eventFired = false; animator.AnimationFinished += (s_, e_) => eventFired = true; BitmapSource inBitmap = new RenderTargetBitmap(1, 1, 96, 96, PixelFormats.Pbgra32); BitmapSource outBitmap; Assert.AreEqual(AnimationState.InProgress, animator.RenderNextFrame(inBitmap, DateTime.Now.AddSeconds(-1), out outBitmap)); Assert.IsFalse(eventFired); }
public double OpacityValueStart(FadeMode fadeMode) { FadeAnimator animator = new FadeAnimator(fadeMode); return(animator.CurrentOpacity); }
private void MumbleLinkManager_MumbleLinkStateChanged(object sender, MumbleLinkStateEventArgs e) { // Since the Mumble Link state has changed, reset the fade animator so it can be used again this.textImage.Animators.Remove(this.fadeAnimator); this.fadeAnimator = null; }
public bool UpdateTexture() { string text = Gw2Plugin.Instance.ScriptsManager.FormatString(this.config.GetString("textFormat")); if (text != this.oldText) { this.oldText = text; this.textImage.Text = text; } if (!this.textImage.AnimationActive) { this.textImage.StartAnimation(); } // Fade in and out when the fade animator is currently null (aka when the Mumble Link state changes) if (this.hideWhenGw2IsInactive && this.fadeAnimator == null) { if (!this.isVisible && Gw2Plugin.Instance.MumbleLinkManager.IsActive) { this.fadeAnimator = new FadeAnimator(FadeMode.FadeIn); } else if (this.isVisible && !Gw2Plugin.Instance.MumbleLinkManager.IsActive) { this.fadeAnimator = new FadeAnimator(FadeMode.FadeOut); } if (this.fadeAnimator != null) { this.fadeAnimator.AnimationFinished += (s_, e_) => { this.textImage.Animators.Remove(this.fadeAnimator); if (this.fadeAnimator.FadeMode == FadeMode.FadeOut) { this.isVisible = false; } }; // Workaround if another animator uses a custom viewport: // This viewport will be ignored in PixelWidth and PixelHeight if the image is actually smaller // Therefore, insert the fade animator before every other animator this.textImage.Animators.Insert(0, this.fadeAnimator); this.isVisible = true; } } else if (!this.hideWhenGw2IsInactive) { this.isVisible = true; } if (this.textImage.AnimateFrame() || this.texture == null) { int pixelWidth = this.textImage.Bitmap.PixelWidth; int pixelHeight = this.textImage.Bitmap.PixelHeight; byte[] pixels = this.textImage.GetPixels(); Texture newTexture = GS.CreateTexture((uint)pixelWidth, (uint)pixelHeight, GSColorFormat.GS_BGRA, null, false, false); newTexture.SetImage(pixels, GSImageFormat.GS_IMAGEFORMAT_BGRA, (uint)this.textImage.GetStride()); this.config.Parent.SetInt("cx", pixelWidth); this.config.Parent.SetInt("cy", pixelHeight); this.Size.X = pixelWidth; this.Size.Y = pixelHeight; lock (textureLock) this.texture = newTexture; return(true); } return(false); }