Exemplo n.º 1
0
 public override void receiveGamePadButton(Buttons b)
 {
     base.receiveGamePadButton(b);
     if (b != Buttons.Back)
     {
         return;
     }
     ExpandedFridgeMenu.organizeItemsInList((IList <Item>)Game1.player.items);
     Game1.playSound("Ship");
 }
Exemplo n.º 2
0
        public override void receiveLeftClick(int x, int y, bool playSound = true)
        {
            base.receiveLeftClick(x, y, true);
            foreach (ClickableComponent cc in this.chestTabs)
            {
                if (cc.containsPoint(x, y))
                {
                    int index = int.Parse(cc.label) - 1;
                    if (this.fridgeHub.SetSelectedChest(index))
                    {
                        Game1.activeClickableMenu = this.fridgeHub.CreateMenu();
                        return;
                    }
                }
            }

            this.chestColorPicker.receiveLeftClick(x, y, true);
            if (this.sourceItem != null && this.sourceItem is Chest)
            {
                (this.sourceItem as Chest).playerChoiceColor.Value = this.chestColorPicker.getColorFromSelection(this.chestColorPicker.colorSelection);
                this.selectedTabColor = (this.sourceItem as Chest).playerChoiceColor.Value;
            }

            if (this.colorPickerToggleButton.containsPoint(x, y))
            {
                Game1.player.showChestColorPicker = !Game1.player.showChestColorPicker;
                this.chestColorPicker.visible     = Game1.player.showChestColorPicker;
                try
                {
                    Game1.playSound("drumkit6");
                }
                catch (Exception ex)
                {
                }
            }

            if (this.heldItem == null)
            {
                this.heldItem = this.ItemsToGrabMenu.leftClick(x, y, this.heldItem, false);
                if (this.heldItem != null)
                {
                    this.fridgeHub.grabItemFromChest(this.heldItem, Game1.player);
                    if (Game1.activeClickableMenu != null && Game1.activeClickableMenu is ExpandedFridgeMenu)
                    {
                        (Game1.activeClickableMenu as ExpandedFridgeMenu).setSourceItem(this.sourceItem);
                        if (Game1.options.SnappyMenus)
                        {
                            (Game1.activeClickableMenu as ExpandedFridgeMenu).currentlySnappedComponent = this.currentlySnappedComponent;
                            (Game1.activeClickableMenu as ExpandedFridgeMenu).snapCursorToCurrentSnappedComponent();
                        }
                    }
                }
                if (Game1.player.addItemToInventoryBool(this.heldItem, false))
                {
                    this.heldItem = (Item)null;
                    Game1.playSound("coin");
                }
            }
            else if (this.isWithinBounds(x, y))
            {
                this.fridgeHub.grabItemFromInventory(this.heldItem, Game1.player);
                if (Game1.activeClickableMenu != null && Game1.activeClickableMenu is ExpandedFridgeMenu)
                {
                    (Game1.activeClickableMenu as ExpandedFridgeMenu).setSourceItem(this.sourceItem);
                    if (Game1.options.SnappyMenus)
                    {
                        (Game1.activeClickableMenu as ExpandedFridgeMenu).currentlySnappedComponent = this.currentlySnappedComponent;
                        (Game1.activeClickableMenu as ExpandedFridgeMenu).snapCursorToCurrentSnappedComponent();
                    }
                }
            }
            if (this.organizeButton.containsPoint(x, y))
            {
                ExpandedFridgeMenu.organizeItemsInList(this.ItemsToGrabMenu.actualInventory);
                Game1.activeClickableMenu = this.fridgeHub.CreateMenu();
                (Game1.activeClickableMenu as ExpandedFridgeMenu).heldItem = this.heldItem;
                Game1.playSound("Ship");
            }
            else
            {
                if (this.heldItem == null || this.isWithinBounds(x, y) || !this.heldItem.canBeTrashed())
                {
                    return;
                }
                Game1.playSound("throwDownITem");
                Game1.createItemDebris(this.heldItem, Game1.player.getStandingPosition(), Game1.player.FacingDirection, (GameLocation)null, -1);
                if (this.inventory.onAddItem != null)
                {
                    this.inventory.onAddItem(this.heldItem, Game1.player);
                }
                this.heldItem = (Item)null;
            }
        }