示例#1
0
        public override void receiveLeftClick(int x, int y, bool playSound = true)
        {
            if (Game1.globalFade)
            {
                return;
            }
            if (_movingAnimal.GetValue())
            {
                Building buildingAt = (Game1.getLocationFromName("Farm") as Farm).getBuildingAt(new Vector2((float)((x + Game1.viewport.X) / Game1.tileSize), (float)((y + Game1.viewport.Y) / Game1.tileSize)));
                if
                (
                    buildingAt != null &&
                    buildingAt.buildingType.Value.Contains(this._farmAnimal.buildingTypeILiveIn.Value) &&
                    !((AnimalHouse)buildingAt.indoors.Value).isFull() &&
                    !buildingAt.Equals((object)this._farmAnimal.home) &&
                    PregnancyController.IsAnimalPregnant(this._farmAnimal) &&
                    PregnancyController.CheckBuildingLimit(this._farmAnimal)
                )
                {
                    if (this.okButton != null && this.okButton.containsPoint(x, y))
                    {
                        Game1.globalFadeToBlack(new Game1.afterFadeFunction(this.prepareForReturnFromPlacement), 0.02f);
                        Game1.playSound("smallSelect");
                    }
                    Game1.showRedMessage(DataLoader.i18n.Get("Menu.AnimalQueryMenu.PregnancyBuildingLimit", new { buildingType = this._farmAnimal.displayHouse }));
                    return;
                }
            }
            else if (this.confirmingMeat)
            {
                if (this.yesButton.containsPoint(x, y))
                {
                    (this._farmAnimal.home.indoors.Value as AnimalHouse)?.animalsThatLiveHere.Remove(this._farmAnimal.myID.Value);
                    this._farmAnimal.health.Value = -1;
                    int num1 = this._farmAnimal.frontBackSourceRect.Width / 2;
                    for (int index = 0; index < num1; ++index)
                    {
                        int num2 = Game1.random.Next(25, 200);
                        Game1.currentLocation.temporarySprites.Add(new TemporaryAnimatedSprite(5, this._farmAnimal.position + new Vector2((float)Game1.random.Next(-Game1.tileSize / 2, this._farmAnimal.frontBackSourceRect.Width * 3), (float)Game1.random.Next(-Game1.tileSize / 2, this._farmAnimal.frontBackSourceRect.Height * 3)), new Color((int)byte.MaxValue - num2, (int)byte.MaxValue, (int)byte.MaxValue - num2), 8, false, Game1.random.NextDouble() < 0.5 ? 50f : (float)Game1.random.Next(30, 200), 0, Game1.tileSize, -1f, Game1.tileSize, Game1.random.NextDouble() < 0.5 ? 0 : Game1.random.Next(0, 600))
                        {
                            scale  = (float)Game1.random.Next(2, 5) * 0.25f,
                            alpha  = (float)Game1.random.Next(2, 5) * 0.25f,
                            motion = new Vector2(0.0f, (float)-Game1.random.NextDouble())
                        });
                    }
                    Game1.playSound("newRecipe");
                    Game1.playSound("money");
                    Game1.exitActiveMenu();
                    Game1.player.Stamina -= ((float)4f - (float)Game1.player.FarmingLevel * 0.2f);
                    Game1.player.Stamina -= ((float)4f - (float)Game1.player.FarmingLevel * 0.2f);
                    Game1.player.gainExperience(0, 5);
                    MeatController.AddItemsToInventoryByMenuIfNecessary(MeatController.CreateMeat(this._farmAnimal));
                }
                else
                {
                    if (!this.noButton.containsPoint(x, y))
                    {
                        return;
                    }
                    this.confirmingMeat = false;
                    Game1.playSound("smallSelect");
                    if (!Game1.options.SnappyMenus)
                    {
                        return;
                    }
                    this.currentlySnappedComponent = this.getComponentWithID(103);
                    this.snapCursorToCurrentSnappedComponent();
                }
                return;
            }
            else if (!_confirmingSell.GetValue())
            {
                if (this.meatButton?.containsPoint(x, y) ?? false)
                {
                    this.confirmingMeat = true;
                    ClickableTextureComponent textureComponent1 = new ClickableTextureComponent(new Microsoft.Xna.Framework.Rectangle(Game1.viewport.Width / 2 - Game1.tileSize - 4, Game1.viewport.Height / 2 - Game1.tileSize / 2, Game1.tileSize, Game1.tileSize), Game1.mouseCursors, Game1.getSourceRectForStandardTileSheet(Game1.mouseCursors, 46, -1, -1), 1f, false);
                    textureComponent1.myID            = 111;
                    textureComponent1.rightNeighborID = 105;
                    this.yesButton = textureComponent1;
                    ClickableTextureComponent textureComponent2 = new ClickableTextureComponent(new Microsoft.Xna.Framework.Rectangle(Game1.viewport.Width / 2 + 4, Game1.viewport.Height / 2 - Game1.tileSize / 2, Game1.tileSize, Game1.tileSize), Game1.mouseCursors, Game1.getSourceRectForStandardTileSheet(Game1.mouseCursors, 47, -1, -1), 1f, false);
                    textureComponent2.myID           = 105;
                    textureComponent2.leftNeighborID = 111;
                    this.noButton = textureComponent2;
                    Game1.playSound("smallSelect");
                    if (!Game1.options.SnappyMenus)
                    {
                        return;
                    }
                    this.populateClickableComponentList();
                    this.currentlySnappedComponent = (ClickableComponent)this.noButton;
                    this.snapCursorToCurrentSnappedComponent();
                }
                else if ((this.animalContestIndicator?.containsPoint(x, y) ?? false) && AnimalContestController.CanChangeParticipant(this._farmAnimal))
                {
                    this.animalContestIndicator = null;
                    AnimalContestController.RemoveAnimalParticipant(this._farmAnimal);
                    Game1.player.addItemByMenuIfNecessary(ToolsFactory.GetParticipantRibbon());
                }
            }
            else
            {
                if (this.yesButton.containsPoint(x, y) && AnimalContestController.CanChangeParticipant(this._farmAnimal))
                {
                    AnimalContestController.RemoveAnimalParticipant(this._farmAnimal);
                    MeatController.ThrowItem(new List <Item>(new Item[] { ToolsFactory.GetParticipantRibbon() }), this._farmAnimal);
                }
            }

            base.receiveLeftClick(x, y, playSound);
        }