本文整理汇总了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;
}
示例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;
}
示例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;
}
}
}