コード例 #1
0
        private void GameEvents_OnAfterLoadedContent(object sender, System.EventArgs e)
        {
            Farmhand.API.Items.Item.RegisterItem <Bluemelon>(Bluemelon.Information);
            Farmhand.API.Items.Item.RegisterItem <BluemelonSeeds>(BluemelonSeeds.Information);
            Farmhand.API.Crops.Crop.RegisterCrop <TestCrop>(TestCrop.Information);

            // Adds a new item to piere's shop, with a delegate to check whether or not they're on sale
            ShopUtilities.AddToShopStock(Instance, Shops.Pierre, BluemelonSeeds.Information, new ShopUtilities.CheckIfAddShopStock(CheckIfBluemelonSeedsAreOnSale), 123);
            // Adds a new item to joja's shop, without a delegate to check whether or not they're no sale, so they always will be
            ShopUtilities.AddToShopStock(Instance, Shops.Joja, BluemelonSeeds.Information, 123);
        }
コード例 #2
0
        protected void InjectStock(Shops shop)
        {
            Dictionary <Item, int[]> newStock = ShopUtilities.GetNewStock(shop);

            foreach (KeyValuePair <Item, int[]> stock in newStock)
            {
                forSale.Add(stock.Key);
                itemPriceAndStock.Add(stock.Key, stock.Value);
            }
            injectedStock = newStock;
        }
コード例 #3
0
        /// <summary>
        ///     Injects stock into the shop.
        /// </summary>
        /// <param name="shop">
        ///     The shop to inject into.
        /// </param>
        protected void InjectStock(Shops shop)
        {
            var newStock = ShopUtilities.GetNewStock(shop);

            foreach (var stock in newStock)
            {
                this.forSale.Add(stock.Key);
                this.itemPriceAndStock.Add(stock.Key, stock.Value);
            }

            this.injectedStock = newStock;
        }
コード例 #4
0
        /// <summary>
        /// Opens a registered custom shop
        /// </summary>
        /// <param name="owner">Instance of mod which created the shop</param>
        /// <param name="shopName">String identifier of shop to open</param>
        public static void OpenShop(Mod owner, string shopName)
        {
            string internalShopName = ShopUtilities.GetInternalShopName(owner, shopName);

            if (ShopUtilities.RegisteredShops.ContainsKey(internalShopName))
            {
                Game1.activeClickableMenu = new ShopMenu(ShopUtilities.GetStock(owner, shopName), ShopUtilities.RegisteredShops[internalShopName].CurrencyType, null);
            }
            else
            {
                Logging.Log.Warning($"Shop {internalShopName} not found! Could not open shop.");
            }
        }
コード例 #5
0
        private void GameEvents_OnAfterLoadedContent(object sender, System.EventArgs e)
        {
            // Register the DimensionalSack
            Farmhand.API.Tools.Tool.RegisterTool <StardewValley.Tool>(DimensionalSack.Information);

            // Register the new shop
            ShopUtilities.RegisterShop(Instance, "DimensionalSack");
            // Add stock to the new shop
            ShopUtilities.AddToShopStock(Instance, "DimensionalSack", StockType.Item, 167, 5);
            ShopUtilities.AddToShopStock(Instance, "DimensionalSack", StockType.Item, 168);
            ShopUtilities.AddToShopStock(Instance, "DimensionalSack", StockType.Item, 169);
            ShopUtilities.AddToShopStock(Instance, "DimensionalSack", StockType.Item, 170);
            ShopUtilities.AddToShopStock(Instance, "DimensionalSack", StockType.Item, 171);
            ShopUtilities.AddToShopStock(Instance, "DimensionalSack", StockType.Item, 172);
        }