示例#1
0
        /*********
        ** Private methods
        *********/
        /// <summary>Regenerate the UI.</summary>
        private void setUpPositions()
        {
            this.Labels.Clear();
            this.OkButton     = new ClickableTextureComponent("OK", new Rectangle(this.xPositionOnScreen + this.width - IClickableMenu.borderWidth - IClickableMenu.spaceToClearSideBorder - Game1.tileSize, this.yPositionOnScreen + this.height - IClickableMenu.borderWidth - IClickableMenu.spaceToClearTopBorder + Game1.tileSize / 4, Game1.tileSize, Game1.tileSize), "", null, Game1.mouseCursors, Game1.getSourceRectForStandardTileSheet(Game1.mouseCursors, 46), 1f);
            this._leftButton  = new ClickableTextureComponent("LeftButton", new Rectangle(this.xPositionOnScreen + this.width - IClickableMenu.borderWidth - IClickableMenu.spaceToClearSideBorder - Game1.tileSize, this.yPositionOnScreen + this.height - IClickableMenu.borderWidth - IClickableMenu.spaceToClearTopBorder + Game1.tileSize / 4 + 96, Game1.tileSize, Game1.tileSize), "", null, HappyBirthday.ModHelper.Content.Load <Texture2D>(Path.Combine("ModAssets", "Graphics", "lastPageButton.png")), new Rectangle(0, 0, 32, 32), 2f);
            this._rightButton = new ClickableTextureComponent("RightButton", new Rectangle(this.xPositionOnScreen + this.width - IClickableMenu.borderWidth - IClickableMenu.spaceToClearSideBorder - Game1.tileSize + 96, this.yPositionOnScreen + this.height - IClickableMenu.borderWidth - IClickableMenu.spaceToClearTopBorder + Game1.tileSize / 4 + 96, Game1.tileSize, Game1.tileSize), "", null, HappyBirthday.ModHelper.Content.Load <Texture2D>(Path.Combine("ModAssets", "Graphics", "nextPageButton.png")), new Rectangle(0, 0, 32, 32), 2f);

            string title = HappyBirthday.Config.translationInfo.getTranslatedString("FavoriteGift");

            this.Labels.Add(new ClickableComponent(new Rectangle(this.xPositionOnScreen + 128, this.yPositionOnScreen + 128, 1, 1), title));

            this.itemButtons.Clear();


            for (int row = 0; row < this._maxRowsToDisplay; row++)
            {
                for (int column = 0; column < this._maxColumnsToDisplay; column++)
                {
                    int value = (this.currentPageNumber * this._maxRowsToDisplay * this._maxColumnsToDisplay) + (row * this._maxColumnsToDisplay) + (column);
                    if (value >= GiftIDS.RegisteredGifts.Count)
                    {
                        continue;
                    }


                    GiftInformation           info            = new GiftInformation(GiftIDS.RegisteredGifts.ElementAt(value).Key, 0, 1, 1);
                    Rectangle                 textureBounds   = GameLocation.getSourceRectForObject(info.getOne().ParentSheetIndex);
                    float                     itemScale       = 4f;
                    Rectangle                 placementBounds = new Rectangle((int)(this.xPositionOnScreen + 64 + column * 16 * itemScale), (int)(this.yPositionOnScreen + (256) + row * 16 * itemScale), 64, 64);
                    ClickableTextureComponent item            = new ClickableTextureComponent(info.objectID, placementBounds, "", info.objectID, Game1.objectSpriteSheet, textureBounds, 4f, true);
                    this.itemButtons.Add(item);
                }
            }
        }
示例#2
0
        /// <summary>
        /// Tries to get a spouse birthday gift.
        /// </summary>
        /// <param name="name"></param>
        public void getSpouseBirthdayGift(string name)
        {
            if (string.IsNullOrEmpty(HappyBirthday.Instance.PlayerData.favoriteBirthdayGift) == false)
            {
                Item I = GiftIDS.RegisteredGifts[HappyBirthday.Instance.PlayerData.favoriteBirthdayGift];
                if (Game1.player.isInventoryFull())
                {
                    Game1.createItemDebris(I.getOne(), Game1.player.getStandingPosition(), Game1.player.getDirection());
                }
                else
                {
                    this.BirthdayGiftToReceive = I.getOne();
                }
                return;
            }


            if (string.IsNullOrEmpty(HappyBirthday.PlayerBirthdayData.favoriteBirthdayGift) == false)
            {
                if (GiftIDS.RegisteredGifts.ContainsKey(HappyBirthday.PlayerBirthdayData.favoriteBirthdayGift))
                {
                    GiftInformation info = new GiftInformation(HappyBirthday.PlayerBirthdayData.favoriteBirthdayGift, 0, 1, 1);
                    if (Game1.player.isInventoryFull())
                    {
                        Game1.createItemDebris(info.getOne(), Game1.player.getStandingPosition(), Game1.player.getDirection());
                    }
                    else
                    {
                        this.BirthdayGiftToReceive = info.getOne();
                    }
                }

                return;
            }


            int heartLevel = Game1.player.getFriendshipHeartLevelForNPC(name);


            List <Item> possibleItems = new List <Item>();

            if (SpouseBirthdayGifts.ContainsKey(name))
            {
                List <GiftInformation> npcPossibleGifts = SpouseBirthdayGifts[name];
                foreach (GiftInformation info in npcPossibleGifts)
                {
                    if (info.minRequiredHearts <= heartLevel && heartLevel <= info.maxRequiredHearts)
                    {
                        possibleItems.Add(info.getOne());
                    }
                }

                Item gift;
                int  index = StardewValley.Game1.random.Next(possibleItems.Count);
                gift = possibleItems[index];
                if (Game1.player.isInventoryFull())
                {
                    Game1.createItemDebris(gift, Game1.player.getStandingPosition(), Game1.player.getDirection());
                }
                else
                {
                    this.BirthdayGiftToReceive = gift;
                }
            }
            else
            {
                this.getNonSpouseBirthdayGift(name);
            }
        }