Пример #1
0
        public bool TryNavigateEnter(NavigationDirection StartingSide, Rectangle?ClosestTo)
        {
            IsGamepadFocused        = true;
            IsNavigatingWithGamepad = true;

            if (ClosestTo.HasValue)
            {
                HoveredSlot = InventorySlotBounds.OrderBy(x => x.SquaredDistanceBetweenCenters(ClosestTo.Value)).First();
            }
            else
            {
                if (StartingSide == NavigationDirection.Right)
                {
                    while (TryNavigate(NavigationDirection.Right, NavigationWrappingMode.NoWrap, NavigationWrappingMode.NoWrap))
                    {
                    }
                }
                if (StartingSide == NavigationDirection.Down)
                {
                    while (TryNavigate(NavigationDirection.Down, NavigationWrappingMode.NoWrap, NavigationWrappingMode.NoWrap))
                    {
                    }
                }
            }

            return(true);
        }
Пример #2
0
 public bool TryNavigate(NavigationDirection Direction, NavigationWrappingMode HorizontalWrapping, NavigationWrappingMode VerticalWrapping)
 {
     if (IsGamepadFocused && HoveredSlot == null)
     {
         HoveredSlot             = InventorySlotBounds.FirstOrDefault();
         IsNavigatingWithGamepad = HoveredSlot != null;
         return(HoveredSlot != null);
     }
     else if (TryGetSlotNeighbor(HoveredSlot, Direction, HorizontalWrapping, VerticalWrapping, out Rectangle? Neighbor))
     {
         HoveredSlot             = Neighbor.Value;
         IsNavigatingWithGamepad = true;
         return(true);
     }
     else
     {
         return(false);
     }
 }
Пример #3
0
 public void GainedGamepadFocus()
 {
     RecentlyGainedFocus     = true;
     HoveredSlot             = InventorySlotBounds.First();
     IsNavigatingWithGamepad = true;
 }