本文整理汇总了C#中PlayerSquad.addPlayer方法的典型用法代码示例。如果您正苦于以下问题:C# PlayerSquad.addPlayer方法的具体用法?C# PlayerSquad.addPlayer怎么用?C# PlayerSquad.addPlayer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PlayerSquad
的用法示例。
在下文中一共展示了PlayerSquad.addPlayer方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: balanceTeams
//.........这里部分代码省略.........
nosquad_pool.Sort(new Comparison<PlayerProfile>(getPlayerSort("live_sort")));
for (int i = 0; i < nosquad_pool.Count; i++)
DebugWrite(" " + i + ". " + nosquad_pool[i] + "(" + getSortFieldValueStr(nosquad_pool[i], "live_sort") + ")", 3);
DebugWrite("Moving ^b" + needed + "^n players from sorted no-squad pool to ^bTeam(" + TN(smaller_team) + ")^n^0", 3);
while (needed > 0 && nosquad_pool.Count > 0) {
PlayerProfile player = nosquad_pool[0];
nosquad_pool.RemoveAt(0);
string tag = player.getClanTag();
/* if keeping clans together, and there are more than two players in the clan in the sever */
if (keep_clans && shouldSkipClanPlayer(player, smaller_team, bigger_team, clan_stats))
continue;
DebugWrite("Moving ^b" + player.ToString() + "^n to ^bTeam(^n" + TN(smaller_team) + ")^n^0", 3);
if (movePlayer(player, smaller_team, 0, true))
needed--;
}
/* if teams are balanced, we are done */
if (needed == 0) {
DebugWrite("Teams should now be balanced!", 3);
return needed;
}
/* teams are not balanced, proceed on squad balancing */
DebugWrite("Teams are still unbalanced, " + needed + " more player/s needed", 3);
/* sort the squad pool */
DebugWrite("Sorting the squad pool by ^b" + getStringVarValue("live_sort") + "^n^0", 3);
squad_pool.Sort(new Comparison<PlayerSquad>(getSquadSort("live_sort")));
for (int i = 0; i < squad_pool.Count; i++) {
DebugWrite(" " + i + ". " + squad_pool[i].ToString() + "(" + getSortFieldValueStr(squad_pool[i], "live_sort") + ")", 3);
}
DebugWrite("Moving squads from sorted squad pool to ^bTeam(" + TN(smaller_team) + ")^n^0", 3);
while (needed > 0 && squad_pool.Count > 0) {
PlayerSquad squad = squad_pool[0];
squad_pool.RemoveAt(0);
int squad_sz = squad.getCount();
string squad_uid = squad.ToString();
string smaller_team_uid = "^bTeam(" + TN(smaller_team) + ")^n";
DebugWrite("^b" + needed + "^n players are needed on " + smaller_team_uid + "^0", 3);
DebugWrite(squad_uid + " has ^b" + squad_sz + "^n player/s^0", 2);
if (needed >= squad_sz) {
if (keep_clans && shouldSkipClanSquad(squad, smaller_team, bigger_team, clan_stats))
continue;
/* we can move the entrie squad */
DebugWrite("Moving entire " + squad_uid + " to " + smaller_team_uid + "^0", 3);
squad_sz = moveSquad(squad, smaller_team, team_sz);
needed -= squad_sz;
} else {
/* we have to break up a squad */
PlayerSquad temp_squad = new PlayerSquad(squad.getTeamId(), squad.getSquadId());
DebugWrite("Breaking up " + squad_uid + " to get ^b" + needed + "^n player/s^0", 3);
DebugWrite("But, first I will sort the members of " + squad_uid, 3);
squad.sortMembers(getPlayerSort("live_sort"));
for (int i = 0; i < squad.getCount(); i++)
DebugWrite(" " + i + ". " + squad.getMembers()[i] + "(" + getSortFieldValueStr(squad.getMembers()[i], "live_sort") + ")", 3);
/* get as many players as needed */
while (needed > 0 && squad.getCount() > 0) {
PlayerProfile player = squad.getMembers()[0];
squad.dropPlayer(player);
if (keep_clans && shouldSkipClanPlayer(player, smaller_team, bigger_team, clan_stats))
continue;
if (isInMoveWhiteList(player))
continue;
temp_squad.addPlayer(player);
DebugWrite("Player " + player + " selected to move to " + smaller_team_uid + "^0", 3);
needed--;
}
/* move the temporary squad */
moveSquad(temp_squad, smaller_team, team_sz);
}
}
if (needed == 0)
DebugWrite("Teams should now be balanced!", 3);
else
DebugWrite("Teams are still ubalanced!", 3);
return needed;
}