Exemplo n.º 1
0
        public void Update()
        {
            MouseItem.Update();

            Inventory.Update();

            if (MouseInput.MouseClickedLeft())
            {
                if (MouseItem.Item != null && GridCraft.AddItem(MouseInput.MouseRealPosMenu(), _items, MouseItem.Item.Rotation) == true)
                {
                    if (Game1.PlayerInstance.Items.Any(i => i.Type == MouseItem.Item.Type) == true)
                    {
                        Game1.PlayerInstance.Items.Single(i => i.Type == MouseItem.Item.Type).Amount--;
                    }

                    if (Game1.PlayerInstance.Items.Single(i => i.Type == MouseItem.Item.Type).Amount <= 0)
                    {
                        Game1.PlayerInstance.Items.Remove(Game1.PlayerInstance.Items.Single(i => i.Type == MouseItem.Item.Type));
                    }

                    MouseItem.Item = null;

                    Inventory.ResetChoosed();
                    CalculateAll();
                }
            }

            if (MouseInput.MouseClickedRight())
            {
                GridItem item = GridCraft.RemoveItem(MouseInput.MouseRealPosMenu(), _items);

                if (item != null)
                {
                    if (Game1.PlayerInstance.Items.Any(i => i.Type == item.Type) == true)
                    {
                        Game1.PlayerInstance.Items.Single(i => i.Type == item.Type).Amount++;
                    }
                    else
                    {
                        Game1.PlayerInstance.Items.Add(new PlayersItem(item.Type, 1));
                    }
                }

                UIShop.Instance.Sync();

                CalculateAll();
            }
            UIShop.Instance.Sync();
            Inventory.Set();
        }