本文整理汇总了C#中Tokenizer.SkipTo方法的典型用法代码示例。如果您正苦于以下问题:C# Tokenizer.SkipTo方法的具体用法?C# Tokenizer.SkipTo怎么用?C# Tokenizer.SkipTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tokenizer
的用法示例。
在下文中一共展示了Tokenizer.SkipTo方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LoadItems
//.........这里部分代码省略.........
case Keyword.Weight:
item.weight = t.GetNumberFloat();
if (item.weight < 0)
throw new Exception(string.Format("Item '{0}' have nagative weight {1}.", item.id, item.weight));
break;
case Keyword.Attack:
item.power = t.GetInt();
if (item.power < 0)
throw new Exception(string.Format("Item '{0}' have negative attack {1}.", item.id, item.power));
break;
case Keyword.Defense:
item.power = t.GetInt();
if (item.power < 0)
throw new Exception(string.Format("Item '{0}' can't have negative defense {1}.", item.id, item.power));
break;
case Keyword.Subtype:
if (item.type == Type.Weapon)
item.subtype = (int)t.GetKeyword<WeaponType>();
else
item.subtype = (int)t.GetKeyword<AmmoType>();
break;
case Keyword.Material:
item.material = t.GetKeyword<Material>();
break;
case Keyword.Capacity:
item.capacity = t.GetInt();
if(item.capacity < 1)
throw new Exception(string.Format("Item '{0}' have negative capacity {1}.", item.id, item.capacity));
break;
case Keyword.Range:
item.range = t.GetInt();
if(item.range < 1)
throw new Exception(string.Format("Item '{0}' have negative range {1}.", item.id, item.range));
break;
}
t.Next();
}
if (!have[(int)Keyword.Name])
throw new Exception(string.Format("Item '{0}' don't have name.", item.id));
if (!have[(int)Keyword.Desc])
throw new Exception(string.Format("Item '{0}' don't have description.", item.id));
if (!have[(int)Keyword.Weight])
throw new Exception(string.Format("Item '{0}' don't have weight.", item.id));
if (!have[(int)Keyword.Value])
throw new Exception(string.Format("Item '{0}' don't have value.", item.id));
if(item.type == Type.Weapon)
{
if (!have[(int)Keyword.Attack])
throw new Exception(string.Format("Item '{0}' don't have attack.", item.id));
if (!have[(int)Keyword.Subtype])
throw new Exception(string.Format("Item '{0}' don't have subtype.", item.id));
if (!have[(int)Keyword.Material])
throw new Exception(string.Format("Item '{0}' don't have material.", item.id));
}
else if(item.type == Type.Gun)
{
if (!have[(int)Keyword.Attack])
throw new Exception(string.Format("Item '{0}' don't have attack.", item.id));
if (!have[(int)Keyword.Subtype])
throw new Exception(string.Format("Item '{0}' don't have subtype.", item.id));
if (!have[(int)Keyword.Range])
throw new Exception(string.Format("Item '{0}' don't have range.", item.id));
if (!have[(int)Keyword.Capacity])
throw new Exception(string.Format("Item '{0}' don't have capacity.", item.id));
}
else if(item.type == Type.Armor)
{
if (!have[(int)Keyword.Defense])
throw new Exception(string.Format("Item '{0}' don't have defense.", item.id));
}
else if(item.type == Type.Ammo)
{
if (!have[(int)Keyword.Subtype])
throw new Exception(string.Format("Item '{0}' don't have subtype.", item.id));
}
items.Add(item);
}
catch(Exception e)
{
++errors;
Game.Instance.Log(e.ToString());
t.SkipTo(Tokenizer.Token.KeywordGroupType, typeof(Type), null);
goto retry;
}
}
}
catch(Exception e)
{
++errors;
Game.Instance.Log(string.Format("Failed to load items: {0}.", e.ToString()));
}
if (errors > 0)
throw new Exception("Failed to load items, check log for details.");
Game.Instance.Log("Finished loading items.");
}