/// <summary> /// Initialize the star component by setting the desire animation and /// the component color /// </summary> public override void Initialize() { base.Initialize(); Vector4 tint = this.TintColor.ToVector4(); tint.W = (float)m_Random.NextDouble(); TintColor = new Color(tint); TimeSpan fadeTime = TimeSpan.FromSeconds(m_Random.Next(1, 4) + m_Random.NextDouble()); bool fadeOut = m_Random.Next() % 2 == 0; TimeSpan animationTime = TimeSpan.Zero; FadeAnimation fadeAnimation = new FadeAnimation( "star_Fade", true, 0, 1, fadeOut, fadeTime, animationTime, false); fadeAnimation.Enabled = true; Animations.Add(fadeAnimation); Animations.Enabled = true; }
/// <summary> /// Initialize the space ship by getting the game's input manager /// and setting the components fade and rotate animations /// </summary> public override void Initialize() { m_InputManager = Game.Services.GetService(typeof(InputManager)) as IInputManager; base.Initialize(); Animations.NotifyWhenAllAnimationsFinished = true; RotateAnimation rotateAnimation = new RotateAnimation("spaceship_deathRotate", 2 * (float) Math.PI, TimeSpan.FromSeconds(.4f), true); FadeAnimation fadeAnimation = new FadeAnimation("spaceship_deathFade", false, 0, 1, true, TimeSpan.FromSeconds(.4f), TimeSpan.FromSeconds(.4f), true); Animations.Add(rotateAnimation); Animations.Add(fadeAnimation); Animations.Enabled = false; Animations.Finished += this.spaceShip_DeathAnimationEnded; Animations.ResetAfterFinish = false; }