当前位置: 首页>>代码示例>>C#>>正文


C# ItemInfo.Clone方法代码示例

本文整理汇总了C#中SqlDataProvider.Data.ItemInfo.Clone方法的典型用法代码示例。如果您正苦于以下问题:C# ItemInfo.Clone方法的具体用法?C# ItemInfo.Clone怎么用?C# ItemInfo.Clone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SqlDataProvider.Data.ItemInfo的用法示例。


在下文中一共展示了ItemInfo.Clone方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SplitItem

        /// <summary>
        /// 拆分物品
        /// </summary>
        /// <param name="item"></param>
        /// <param name="count"></param>
        /// <returns></returns>
        public bool SplitItem(ItemInfo item, int count, int toSlot)
        {
            if (_bagType == 11)
            {
                ConsortiaInfo info = ConsortiaMgr.FindConsortiaInfo(_player.PlayerCharacter.ConsortiaID);
                if (info != null || toSlot >= info.StoreLevel * 10)
                {
                    _player.Out.SendUpdateInventorySlot(item.Place, true, item, _bagType);
                    return false;
                }
            }

            if (item.Count > count && m_items[toSlot] == null)
            {
                ItemInfo clone = item.Clone();
                clone.ItemID = -1;
                clone.Count = count;
                if (AddItemTo(clone, toSlot) != -1)
                {
                    item.Count -= count;
                    _player.Out.SendUpdateInventorySlot(item.Place, true, item, _bagType);
                    _player.Out.SendUpdateInventorySlot(clone.Place, true, clone, _bagType);
                    return true;
                }
            }
            else
            {
                _player.Out.SendUpdateInventorySlot(item.Place, true, item, _bagType);
            }

            return false;
        }
开发者ID:vancourt,项目名称:BaseGunnyII,代码行数:38,代码来源:CommonPage.cs

示例2: SplitItem

        /// <summary>
        /// 拆分物品
        /// </summary>
        /// <param name="item"></param>
        /// <param name="count"></param>
        /// <returns></returns>
        public bool SplitItem(ItemInfo item, int count, int toSlot)
        {
            if (item.Count > count  && _items[toSlot] == null)
            {
                ItemInfo clone = item.Clone();
                clone.ItemID = -1;
                clone.Count = count;
                //clone.Place = toSlot;
                if (AddItem(clone) != -1)
                {
                    UseItem(item);
                    UseItem(clone);
                    item.Count -= count;
                    _player.Out.SendUpdateInventorySlot(item.Place, true, item,_bagType);
                    _player.Out.SendUpdateInventorySlot(clone.Place, true, clone,_bagType);
                    return true;
                }
            }

            return false;
        }
开发者ID:vancourt,项目名称:BaseGunnyII,代码行数:27,代码来源:CommonPage.cs

示例3: AddTemplate

        public virtual bool AddTemplate(ItemInfo cloneItem, int count, int minSlot, int maxSlot)
        {
            if (cloneItem == null) return false;
            ItemTemplateInfo template = cloneItem.Template;
            if (template == null) return false;
            if (count <= 0) return false;
            if (minSlot < m_beginSlot || minSlot > m_capalility - 1) return false;
            if (maxSlot < m_beginSlot || maxSlot > m_capalility - 1) return false;
            if (minSlot > maxSlot) return false;


            lock (m_lock)
            {
                List<int> changedSlot = new List<int>();
                int itemcount = count;

                for (int i = minSlot; i <= maxSlot; i++)
                {
                    ItemInfo item = m_items[i];
                    if (item == null)
                    {
                        itemcount -= template.MaxCount;
                        changedSlot.Add(i);
                    }
                    else if (m_autoStack && cloneItem.CanStackedTo(item))
                    {
                        itemcount -= (template.MaxCount - item.Count);
                        changedSlot.Add(i);
                    }
                    if (itemcount <= 0)
                        break;
                }

                if (itemcount <= 0)
                {
                    BeginChanges();
                    try
                    {
                        itemcount = count;
                        foreach (int i in changedSlot)
                        {
                            ItemInfo item = m_items[i];
                            if (item == null)
                            {
                                item = cloneItem.Clone();

                                item.Count = itemcount < template.MaxCount ? itemcount : template.MaxCount;

                                itemcount -= item.Count;

                                AddItemTo(item, i);
                            }
                            else
                            {
                                if (item.TemplateID == template.TemplateID)
                                {
                                    int add = (item.Count + itemcount < template.MaxCount ? itemcount : template.MaxCount - item.Count);
                                    item.Count += add;
                                    itemcount -= add;

                                    OnPlaceChanged(i);
                                }
                                else
                                {
                                    log.Error("Add template erro: select slot's TemplateId not equest templateId");
                                }
                            }
                        }

                        if (itemcount != 0)
                            log.Error("Add template error: last count not equal Zero.");
                    }
                    finally
                    {
                        CommitChanges();
                    }

                    return true;
                }
                else
                {
                    return false;
                }
            }
        }
开发者ID:geniushuai,项目名称:DDTank-3.0,代码行数:85,代码来源:AbstractInventory.cs


注:本文中的SqlDataProvider.Data.ItemInfo.Clone方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。