本文整理汇总了C#中Team.AddPlayer方法的典型用法代码示例。如果您正苦于以下问题:C# Team.AddPlayer方法的具体用法?C# Team.AddPlayer怎么用?C# Team.AddPlayer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Team
的用法示例。
在下文中一共展示了Team.AddPlayer方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CalculateNewRatings
public void CalculateNewRatings(string type, Match match)
{
Team awayTeam = new Team();
Team homeTeam = new Team();
GameInfo gameInfo = GameInfo.DefaultGameInfo;
gameInfo.DrawProbability = 0;
foreach (DartsPlayer x in AwayDartsPlayers)
{
switch (type)
{
case "player":
awayTeam.AddPlayer(x, x._Rating);
break;
case "class":
awayTeam.AddPlayer(x, x.ClassRatings[Convert.ToInt32(match._Campaign._Class)]);
break;
case "campaign":
awayTeam.AddPlayer(x, x.CampaignRatings[Convert.ToInt32(match._Campaign.ID)]);
break;
}
}
foreach (DartsPlayer x in HomeDartsPlayers)
{
switch (type)
{
case "player":
homeTeam.AddPlayer(x, x._Rating);
break;
case "class":
homeTeam.AddPlayer(x, x.ClassRatings[Convert.ToInt32(match._Campaign._Class)]);
break;
case "campaign":
homeTeam.AddPlayer(x, x.CampaignRatings[Convert.ToInt32(match._Campaign.ID)]);
break;
}
}
if (AwayDartsPlayers.Count == 0 && HomeDartsPlayers.Count == 0)
return;
if (AwayDartsPlayers.Count != HomeDartsPlayers.Count)
return;
var teams = Teams.Concat(awayTeam, homeTeam);
IDictionary<Player, Rating> newRatings;
if (IsHomeWin)
newRatings = TrueSkillCalculator.CalculateNewRatings(gameInfo, teams, 2, 1);
else // IsAwayWin
newRatings = TrueSkillCalculator.CalculateNewRatings(gameInfo, teams, 1, 2);
foreach (DartsPlayer x in AwayDartsPlayers.Concat(HomeDartsPlayers))
{
switch (type)
{
case "player":
x._Rating = newRatings[x];
break;
case "class":
x.ClassRatings[Convert.ToInt32(match._Campaign._Class)] = newRatings[x];
break;
case "campaign":
x.CampaignRatings[Convert.ToInt32(match._Campaign.ID)] = newRatings[x];
break;
}
CommitGame(x, match, type);
}
}
示例2: LoadGame
public void LoadGame()
{
FileStream fs = null;
BinaryReader br = null;
try {
fs = new FileStream("save.dat", FileMode.Open);
br = new BinaryReader(fs);
Team[] teams = new Team[br.ReadInt32()];
for (int i = 0; i < teams.Length; i++) {
Team team = new Team(br.ReadString());
int players = br.ReadInt32();
for (int j = 0; j < players; j++) {
Player player = new Player(br.ReadString());
player.Correct = br.ReadInt32();
player.Pass = br.ReadInt32();
player.Foul = br.ReadInt32();
player.Turns = br.ReadInt32();
team.AddPlayer(player);
}
team.PlayerGoIndex = br.ReadInt32();
teams[i] = team;
}
mTeams = teams;
mRoundDuration = br.ReadInt32();
mMaximumPasses = br.ReadInt32();
mCategories = new string[br.ReadInt32()];
for (int i = 0; i < mCategories.Length; i++)
mCategories[i] = br.ReadString();
mPlayedRounds = br.ReadInt32();
mCurrentTeamGo = br.ReadInt32();
InitialiseBags();
} finally {
if (br != null)
br.Close();
if (fs != null)
fs.Close();
}
}
示例3: GetTeams
private Team[] GetTeams()
{
List<Team> teams = new List<Team>();
foreach (TreeNode node in trvTeams.Nodes) {
Team team = new Team(node.Text);
foreach (TreeNode player in node.Nodes)
team.AddPlayer(player.Text);
teams.Add(team);
}
return teams.ToArray();
}