Example #1
0
        /// <summary>
        ///     Returns the top left of the specified Frame Animation to allow for the center of the image to be vertically centered with the text, but with some pixels between the right of the image and the left of the text.
        ///     If the Frame Animation specified is null, then the Idle or Enter frame will be used based on the UseIdleAnimation and UseEnteranimation flags.
        /// </summary>
        private Vector2 GetMenuSelectorPosition(MenuConstants.MenuOption menuOption, Frame2DAnimation menuSelectorFrameAnimation = null)
        {
            var frame            = (menuSelectorFrameAnimation == null) ? this.menuSelectorFrameAnimation.Animation.CurrentFrame : menuSelectorFrameAnimation.CurrentFrame;
            var menuTextPosition = GetMenuTextPosition(menuOption);

            return(new Vector2(menuTextPosition.X - frame.Width - 25, menuTextPosition.Y + (MenuConstants.MenuItemFont.LineSpacing / 2) - frame.Height / 2));
        }
Example #2
0
        private void SelectDown(GameTime gameTime)
        {
            var newMenuItem =
                (MenuConstants.MenuOption)
                Math.Min((int)this.selectedMenuOption + 1, MenuConstants.MenuOptions.Count - 1);

            // If the menu isn't going to change, then do nothing.
            if (newMenuItem == this.selectedMenuOption)
            {
                return;
            }

            var menuStart = GetMenuSelectorPosition(this.selectedMenuOption);
            var menuEnd   = GetMenuSelectorPosition(newMenuItem);

            menuSelectorUpDownTranslationAnimation = new TranslationAnimation(menuStart.X, menuStart.Y, menuEnd.X, menuEnd.Y, 0.0f, MenuConstants.MenuTranslationTotalDuration)
            {
                OnComplete = () =>
                {
                    this.selectedMenuOption = newMenuItem;
                    this.menuSelectorUpDownTranslationAnimation = null;
                }
            };
            menuSelectorUpDownTranslationAnimation.LogName = "Selector Down Translation";

            menuSelectorUpDownTranslationAnimation.AddVerticalEasing(0.0f, 0.5f, 0.1f, 1.0f);
            menuSelectorUpDownTranslationAnimation.AddVerticalEasing(0.5f, 1.0f, 1.0f, 0.1f);
        }
Example #3
0
        /// <summary> Returns the top left of the Enter Animation to allow for the center of the image to be vertically centered with the Selector's arm cannon, as well as the top left of where it should end. </summary>
        private Vector2[] GetMenuSelectorEnterPositions(MenuConstants.MenuOption menuOption)
        {
            var menuSelectorPosition           = GetMenuSelectorPosition(menuOption);
            var menuSelectorEnterPositionStart = new Vector2(menuSelectorPosition.X + this.menuSelectorFrameAnimation.Animation.CurrentFrame.Width - 8, menuSelectorPosition.Y);
            // It ends all the way beyond the screen boundaries
            var menuSelectorEnterPositionEnd = new Vector2(SharedResources.GameWindow.ClientBounds.Width, menuSelectorEnterPositionStart.Y);

            return(new Vector2[] { menuSelectorEnterPositionStart, menuSelectorEnterPositionEnd });
        }
Example #4
0
 /// <summary> Top-Left of the Menu Text Entry. </summary>
 private Vector2 GetMenuTextPosition(MenuConstants.MenuOption menuOption)
 {
     return(new Vector2(MenuConstants.MenuStartX, MenuConstants.MenuStartY + (MenuConstants.MenuItemFont.LineSpacing * (int)menuOption)));
 }
Example #5
0
        private void SelectUp(GameTime gameTime)
        {
            var newMenuItem = (MenuConstants.MenuOption)Math.Max((int)this.selectedMenuOption - 1, 0);

            // If the menu isn't going to change, then do nothing.
            if (newMenuItem == this.selectedMenuOption)
                return;

            var menuStart = GetMenuSelectorPosition(this.selectedMenuOption);
            var menuEnd = GetMenuSelectorPosition(newMenuItem);
            menuSelectorUpDownTranslationAnimation = new TranslationAnimation(menuStart.X, menuStart.Y, menuEnd.X, menuEnd.Y, 0.0f, MenuConstants.MenuTranslationTotalDuration)
                                          {
                                              OnComplete = () =>
                                              {
                                                  this.selectedMenuOption = newMenuItem;
                                                  this.menuSelectorUpDownTranslationAnimation = null;
                                              },
                                          };
            menuSelectorUpDownTranslationAnimation.LogName = "Selector Up Translation";

            menuSelectorUpDownTranslationAnimation.AddVerticalEasing(0.0f, 0.5f, 0.1f, 1.0f);
            menuSelectorUpDownTranslationAnimation.AddVerticalEasing(0.5f, 1.0f, 1.0f, 0.1f);
        }