示例#1
0
 private void GameLoop_DayStarted(object sender, StardewModdingAPI.Events.DayStartedEventArgs e)
 {
     foreach (var shopid in MapTKShop.Bought.Keys)
     {
         if (MapTKShop.GetShop(Plato.ModHelper, shopid) is MapTKShop shop &&
             (shop.Restock == "Daily" || (shop.Restock == "Monthly" && Game1.dayOfMonth == 1) || (shop.Restock == "Yearly" && Game1.dayOfMonth == 1 && Game1.currentSeason.ToLower() == "spring")))
         {
             MapTKShop.Bought.Remove(shopid);
         }
     }
 }
示例#2
0
        private void OpenMapTKShop(string shopId)
        {
            if (!string.IsNullOrEmpty(shopId) && MapTKShop.GetShop(Plato.ModHelper, shopId) is MapTKShop shop)
            {
                LastShop = shopId;

                var shopMenu = new ShopMenu(MapTKShop.GetInventory(LastShop, Plato.ModHelper), shop.Currency);

                if (shop.Restock != "Always")
                {
                    shopMenu.onPurchase = SoldItemInCustomShop;
                }

                try
                {
                    if (shop.ShopKeeper != "")
                    {
                        if (Game1.getCharacterFromName(shop.ShopKeeper) is NPC shopkeeper)
                        {
                            shopMenu.setUpShopOwner(shop.ShopKeeper);
                            shopMenu.portraitPerson = shopkeeper;
                        }
                        else
                        {
                            var npc = new NPC(null, Vector2.Zero, "Town", 0, shop.ShopKeeper.Split('.')[0], false, null, Plato.ModHelper.Content.Load <Texture2D>(Path.Combine(ShopPortraitsToken.ShopPortraitsPrefix, shop.ShopKeeper), ContentSource.GameContent));
                            shopMenu.portraitPerson = npc;
                            Game1.removeThisCharacterFromAllLocations(npc);
                        }
                    }
                }
                catch
                {
                }

                if (shop.Message != "")
                {
                    shopMenu.potraitPersonDialogue = Game1.parseText(shop.Message, Game1.dialogueFont, 304);
                }

                Game1.activeClickableMenu = shopMenu;
            }
        }