本文整理汇总了C#中WCell.RealmServer.Items.ItemTemplate类的典型用法代码示例。如果您正苦于以下问题:C# ItemTemplate类的具体用法?C# ItemTemplate怎么用?C# ItemTemplate使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ItemTemplate类属于WCell.RealmServer.Items命名空间,在下文中一共展示了ItemTemplate类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LootItem
public LootItem(ItemTemplate templ, int amount, uint index, uint randomPropertyId)
{
Template = templ;
Amount = amount;
Index = index;
RandomPropertyId = randomPropertyId;
}
示例2: GetHappinessGain
public int GetHappinessGain(ItemTemplate food)
{
if (food == null) return 0;
// TODO: Replace constants with named Variables
var diff = (Level - (int)food.Level);
if (diff > 0)
{
if (diff < 16)
{
return PetMgr.MaxFeedPetHappinessGain;
}
if (diff < 26)
{
return (PetMgr.MaxFeedPetHappinessGain / 2);
}
if (diff < 36)
{
return (PetMgr.MaxFeedPetHappinessGain / 4);
}
}
else
{
if (diff > -16)
{
return PetMgr.MaxFeedPetHappinessGain;
}
}
return 0;
}
示例3: VendorItem
/// <param name="template">The ItemTemplate for this item.</param>
/// <param name="numStacksForSale">The maximum number of lots of this item the vendor can sell per period of time. 0xFFFFFFFF means infinite.</param>
/// <param name="buyStackSize">The vendor sells these items in lots of buyStackSize.</param>
/// <param name="regenTime">If the vendor has a limited number of this item to sell, this is the time it takes to regen one item.</param>
public VendorItem( ItemTemplate template, uint numStacksForSale, uint buyStackSize, uint regenTime )
{
Template = template;
this.numStacksForSale = numStacksForSale;
maxStacksForSale = numStacksForSale;
BuyStackSize = buyStackSize;
lastUpdate = DateTime.Now;
this.regenTime = regenTime;
}
示例4: SendItemNameQueryResponse
public static void SendItemNameQueryResponse(IPacketReceiver client, ItemTemplate item)
{
using (var outPacket = new RealmPacketOut(RealmServerOpCode.SMSG_ITEM_NAME_QUERY_RESPONSE, 4 + item.DefaultName.Length))
{
outPacket.WriteInt(item.Id);
outPacket.WriteCString(item.DefaultName);
client.Send(outPacket);
}
}
示例5: Ensure
public InventoryError Ensure(ItemTemplate templ, int amount, bool equip)
{
if (equip && templ.EquipmentSlots == null)
{
return InventoryError.ITEM_CANT_BE_EQUIPPED;
}
if (templ.EquipmentSlots != null)
{
for (var i = 0; i < templ.EquipmentSlots.Length; i++)
{
var slot = templ.EquipmentSlots[i];
var item = m_Items[(int)slot];
if (item != null && item.Template.Id == templ.Id)
{
// done
return InventoryError.OK;
}
}
}
var found = 0;
if (Iterate(item =>
{
if (item.Template == templ)
{
found += item.Amount;
if (equip && !item.IsEquipped)
{
TryEquip(this, item.Slot);
return false;
}
else if (found >= amount)
{
return false;
}
}
return true;
}))
{
// didn't add everything yet
amount -= found;
if (!equip)
{
return TryAdd(templ, ref amount);
}
var slot = GetEquipSlot(templ, true);
if (slot == InventorySlot.Invalid)
{
return InventoryError.INVENTORY_FULL;
}
return TryAdd(templ, slot);
}
return InventoryError.OK;
}
示例6: TryAdd
/// <summary>
/// Tries to add a single new item with the given template to the given slot.
/// Make sure the given targetSlot is valid before calling this method.
/// </summary>
public InventoryError TryAdd(ItemTemplate template, EquipmentSlot targetSlot)
{
var amount = 1;
return TryAdd(template, ref amount, (int)targetSlot, true);
}
示例7: FindFreeSlotCheck
/// <summary>
/// Finds a free slot after checking for uniqueness
/// </summary>
/// <param name="templ"></param>
/// <param name="amount"></param>
/// <returns></returns>
public SimpleSlotId FindFreeSlotCheck(ItemTemplate templ, int amount)
{
var err = InventoryError.OK;
var possibleAmount = amount;
CheckUniqueness(templ, ref possibleAmount, ref err, true);
if (possibleAmount != amount)
{
return SimpleSlotId.Default;
}
return FindFreeSlot(templ, amount);
}
示例8: SendRefundInfo
private static void SendRefundInfo(IRealmClient client, ItemTemplate item)
{
//throw new NotImplementedException();
}
示例9: SendItemPushResult
/// <summary>
/// Sends the Item's PushResult (required after adding items).
/// </summary>
public static void SendItemPushResult(Character owner, Item item, ItemTemplate templ, int amount, ItemReceptionType reception)
{
bool isStacked;
int contSlot;
uint propertySeed, randomPropid;
if (item != null)
{
contSlot = item.Container.Slot;
isStacked = item.Amount != amount; // item.Amount == amount means that it was not added to an existing stack
propertySeed = item.PropertySeed;
randomPropid = item.RandomPropertiesId;
}
else
{
contSlot = BaseInventory.INVALID_SLOT;
isStacked = true; // we did not have an item -> stacked
propertySeed = 0;
randomPropid = 0;
}
using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_ITEM_PUSH_RESULT, 45))
{
packet.Write(owner.EntityId);
packet.Write((ulong)reception);
//packet.Write(received ? 1 : 0); // 0 = "You looted...", 1 = "You received..."
//packet.Write(isNew ? 1 : 0); // 0 = "You received/looted...", 1 = "You created..."
packet.Write(1); // log message
packet.Write((byte)contSlot);
packet.Write(isStacked ? -1 : item.Slot);
packet.Write(templ.Id);
packet.Write(propertySeed);
packet.Write(randomPropid);
packet.Write(amount); // amount added
packet.Write(owner.Inventory.GetAmount(templ.ItemId)); // amount of that type of item in inventory
owner.Send(packet);
}
}
示例10: Distribute
public override bool Distribute(ItemTemplate template, ref int amount)
{
// distribute to ammo
if (m_ammo != null && m_ammo.Template == template)
{
var diff = template.MaxAmount - m_ammo.Amount;
if (diff > 0)
{
if (amount <= diff)
{
m_ammo.Amount += amount;
return true; // done
}
m_ammo.Amount += diff;
amount -= diff;
}
}
return base.Distribute(template, ref amount);
}
示例11: SetItem
/// <summary>
/// Set the Item at the given slot on this corpse.
/// </summary>
public void SetItem(EquipmentSlot slot, ItemTemplate template)
{
//var id = (template.DisplayId & 0x00FFFFFF) | (uint)((int)template.InventorySlotType << 24);
var id = template.DisplayId | (uint)((int)template.InventorySlotType << 24);
var slotId = (int)CorpseFields.ITEM + (int)slot;
SetUInt32(slotId, id);
//Array.Copy(characterFields, (int)PlayerFields.VISIBLE_ITEM_1_0,
// m_updateValues, (int)CorpseFields.ITEM, EmptyItemFields.Length);
//if (!m_queuedForUpdate && m_isInWorld)
//{
// RequestUpdate();
//}
}
示例12: ItemStackTemplate
public ItemStackTemplate(ItemTemplate templ)
: this(templ, templ.MaxAmount)
{
}
示例13: MayAddToContainer
/// <summary>
/// For templates of Containers only, checks whether the given
/// Template may be added
/// </summary>
/// <param name="templ"></param>
/// <returns></returns>
public bool MayAddToContainer(ItemTemplate templ)
{
return BagFamily == 0 || templ.BagFamily.HasAnyFlag(BagFamily);
}
示例14: CheckEquippedGems
internal bool CheckEquippedGems(ItemTemplate gemTempl)
{
if (gemTempl != null && gemTempl.Flags.HasFlag(ItemFlags.UniqueEquipped))
{
// may only equip a certain maximum of this kind of gem
for (var slot = EquipmentSlot.Head; slot < EquipmentSlot.Bag1; slot++)
{
var item = this[slot];
if (item != null && item.HasGem(gemTempl.ItemId))
{
return false;
}
}
}
return true;
}
示例15: CreateRecord
public static ItemRecord CreateRecord(ItemTemplate templ)
{
var item = CreateRecord();
item.EntryId = templ.Id;
item.Amount = templ.MaxAmount;
item.Durability = templ.MaxDurability;
item.Flags = templ.Flags;
item.ItemTextId = templ.PageTextId;
item.RandomProperty = (int)(templ.RandomPropertiesId != 0 ? templ.RandomPropertiesId : templ.RandomSuffixId);
item.RandomSuffix = (int) templ.RandomSuffixId;
item.Duration = templ.Duration;
if (templ.UseSpell != null)
{
item.Charges = (short)templ.UseSpell.Charges;
}
return item;
}