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


C# Table.Add方法代码示例

本文整理汇总了C#中Table.Add方法的典型用法代码示例。如果您正苦于以下问题:C# Table.Add方法的具体用法?C# Table.Add怎么用?C# Table.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Table的用法示例。


在下文中一共展示了Table.Add方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AddNumKey

        public void AddNumKey()
        {
            var ta = new Table( 6, 0 );

            ta.Add( 1, Math.PI );
            Assert.AreEqual( Math.PI, ta[1] );
        }
开发者ID:henchmeninteractive,项目名称:HenchLua,代码行数:7,代码来源:TableTests.cs

示例2: Parse

		Table Parse()
		{
			Table table = new Table();
			string name = null;
			Dictionary<object, string> comments = new Dictionary<object,string>();

			while (true) {
				Token token = ReadToken();

				if (token.type == TokenType.Comment) {
					comments[new object()] = (string)token.value;
					continue;
				}

				if (token.type == TokenType.CloseParen || 
				    token.type == TokenType.Ident || 
				    token.type == TokenType.Comma)
				{
					if (name != null)
						throw new InternalParseException(String.Format("Expecting value after '{0} ='", name));
				}
				
				if (token.type == TokenType.CloseParen || token.type == TokenType.EOF)
					break;
				
				if (token.type == TokenType.Ident) {
					name = (string)token.value;
					if (ReadToken().type != TokenType.Equals)
						throw new InternalParseException("Expecting '=' after '" + name + "'");
					continue;
				} 
				if (token.type == TokenType.Equals)
					throw new InternalParseException("Unexpected = token");
				
				object value = null;
				switch (token.type) {
					case TokenType.OpenParen:
						value = Parse();
						break;
					case TokenType.Int:
					case TokenType.Float:
					case TokenType.String:
						value = token.value;
						break;
				}
				if (value != null) {
					name = table.Add(value, name);
					if (comments.Count>0) {
						string comment = "";
						foreach (var kv in comments)
							 comment += kv.Value + "\n";
						table.Comments[table[name]] = comment;
						comments.Clear();
					}
					name = null;
				}
			}
			return table;
		}
开发者ID:jcnossen,项目名称:upspring.net,代码行数:59,代码来源:LuaTableParser.cs

示例3: TryFillFromExpandable

        private static void TryFillFromExpandable(Table t, decimal index, object o)
        {
            var rl = o as IExpandable;

            if (rl == null)
                t.Add(index, o);
            else
            {
                var list = rl.ToList();

                foreach (var i in list)
                {
                    t.Add(index, i);
                    index++;
                }
            }
        }
开发者ID:jeffpanici75,项目名称:Tsuki,代码行数:17,代码来源:TableDef.cs

示例4: PickSkill

        static void PickSkill(Character result, Dice dice, string attributeFilter = null)
        {
            bool allowHigh = result.UnusedSkills >= 2 && result.UnusedAttributes == 0; //don't buy expensive skills until all of the attributes are picked

            var table = new Table<Skill>();
            foreach (var item in result.Skills.Where(s => attributeFilter == null || s.Attribute == attributeFilter))
            {

                if (item.Trait == 0)
                    table.Add(item, result.GetAttribute(item.Attribute).Score - 3); //favor skills that match your attributes
                else if (item.Trait < result.GetAttribute(item.Attribute)) //favor improving what you know
                    table.Add(item, result.GetAttribute(item.Attribute).Score - 3 + item.Trait.Score);
                else if (allowHigh && item.Trait < 12)
                    table.Add(item, item.Trait.Score); //Raising skills above the controlling attribute is relatively rare
            }
            var skill = table.RandomChoose(dice);
            if (skill.Trait == 0)
            {
                result.UnusedSkills -= 1;
                skill.Trait = 4;
            }
            else if (skill.Trait < result.GetAttribute(skill.Attribute))
            {
                result.UnusedSkills -= 1;
                skill.Trait += 1;
            }
            else
            {
                result.UnusedSkills -= 2;
                skill.Trait += 1;
            }
        }
开发者ID:Grauenwolf,项目名称:SavageTools,代码行数:32,代码来源:CharacterGenerator.cs

示例5: PickAttribute

        static void PickAttribute(Character result, Dice dice)
        {
            //Attributes are likely to stack rather than spread evenly
            var table = new Table<string>();
            if (result.Vigor < 12)
                table.Add("Vigor", result.Vigor.Score);
            if (result.Smarts < 12)
                table.Add("Smarts", result.Smarts.Score);
            if (result.Agility < 12)
                table.Add("Agility", result.Agility.Score);
            if (result.Strength < 12)
                table.Add("Strength", result.Strength.Score);
            if (result.Spirit < 12)
                table.Add("Spirit", result.Spirit.Score);

            result.Increment(table.RandomChoose(dice));

            result.UnusedAttributes -= 1;
        }
开发者ID:Grauenwolf,项目名称:SavageTools,代码行数:19,代码来源:CharacterGenerator.cs

示例6: PickAdvancement

        static void PickAdvancement(Character result, Dice dice)
        {
            result.UnusedAdvances -= 1;

            if (result.UnusedEdges < 0)
                result.UnusedEdges += 1;
            else if (result.UnusedSkills < 0)
                result.UnusedSkills += 2; //pay back the skill point loan
            else if (result.UnusedSmartSkills < 0)
                result.UnusedSmartSkills += 2; //pay back the skill point loan
            else

            {
                switch (dice.Next(5))
                {
                    case 0:
                        result.UnusedEdges += 1;
                        break;
                    case 1: //increase a high skill

                        {
                            var table = new Table<Skill>();
                            foreach (var skill in result.Skills)
                            {
                                if (skill.Trait >= result.GetAttribute(skill.Attribute) && skill.Trait < 12)
                                    table.Add(skill, skill.Trait.Score);
                            }
                            if (table.Count == 0)
                                goto case 2;
                            table.RandomChoose(dice).Trait += 1;
                            break;
                        }
                    case 2: //increase a low skill

                        {
                            var table = new Table<Skill>();
                            foreach (var skill in result.Skills)
                            {
                                if (skill.Trait < result.GetAttribute(skill.Attribute) && skill.Trait < 12)
                                    table.Add(skill, skill.Trait.Score);
                            }
                            if (table.Count >= 2)
                                goto case 3;
                            table.RandomPick(dice).Trait += 1;
                            table.RandomPick(dice).Trait += 1; //use Pick so we get 2 different skills
                            break;
                        }
                    case 3: //add a new skill

                        {
                            var table = new Table<Skill>();
                            foreach (var skill in result.Skills)
                            {
                                if (skill.Trait == 0)
                                    table.Add(skill, result.GetAttribute(skill.Attribute).Score);
                            }
                            if (table.Count == 0)
                                break; //really?
                            table.RandomChoose(dice).Trait = 4;
                            break;
                        }
                    case 4:
                        result.UnusedAttributes += 1;
                        break;
                }
            }
        }
开发者ID:Grauenwolf,项目名称:SavageTools,代码行数:67,代码来源:CharacterGenerator.cs


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