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


C# Team.AddPlayer方法代码示例

本文整理汇总了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);
            }
        }
开发者ID:Rocci1212,项目名称:DartsRatingCalculator,代码行数:70,代码来源:Game.cs

示例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();
            }
        }
开发者ID:IntelOrca,项目名称:whos-in-the-computer,代码行数:42,代码来源:Game.cs

示例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();
 }
开发者ID:IntelOrca,项目名称:whos-in-the-computer,代码行数:11,代码来源:PlayerSetupForm.cs


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