public NetworkParticipant[] GetParticipants(HelloPackage helloPackage) { var client = new ClientWithPackage(listener.AcceptTcpClient()); var client2 = new ClientWithPackage(listener.AcceptTcpClient()); CompetitionsBundle = GetCompetitionsBundle(helloPackage); return new[] { new NetworkParticipant(CompetitionsBundle.competitions, 0, client.Client), new NetworkParticipant(CompetitionsBundle.competitions, 1, client2.Client) }; }
private static void InitCompetition(HelloPackage helloPackage, string competitionsName) { var participantsServer = new ParticipantsServer(competitionsName); var participantsTask = Task.Factory.StartNew(() => participantsServer.GetParticipants(helloPackage)); RunClients("player2\\Client.exe", "player1\\Client.exe"); participants = participantsTask.Result; competitionsBundle = participantsServer.CompetitionsBundle; participantsServer.CompetitionsBundle.competitions.Initialize(new CVARCEngine(competitionsBundle.Rules), new[] { new RobotSettings(0, false), new RobotSettings(1, false) }); }
private static void InternalMain(HelloPackage helloPackage, string competitionsName) { try { InitCompetition(helloPackage, competitionsName); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); form = new TutorialForm(competitionsBundle.competitions); new Thread(() => competitionsBundle.competitions.ProcessParticipants(realTime, 60 * 1000, participants)) { IsBackground = true }.Start(); Application.Run(form); } catch (Exception e) { throw;//todo Убрать MessageBox.Show(e.Message, "CVARC Network", MessageBoxButtons.OK, MessageBoxIcon.Error); Environment.Exit(1); } }
private CompetitionsBundle GetCompetitionsBundle(HelloPackage helloPackage) { var competitionsBundle = CompetitionsBundle.Load(competitionsName, helloPackage.LevelName); competitionsBundle.competitions.HelloPackage = helloPackage; return competitionsBundle; }