当前位置: 首页>>代码示例>>C#>>正文


C# Tokenizer.SkipTo方法代码示例

本文整理汇总了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.");
        }
开发者ID:Tomash667,项目名称:hunters,代码行数:101,代码来源:Item.cs


注:本文中的Tokenizer.SkipTo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。