コード例 #1
0
 private void AddItems(string locationName, ShopMenuProxy shopMenu, IDictionary <string, IList <ShopItemInfo> > shopItemsInfo, Func <ShopItemInfo, Object> createItem)
 {
     if (!shopItemsInfo.TryGetValue(locationName, out var shopItems))
     {
         return;
     }
     foreach (var shopItem in shopItems)
     {
         shopMenu.AddItem(createItem(shopItem));
     }
 }
コード例 #2
0
        private void MenuEventsOnMenuChanged(object sender, EventArgsClickableMenuChanged e)
        {
            if (!(e.NewMenu is ShopMenu shopMenu))
            {
                return;
            }

            CurrentShopMenu = new ShopMenuProxy(shopMenu);
            WrapMenuItems();

            GameEvents.UpdateTick += OnMenuUpdateTick;
        }
コード例 #3
0
        private void OnMenuChanged(object sender, EventArgsClickableMenuChanged args)
        {
            var locationName = Game1.currentLocation?.Name;

            if (!Shops.Contains(locationName) || !(args.NewMenu is ShopMenu shopMenu))
            {
                return;
            }

            var menuProxy = new ShopMenuProxy(shopMenu);

            AddItems(locationName, menuProxy, ShopFurniture, si => new Furniture(si.ID, Vector2.Zero));
            // TODO: Other items.

            MenuItemsAdded?.Invoke(this, args);
        }