本文整理汇总了C#中Item.IsOfType方法的典型用法代码示例。如果您正苦于以下问题:C# Item.IsOfType方法的具体用法?C# Item.IsOfType怎么用?C# Item.IsOfType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Item
的用法示例。
在下文中一共展示了Item.IsOfType方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LoadItems
/// <summary>
/// Load the master item dictionary, so
/// if we have to create a new item, we look it up in the
/// master dictionary.
/// </summary>
public static void LoadItems()
{
//string itemPath = Config.GetDataPath() + "items/" + "items.dat"; TODO: REMOVE
string itemPath = Config.GetDataPath() + Config.GetItemDirectory() + "items.dat";
Dictionary<ushort, Item> dict = new Dictionary<ushort, Item>();
BinaryReader bReader = new BinaryReader(File.Open(itemPath, FileMode.Open));
ushort itemCount = bReader.ReadUInt16();
//Console.WriteLine("ItemCount: " + itemCount);
for (int i = 0; i < itemCount; i++) {
ushort id = bReader.ReadUInt16(); //item id
Item item = new Item(id);
item.Type = bReader.ReadUInt32(); //item type
item.Article = bReader.ReadString(); //Article, "a", "an", if any
item.Name = bReader.ReadString(); //item name
item.LightLevel = bReader.ReadByte();
item.Speed = bReader.ReadByte();
byte attributeCount = bReader.ReadByte();
for (int j = 0; j < attributeCount; j++) {
string key = bReader.ReadString(); //Key
string value = bReader.ReadString(); //Value
item.AddAtribute(key, value);
}
if (item.GetAttribute(Constants.ATTRIBUTE_CONTAINER_SIZE) != null
&& !item.IsOfType(Constants.TYPE_CONTAINER)) {
/*Console.WriteLine("Item: " + item.Name + " is a container"
+ " but does not have a container type.");*/
}
if (!dict.ContainsKey(id)) {
dict.Add(id, item);
} /*else {
#if DEBUG
Tracer.Println("Warning! Duplicate key: " + id);
#endif
}*/
}
itemDict = dict;
CompileActions();
}
示例2: AddItemRaw
private void AddItemRaw(Item item)
{
//TODO: Finish this code
netmsg.AddU16((ushort)conversion[item.ItemID]);
if (item.IsOfType(Constants.TYPE_FLUID_CONTAINER)) {
netmsg.AddByte(0x00);
}
if (item.IsOfType(Constants.TYPE_STACKABLE)) {
netmsg.AddByte(0x00);
}
}
示例3: AddItemRaw
private void AddItemRaw(Item item, bool carrying, bool defaultByte,
bool screenItem)
{
netmsg.AddU16(item.ItemID);
if (item.IsOfType(Constants.TYPE_LIGHT_ITEMS) && !carrying) {
netmsg.AddByte(0x06); //Item light level
} else if (item.IsOfType(Constants.TYPE_STACKABLE)) {
netmsg.AddByte(item.Count); //Item count
} else if (item.IsOfType(Constants.TYPE_FLUID_CONTAINER)) {
netmsg.AddByte((byte)item.FluidType); //Fluid type
} else if (defaultByte) { //Required
netmsg.AddByte(0x00); //No type
}
if (screenItem) {
netmsg.AddByte(0x00);
netmsg.AddU16(0x00);
}
}