本文整理汇总了C#中Party.addMember方法的典型用法代码示例。如果您正苦于以下问题:C# Party.addMember方法的具体用法?C# Party.addMember怎么用?C# Party.addMember使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Party
的用法示例。
在下文中一共展示了Party.addMember方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: fight
static bool fight(Party p1, Party p2)
{
int averageLevel = 0;
foreach (IEngageable member in p1)
{
averageLevel += member.getLevel();
}
averageLevel /= p1.Count;
for (int i = 0; i < 3; i++)
{
switch (RandomPlus.genIntInc(5))
{
case 0: p2.addMember(new Swordsman(averageLevel)); break;
case 1: p2.addMember(new Assassin(averageLevel)); break;
case 2: p2.addMember(new Tank(averageLevel)); break;
case 3: p2.addMember(new Tank(averageLevel)); break;
case 4: p2.addMember(new Assassin(averageLevel)); break;
case 5: p2.addMember(new Swordsman(averageLevel)); break;
}
}
p2.addMember(new Cleric(averageLevel));
Battle.engage(p1, p2);
Console.WriteLine("-----------");
if (!p1.isDefeated())
{
Text.color("You win!\n", ConsoleColor.Cyan);
return true;
}
else
{
Text.color("You lose...\n", ConsoleColor.Red);
return false;
}
}
示例2: initPlayerParty
static Party initPlayerParty()
{
Party p1 = new Party(true);
List<IEngageable> draft = new List<IEngageable>();
Console.WriteLine("Select 4 Fighters for your party: \n");
for (int members = 0; members < 10; members++)
{
switch (RandomPlus.genIntInc(5))
{
case 0: draft.Add(new Swordsman()); break;
case 1: draft.Add(new Assassin()); break;
case 2: draft.Add(new Tank()); break;
case 3: draft.Add(new Cleric()); break;
case 4: draft.Add(new Swordsman()); break;
case 5: draft.Add(new Cleric()); break;
}
Console.WriteLine((members + 1) + ". \n" + draft[members].getStats());
}
for (int i = 0; i < 4; ++i)
{
int index = -1;
string input;
do
{
Console.WriteLine("Character {0}'s index:", (i + 1));
input = Console.ReadLine();
try
{
index = int.Parse(input) - 1;
}
catch (Exception e)
{
index = -1;
}
if (index >= 0 && index < draft.Count)
{
if (draft.ElementAt(index) == null)
{
Text.color("You've already selected that character.\n\n", ConsoleColor.Red);
}
}
else
{
Text.color("Really? '" + input + "'? Hahahahha! -_-' That wasn't funny.\n\n", ConsoleColor.Red);
index = -1;
}
}
while (index == -1 || draft.ElementAt(index) == null);
p1.addMember(draft.ElementAt(index));
draft[index] = null;
Console.WriteLine();
}
return p1;
}