/// <summary> /// Creates a single bubble that floats toward the surface and fades out. /// </summary> /// <returns></returns> private Bubble CreateBubble() { Vector2 oceanSize = _scene.Sprite.GetSprite("Water").Size; Vector2 start = new Vector2( _random.Next(0, (int)oceanSize.X), _random.Next(BubbleDepthMin, BubbleDepthMax)); int height = _random.Next(BubbleTravelMin, Math.Min(BubbleTravelMax, (int)start.Y)); Vector2 end = new Vector2( start.X, start.Y - height); Sprite bubbleSprite = _bubbleTemplate.Create(); bubbleSprite.Position = start; bubbleSprite.Color = Color.TransparentWhite; _scene.Sprite.GetSprite <CompositeSprite>("Bubbles").Add(bubbleSprite); IAnimation animation = new SequentialAnimation( new DelayAnimation((float)_random.NextDouble() * 10), new CompositeAnimation( new PositionAnimation(bubbleSprite, end, 2f, PositionInterpolation), new SequentialAnimation( new ColorAnimation(bubbleSprite, Color.White, 0.5f, ColorInterpolation), new DelayAnimation(1f), new ColorAnimation(bubbleSprite, Color.TransparentWhite, 0.5f, ColorInterpolation)))); Bubble bubble = new Bubble(); bubble.Sprite = bubbleSprite; bubble.Animation = animation; return(bubble); }
private IAnimation CreateSequentialAnimation(XElement animationElem) { IAnimation[] animations = animationElem.Elements().Select(elem => CreateAnimation(elem)).ToArray <IAnimation>(); SequentialAnimation animation = new SequentialAnimation(animations); XAttribute loopAttr = animationElem.Attribute("Loop"); if (loopAttr != null) { animation.Loop = ParseBool(loopAttr.Value); } return(animation); }
/// <summary> /// Hide the fish after showing it off. /// </summary> private void OnFishingEvent(object stateObj, FishingEventArgs e) { if (e.Event == FishingEvent.FishCaught) { _fish = e.Fish; _fishAnimation = new SequentialAnimation( new DelayAnimation(4f), new ColorAnimation(_fish.Sprite.Sprite, Color.TransparentWhite, 1f, Interpolation.InterpolateColor(Easing.Uniform))); } else if (e.Event == FishingEvent.LureChanged) { CancelAnimation(); } }
/// <summary> /// Starts the mouth closed animation. /// </summary> private void CloseMouth() { IAnimation closeAnimation = _fish.Sprite.GetAnimation("MouthClose"); if (closeAnimation != null) { if (_mouthAnimation != null) { // let the mouth open before closing it again _mouthAnimation = new SequentialAnimation(_mouthAnimation, closeAnimation); } else { _mouthAnimation = closeAnimation; _mouthAnimation.Start(); } } }
/// <summary> /// Zooms in on caught fish. /// </summary> private void OnFishingEvent(object stateObj, FishingEventArgs e) { if (e.Event == FishingEvent.FishCaught) { _cameraAnimation = new SequentialAnimation( new CompositeAnimation( new PositionAnimation(_camera, GetFocusPosition(CatchFocus), CatchScaleTime, Interpolate), new ScaleAnimation(_camera, CatchScale, CatchScaleTime, Interpolate)), new DelayAnimation(CatchDelayTime), new CompositeAnimation( new PositionAnimation(_camera, GetFocusPosition(SwingFocus), CatchScaleTime, Interpolate), new ScaleAnimation(_camera, Vector2.One, CatchScaleTime, Interpolate))); } else if (e.Event == FishingEvent.LureChanged) { ResetForCast(); } else if (e.Event == FishingEvent.LureIsland) { _followLure = false; _followNPC = true; } }