本文整理汇总了C#中Pocket类的典型用法代码示例。如果您正苦于以下问题:C# Pocket类的具体用法?C# Pocket怎么用?C# Pocket使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Pocket类属于命名空间,在下文中一共展示了Pocket类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Item
public Item(int itemId, Pocket pocket, uint color1, uint color2, uint color3)
{
this.Info.Id = itemId;
this.Info.Pocket = pocket;
this.Info.Color1 = color1;
this.Info.Color2 = color2;
this.Info.Color3 = color3;
}
示例2: EquipmentMoved
/// <summary>
/// Broadcasts EquipmentMoved in creature's range.
/// </summary>
/// <param name="creature"></param>
/// <param name="from"></param>
public static void EquipmentMoved(Creature creature, Pocket from)
{
var packet = new Packet(Op.EquipmentMoved, creature.EntityId);
packet.PutByte((byte)from);
packet.PutByte(1);
creature.Region.Broadcast(packet, creature);
}
示例3: Item
public Item(string n, string d, ushort p, Pocket b, Action<Pokemon, int> a)
{
name = n;
description = d;
price = p;
pocket = b;
battleEffect = a;
fieldEffect = a;
}
示例4: EquipItem
protected virtual void EquipItem(Pocket slot, string itemName, uint color1 = 0, uint color2 = 0, uint color3 = 0)
{
var dbInfo = MabiData.ItemDb.Find(itemName);
if (dbInfo == null)
{
Logger.Warning("Unknown item '" + itemName + "' cannot be eqipped. Try specifying the ID manually.");
return;
}
this.EquipItem(slot, dbInfo.Id, color1, color2, color3);
}
示例5: EquipItem
protected virtual void EquipItem(Pocket pocket, uint itemClass, uint color1 = 0, uint color2 = 0, uint color3 = 0)
{
var item = new MabiItem(itemClass);
item.Info.ColorA = color1;
item.Info.ColorB = color2;
item.Info.ColorC = color3;
item.Info.Pocket = (byte)pocket;
//var inPocket = this.Creature.GetItemInPocket(slot);
//if (inPocket != null)
// this.Creature.Items.Remove(inPocket);
this.Creature.Items.Add(item);
Send.EquipmentChanged(this.Creature, item);
}
示例6: ItemMoveInfo
/// <summary>
/// Sends ItemMoveInfo or ItemSwitchInfo to creature's client,
/// depending on whether collidingItem is null.
/// </summary>
/// <param name="creature"></param>
/// <param name="item"></param>
/// <param name="source"></param>
/// <param name="target"></param>
/// <param name="collidingItem"></param>
public static void ItemMoveInfo(Creature creature, Item item, Pocket source, Item collidingItem)
{
var packet = new Packet((collidingItem == null ? Op.ItemMoveInfo : Op.ItemSwitchInfo), creature.EntityId);
packet.PutLong(item.EntityId);
packet.PutByte((byte)source);
packet.PutByte((byte)item.Info.Pocket);
packet.PutByte(2);
packet.PutByte((byte)item.Info.X);
packet.PutByte((byte)item.Info.Y);
if (collidingItem != null)
{
packet.PutLong(collidingItem.EntityId);
packet.PutByte((byte)item.Info.Pocket);
packet.PutByte((byte)collidingItem.Info.Pocket);
packet.PutByte(2);
packet.PutByte((byte)collidingItem.Info.X);
packet.PutByte((byte)collidingItem.Info.Y);
}
creature.Client.Send(packet);
}
示例7: Move
/// <summary>
/// Modifies position in inventory.
/// </summary>
/// <param name="pocket"></param>
/// <param name="x"></param>
/// <param name="y"></param>
public void Move(Pocket pocket, int x, int y)
{
this.Info.Pocket = pocket;
this.Info.Region = 0;
this.Info.X = x;
this.Info.Y = y;
}
示例8: CheckLeftHand
/// <summary>
/// Unequips item in left hand/magazine, if item in right hand is moved.
/// </summary>
/// <param name="item"></param>
/// <param name="source"></param>
/// <param name="target"></param>
private void CheckLeftHand(Item item, Pocket source, Pocket target)
{
var pocketOfInterest = Pocket.None;
if (source == Pocket.RightHand1 || source == Pocket.RightHand2)
pocketOfInterest = source;
if (target == Pocket.RightHand1 || target == Pocket.RightHand2)
pocketOfInterest = target;
if (pocketOfInterest == Pocket.None)
return;
// Check LeftHand first, switch to Magazine if it's empty
var leftPocket = pocketOfInterest + 2; // Left Hand 1/2
var leftItem = _pockets[leftPocket].GetItemAt(0, 0);
if (leftItem == null)
{
leftPocket += 2; // Magazine 1/2
leftItem = _pockets[leftPocket].GetItemAt(0, 0);
// Nothing to remove
if (leftItem == null)
return;
}
// Try inventory first.
// TODO: List of pockets stuff can be auto-moved to.
var success = _pockets[Pocket.Inventory].Add(leftItem);
// Fallback, temp inv
if (!success)
success = _pockets[Pocket.Temporary].Add(leftItem);
if (success)
{
_pockets[leftPocket].Remove(leftItem);
Send.ItemMoveInfo(_creature, leftItem, leftPocket, null);
Send.EquipmentMoved(_creature, leftPocket);
}
}
示例9: MovePet
/// <summary>
/// Moving item between char and pet, used from handler.
/// </summary>
/// <param name="pet">Always the pet</param>
/// <param name="item"></param>
/// <param name="other">The "other" creature, player when taking out, pet when putting in.</param>
/// <param name="target"></param>
/// <param name="targetX"></param>
/// <param name="targetY"></param>
/// <returns></returns>
public bool MovePet(Creature pet, Item item, Creature other, Pocket target, int targetX, int targetY)
{
if (!this.Has(target) || !other.Inventory.Has(target))
return false;
var source = item.Info.Pocket;
var amount = item.Info.Amount;
// We have to copy the item to get a new id, otherwise there could
// be collisions when saving, because the moved item is still in
// the inventory of the pet/character (from the pov of the db).
// http://dev.mabinoger.com/forum/index.php/topic/804-pet-inventory/
var newItem = new Item(item);
Item collidingItem = null;
if (!other.Inventory._pockets[target].TryAdd(newItem, (byte)targetX, (byte)targetY, out collidingItem))
return false;
// If amount differs (item was added to stack)
if (collidingItem != null && newItem.Info.Amount != amount)
{
Send.ItemAmount(other, collidingItem);
// Left overs, update
if (newItem.Info.Amount > 0)
{
Send.ItemAmount(_creature, item);
}
// All in, remove from cursor.
else
{
_pockets[item.Info.Pocket].Remove(item);
Send.ItemRemove(_creature, item);
}
}
else
{
// Remove the item from the source pocket
_pockets[source].Remove(item);
Send.ItemRemove(_creature, item, source);
if (collidingItem != null)
{
// Remove colliding item
Send.ItemRemove(other, collidingItem, target);
// Toss it in, it should be the cursor.
_pockets[source].Add(collidingItem);
Send.ItemNew(_creature, collidingItem);
}
Send.ItemNew(other, newItem);
Send.ItemMoveInfo(_creature, item, source, collidingItem);
}
pet.Inventory.UpdateInventory(newItem, source, target);
return true;
}
示例10: Has
/// <summary>
/// Returns true if pocket exists in this inventory.
/// </summary>
/// <param name="pocket"></param>
/// <returns></returns>
public bool Has(Pocket pocket)
{
return _pockets.ContainsKey(pocket);
}
示例11: Add
/// <summary>
/// Tries to add item to pocket. Returns false if the pocket
/// doesn't exist or there was no space.
/// </summary>
public bool Add(int itemId, Pocket pocket)
{
var item = new Item(itemId);
if (!this.Add(item, pocket))
return false;
this.CheckEquipMoved(item, Pocket.None, pocket);
return true;
}
示例12: GetItemAt
/// <summary>
/// Returns item at the location, or null.
/// </summary>
/// <param name="pocket"></param>
/// <param name="x"></param>
/// <param name="y"></param>
/// <returns></returns>
public Item GetItemAt(Pocket pocket, int x, int y)
{
return !this.Has(pocket) ? null : _pockets[pocket].GetItemAt(x, y);
}
示例13: CheckEquipMoved
/// <summary>
/// Runs equipment updates if necessary.
/// </summary>
/// <param name="item"></param>
/// <param name="source"></param>
/// <param name="target"></param>
private void CheckEquipMoved(Item item, Pocket source, Pocket target)
{
if (source.IsEquip())
Send.EquipmentMoved(_creature, source);
if (target.IsEquip())
Send.EquipmentChanged(_creature, item);
// Send stat update when moving equipment
if (source.IsEquip() || target.IsEquip())
this.UpdateEquipStats();
}
示例14: InventoryPocketStack
public InventoryPocketStack(Pocket pocket)
: base(pocket)
{
_items = new List<Item>();
}
示例15: GetAllItemsFrom
/// <summary>
/// Returns list of all items in pocket. Returns null if the pocket
/// doesn't exist.
/// </summary>
/// <param name="pocket"></param>
/// <returns></returns>
public List<Item> GetAllItemsFrom(Pocket pocket)
{
if (!_pockets.ContainsKey(pocket))
return null;
return _pockets[pocket].Items.Where(a => a != null).ToList();
}