Ejemplo n.º 1
0
        public void Animation(object sender, EventArgs e)
        {
            switch (crosshairAnimationState)
            {
            case CrosshairAnimationState.Start:
                crosshairFrame.ShowElement();
                CrosshairPointer.HideElement();
                crosshairRangeIndicatorList.ForEach((x) => x.HideElement());
                crosshairAngleList?.ForEach((x) => x.HideElement());
                crosshairFrame.Scale    = Parameter.HUDCrosshairAnimationStartingScale;
                animationElapsedTime    = 0;
                crosshairAnimationState = CrosshairAnimationState.Animating;
                break;

            case CrosshairAnimationState.Animating:
                crosshairFrame.Scale  = Parameter.HUDCrosshairAnimationStartingScale - (Parameter.HUDCrosshairAnimationStartingScale - new Vector2(1, 1)) * (animationElapsedTime / Parameter.HUDCrosshairAnimationTotalTime);
                animationElapsedTime += (float)((GameTime)sender).ElapsedGameTime.TotalSeconds;
                if (animationElapsedTime > Parameter.HUDCrosshairAnimationTotalTime)
                {
                    crosshairFrame.Scale    = CrosshairPointer.Scale = new Vector2(1f, 1f);
                    crosshairAnimationState = CrosshairAnimationState.End;
                }
                break;

            case CrosshairAnimationState.End:
                animationEventHandler -= Animation;
                CrosshairPointer.ShowElement();
                crosshairRangeIndicatorList.ForEach((x) => x.ShowElement());
                crosshairAngleList?.ForEach((x) => x.ShowElement());
                break;
            }
        }
Ejemplo n.º 2
0
 public void PlayAnimation()
 {
     crosshairAnimationState = CrosshairAnimationState.Start;
     animationEventHandler  += Animation;
 }