本文整理汇总了C#中PlayerSquad类的典型用法代码示例。如果您正苦于以下问题:C# PlayerSquad类的具体用法?C# PlayerSquad怎么用?C# PlayerSquad使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PlayerSquad类属于命名空间,在下文中一共展示了PlayerSquad类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: getSquads
private Dictionary<int, PlayerSquad> getSquads(int teamId) {
int num_squads = 8;
if (teamId == 0)
num_squads = 16;
List<PlayerProfile> player_list = getPlayersProfile("");
Dictionary<int, PlayerSquad> squads = new Dictionary<int, PlayerSquad>();
for (int i = 0; i <= num_squads; i++)
squads[i] = new PlayerSquad(teamId, i);
foreach (PlayerProfile player in player_list) {
if (player.getTeamId() == teamId && squads.ContainsKey(player.getSquadId()))
squads[player.getSquadId()].addPlayer(player);
}
return squads;
}
示例2: moveSquad
/* best effort to move an entire squad into another team withouth breaking up */
private int moveSquad(PlayerSquad squad, int teamId, int team_sz) {
int players_moved = 0;
if (squad == null)
return 0;
/* first move all players to the opposite team without squad (to guarantee a spot)*/
int squadId = 0;
int noSquadId = 0;
List<PlayerProfile> squad_players = squad.getMembers();
/* find a squad on teamId with enough space */
List<PlayerSquad> squads = getAllSquads(teamId);
/* find first empty squad */
foreach (PlayerSquad sq in squads) {
if (sq.getCount() == 0) {
DebugWrite("Found empty squad " + sq + ", for " + squad, 3);
while (squad.getCount() > 0) {
PlayerProfile pp = squad.removeRandomPlayer();
DebugWrite("Moving ^b" + pp + "^n to Team(" + TN(teamId) + ").Squad(" + SQN(sq.getSquadId()) + ")", 3);
if (movePlayer(pp, teamId, sq.getSquadId()))
players_moved++;
}
break;
}
}
if (squad.getCount() == 0)
return players_moved;
DebugWrite("^1^bWARNING^0^n: Could not find an empty squad on ^bTeam(" + TN(teamId) + ")^n for " + squad.ToString(), 1);
DebugWrite("Looking now for squads that are not full^n", 1);
/* sort the squads in increasing order of player count */
squads.Sort(new Comparison<PlayerSquad>(squad_count_asc_cmp));
for (int i = 0; i < squads.Count; i++) {
PlayerSquad sorted_squad = squads[i];
if (sorted_squad.getSquadId() > 8)
continue;
if (sorted_squad.getFreeSlots() > 0 && squad_players.Count > 0)
DebugWrite("Found " + sorted_squad.getFreeSlots() + " free slots on " + sorted_squad, 3);
while (sorted_squad.getFreeSlots() > 0 && squad_players.Count > 0) {
PlayerProfile squad_player = squad_players[0];
squad_players.RemoveAt(0);
DebugWrite("Moving ^b" + squad_player + "^n to Team(" + TN(teamId) + ").Squad(" + SQN(sorted_squad.getSquadId()) + ")", 3);
if (movePlayer(squad_player, teamId, sorted_squad.getSquadId()))
players_moved++;
}
}
foreach (PlayerProfile pp in squad_players) {
DebugWrite("^1^bWARNING^0^n: could not find squad on ^bTeam(" + TN(teamId) + ")^n for ^b" + pp + "^n^0", 1);
DebugWrite("Moving ^b" + pp + "^n to Team(" + TN(teamId) + ").Squad(" + SQN(noSquadId) + ")", 3);
if (movePlayer(pp, teamId, noSquadId))
players_moved++;
}
return players_moved;
}
示例3: listSquad
private void listSquad(PlayerSquad sq) {
List<PlayerProfile> members = sq.getMembers();
DebugWrite("Team(^b" + TN(sq.getTeamId()) + "^n).Squad(^b" + SQN(sq.getSquadId()) + "^n): " + sq.getCount() + " players", 3);
int count = 1;
foreach (PlayerProfile pp in members)
DebugWrite(" " + count++ + ". ^b" + pp + "^n", 3);
}
示例4: shouldSkipClanSquad
private bool shouldSkipClanSquad(PlayerSquad squad, int smaller_team, int bigger_team, Dictionary<string, int>[] clan_stats) {
int squad_sz = squad.getCount();
string tag = squad.getMajorityClanTag();
if (tag.Length > 0 && (clan_stats[bigger_team][tag] + clan_stats[smaller_team][tag]) > 1) {
if (clan_stats[bigger_team][tag] >= clan_stats[smaller_team][tag]) {
DebugWrite("Skipping clan-squad " + squad.ToString() + " because majority of clan is in same team", 3);
return true;
}
/* update clan stats */
clan_stats[bigger_team][tag] -= squad_sz;
clan_stats[smaller_team][tag] += squad_sz;
}
return false;
}
示例5: getSortFieldValueStr
private string getSortFieldValueStr(PlayerSquad squad, string phase) {
string sort_method = getStringVarValue(phase);
if (sort_method.CompareTo("kdr_asc_round") == 0 || sort_method.CompareTo("kdr_desc_round") == 0)
return "kdr_round: " + Math.Round(squad.getRoundKdr(), 2);
else if (sort_method.CompareTo("score_asc_round") == 0 || sort_method.CompareTo("score_desc_round") == 0)
return "score_round: " + Math.Round(squad.getRoundScore(), 2);
else if (sort_method.CompareTo("spm_asc_round") == 0 || sort_method.CompareTo("spm_desc_round") == 0)
return "spm_round: " + Math.Round(squad.getRoundSpm(), 2);
else if (sort_method.CompareTo("kpm_asc_round") == 0 || sort_method.CompareTo("kpm_desc_round") == 0)
return "kpm_round: " + Math.Round(squad.getRoundKpm(), 2);
else if (sort_method.CompareTo("time_asc_round") == 0 || sort_method.CompareTo("time_desc_round") == 0)
return "time_round: " + squad.getRoundTime();
else if (sort_method.CompareTo("random_value") == 0 || sort_method.CompareTo("random_value") == 0)
return "random_value: " + squad.getRandomValue();
else if (sort_method.CompareTo("kdr_asc_online") == 0 || sort_method.CompareTo("kdr_desc_online") == 0)
return "kdr_online: " + Math.Round(squad.getOnlineKdr(), 2);
else if (sort_method.CompareTo("kpm_asc_online") == 0 || sort_method.CompareTo("kpm_desc_online") == 0)
return "kpm_online: " + Math.Round(squad.getOnlineKpm(), 2);
else if (sort_method.CompareTo("spm_asc_online") == 0 || sort_method.CompareTo("spm_desc_online") == 0)
return "spm_online: " + Math.Round(squad.getOnlineSpm(), 2);
else if (sort_method.CompareTo("kills_asc_online") == 0 || sort_method.CompareTo("kills_desc_online") == 0)
return "kills_online: " + Math.Round(squad.getOnlineKills(), 2);
else if (sort_method.CompareTo("deaths_asc_online") == 0 || sort_method.CompareTo("deaths_desc_online") == 0)
return "deaths_online: " + Math.Round(squad.getOnlineDeaths(), 2);
else if (sort_method.CompareTo("skill_asc_online") == 0 || sort_method.CompareTo("skill_desc_online") == 0)
return "skill_online: " + Math.Round(squad.getOnlineSkill(), 2);
else if (sort_method.CompareTo("quits_asc_online") == 0 || sort_method.CompareTo("quits_desc_online") == 0)
return "quits_online: " + Math.Round(squad.getOnlineQuits(), 2);
else if (sort_method.CompareTo("accuracy_asc_online") == 0 || sort_method.CompareTo("accuracy_desc_online") == 0)
return "accuracy_online: " + Math.Round(squad.getOnlineAccuracy(), 2);
else if (sort_method.CompareTo("score_asc_online") == 0 || sort_method.CompareTo("score_desc_online") == 0)
return "score_online: " + Math.Round(squad.getOnlineScore(), 2);
else if (sort_method.CompareTo("rank_asc_online") == 0 || sort_method.CompareTo("rank_desc_online") == 0)
return "rank_online: " + Math.Round(squad.getOnlineRank(), 2);
DebugWrite("^1^bWARNING^0^n: cannot find squad sort method for ^b" + sort_method + "^0", 1);
return "";
}
示例6: mergeSquadWithPool
private int mergeSquadWithPool(PlayerSquad squad, List<PlayerSquad> squads) {
int players_moved = 0;
if (squad == null)
return 0;
int squad_max_sz = 4;
List<PlayerProfile> squad_players = squad.getMembers();
/* sort the squads in increasing order of player count */
squads.Sort(new Comparison<PlayerSquad>(squad_count_asc_cmp));
for (int i = 0; i < squads.Count; i++) {
PlayerSquad sorted_squad = squads[i];
if (squad.getTeamId() == sorted_squad.getTeamId() &&
squad.getSquadId() == sorted_squad.getSquadId())
continue;
while (sorted_squad.getFreeSlots() > 0 && squad_players.Count > 0) {
PlayerProfile squad_player = squad_players[0];
squad_players.RemoveAt(0);
if (movePlayer(squad_player, sorted_squad.getTeamId(), sorted_squad.getSquadId())) {
DebugWrite(squad_player + " moved to Team(" + TN(squad_player.getTeamId()) + ").Squad(" + SQN(squad_player.getSquadId()) + ")", 3);
sorted_squad.addPlayer(squad_player);
players_moved++;
}
}
}
return players_moved;
}
示例7: balanceTeams
private int balanceTeams(DateTime now) {
pluginState = PluginState.balance;
setStartTime(pluginState, now.AddSeconds(1));
DebugWrite("^b" + pluginState + "_live^n state started " + getStartTime(pluginState).ToString() + "^n^0", 1);
bool keep_clans = getBooleanVarValue("keep_clans_live");
Dictionary<int, int> player_count = getPlayerCount();
if (player_count[1] == player_count[2])
return 0;
int team_sz = serverInfo.MaxPlayerCount / 2;
int neutral_team = 0;
int bigger_team = (player_count[1] > player_count[2]) ? 1 : 2;
int smaller_team = (player_count[1] > player_count[2]) ? 2 : 1;
int total = player_count[1] + player_count[2];
int difference = Math.Abs(player_count[1] - player_count[2]);
int needed = difference / 2;
DebugWrite("Total of ^b" + total + "^n player/s in server^0", 3);
for (int i = 1; i < 3; i++) {
DebugWrite("^bTeam(" + TN(i) + ")^n has ^b" + player_count[i] + "^n player/s^0", 3);
}
DebugWrite("Teams differ by ^b" + difference + "^n player/s, ^b" + needed + "^n player/s are needed on ^bTeam(" + TN(smaller_team) + ")^n^0", 3);
int candidates = needed;
//?????? jstmx - Wrong logic, some fixes
if (getBooleanVarValue("wait_death")) {
candidates = getIntegerVarValue("wait_death_count");
int tsz = player_count[bigger_team];
// check that the candidate list does not exceed the team size
if (candidates > tsz) {
DebugWrite("cannot use candidate list size of ^b" + candidates + "^n, Team(" + TN(bigger_team) + ") has only ^b" + tsz + "^n player" + ((tsz > 1) ? "s" : ""), 3);
candidates = tsz;
}
// check that the candidates list size is bigger than needed
if (candidates > needed) {
needed = candidates;
DebugWrite("^bwait_death^n is on, will flag " + needed + " candidate" + ((needed > 1) ? "s" : "") + " for moving", 3);
}
}
//??????
DebugWrite("Building no-squad pool from ^bTeam(" + TN(bigger_team) + ")^n^0", 3);
List<PlayerProfile> nosquad_pool = getNoSquadPlayers(bigger_team);
DebugWrite("No-squad pool has ^b" + nosquad_pool.Count + "^n player/s^0", 3);
DebugWrite("Building squad pool from ^bTeam(" + TN(bigger_team) + ")^n^0", 3);
List<PlayerSquad> squad_pool = getNonEmptySquads(bigger_team);
DebugWrite("Squad pool has ^b" + squad_pool.Count + "^n squads^0", 3);
Dictionary<string, int>[] clan_stats = new Dictionary<string, int>[3];
clan_stats[smaller_team] = new Dictionary<string, int>();
clan_stats[bigger_team] = new Dictionary<string, int>();
clan_stats[neutral_team] = new Dictionary<string, int>();
if (keep_clans) {
DebugWrite("Keeping clans in same team", 3);
List<PlayerProfile> players_list = getPlayersProfile("");
/* collect statistics about clans */
DebugWrite("Collecting clan statistics", 3);
getClanStatsByTeam(players_list, clan_stats);
List<string> clanlist = new List<string>();
clanlist.AddRange(clan_stats[1].Keys);
DebugWrite("^b" + clanlist.Count + "^n clans in server: [^b" + String.Join("^n], [^b", clanlist.ToArray()) + "^n]", 3);
}
if (!getBooleanVarValue("keep_squads_live")) {
DebugWrite("^bkeep_squads_live^n is off, moving players to no-squad pool before balancing", 3);
foreach (PlayerSquad squad in squad_pool)
foreach (PlayerProfile player in squad.getMembers())
nosquad_pool.Add(player);
squad_pool.Clear();
}
/* sort the no-squad pool */
DebugWrite("Sorting the no-squad pool by ^b" + getStringVarValue("live_sort") + "^n^0", 3);
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];
//.........这里部分代码省略.........
示例8: squad_random_value_cmp
private int squad_random_value_cmp(PlayerSquad left, PlayerSquad right) {
int lval = left.getRandomValue();
int rval = right.getRandomValue();
return lval.CompareTo(rval);
}
示例9: PlayerSquad
public PlayerSquad(PlayerSquad squad) {
squadId = squad.squadId;
teamId = squad.squadId;
members = squad.members;
}
示例10: squad_rank_asc_online_cmp
private int squad_rank_asc_online_cmp(PlayerSquad left, PlayerSquad right) {
double lval = left.getOnlineRank();
double rval = right.getOnlineRank();
return lval.CompareTo(rval);
}
示例11: squad_rank_desc_online_cmp
private int squad_rank_desc_online_cmp(PlayerSquad left, PlayerSquad right) {
return squad_rank_asc_online_cmp(left, right) * (-1);
}
示例12: squad_time_desc_round_cmp
private int squad_time_desc_round_cmp(PlayerSquad left, PlayerSquad right) {
return squad_time_asc_round_cmp(left, right) * (-1);
}
示例13: squad_time_asc_round_cmp
private int squad_time_asc_round_cmp(PlayerSquad left, PlayerSquad right) {
DateTime lval = left.getRoundTime();
DateTime rval = right.getRoundTime();
return lval.CompareTo(rval);
}
示例14: squad_kpm_asc_round_cmp
private int squad_kpm_asc_round_cmp(PlayerSquad left, PlayerSquad right) {
double lval = left.getRoundKpm();
double rval = right.getRoundKpm();
return lval.CompareTo(rval);
}
示例15: squad_count_desc_cmp
private int squad_count_desc_cmp(PlayerSquad left, PlayerSquad right) {
return squad_count_asc_cmp(left, right) * (-1);
}