コード例 #1
0
        private void FormPrelimRaceCommand_Load(object sender, EventArgs e)
        {
            // NOTE: The first heat was already loaded by the Prelim Race Form

            // Get the next race
            _activeRace = RaceDataStore.RaceProc.GetNextTournamentRace();

            // Hook into the race complete event
            RaceDataStore.RaceProc.OnRaceComplete += new RaceProcessor.OnRaceCompleteHandler(RaceProc_OnRaceComplete);
            this.LoadRacerData();
        }
コード例 #2
0
        public bool AdvanceWinner(TournamentRace activeRace)
        {
            bool moreRaces = true;

            string winnerKey = activeRace.WinnerKey;

            Sweet16Racer winningRacer = activeRace.Racer1.IsEliminated == false ? activeRace.Racer1 : activeRace.Racer2;

            if (winnerKey == string.Empty)
            {
                System.Windows.Forms.MessageBox.Show(winningRacer.Racer.GetScoreboardDisplay(), "We have a winner!");

                moreRaces = false;

                return moreRaces;
            }

            // Get a reference to the tournament race mathing the
            // winnners key
            TournamentRace race = RaceDataStore.TournamentRaces[winnerKey];

            // Is racer1 empty?
            if (race.Racer1 == null)
            {
                race.Racer1 = winningRacer;
            }
            else
            {
                race.Racer2 = winningRacer;
            }

            if (race.Racer1 != null && race.Racer2 != null)
            {
                RaceDataStore.RaceKeyQueue.Enqueue(winnerKey);
            }

            return moreRaces;
        }
コード例 #3
0
        private void LoadTournamentBrackets()
        {
            XmlDocument raceTemplateXml = this.LoadTournamentTemplate();

            // Iterate over the brackets and build tournement objects
            XmlNodeList bracketList = raceTemplateXml.SelectNodes("/tournamentTemplate/raceTemplate/race");

            foreach (XmlNode raceNode in bracketList)
            {
                TournamentRace tournamentRace = new TournamentRace(raceNode.Attributes["winnerKey"].Value.ToString());

                string key = raceNode.Attributes["key"].Value.ToString();

                RaceDataStore.TournamentRaces.Add(key, tournamentRace);
            }

            this.LoadRacersInTournametBracket(raceTemplateXml);
        }
コード例 #4
0
        public void RunTournamentRace(TournamentRace activeRace)
        {
            // Store a reference to the tournament race
            _activeTournamentRace = activeRace;

            // Make sure the active race object is null
            _activeRace = null;

            // Play our Rev Start wave
            _wavePlayer.SoundLocation = "StartRev.wav";
            _wavePlayer.PlaySync();

            if (RaceDataStore.EmulateRace)
            {
                Random randomTimeGenerator = new Random();

                double time1 = randomTimeGenerator.NextDouble();
                double time2 = randomTimeGenerator.NextDouble();

                time1 += randomTimeGenerator.Next(3, 6);
                time2 += randomTimeGenerator.Next(3, 6);

                activeRace.Racer1.RaceTime = time1;
                activeRace.Racer2.RaceTime = time2;

                if (time1 < time2)
                {
                    activeRace.Racer1.RecordRaceResult(true);
                    activeRace.Racer2.RecordRaceResult(false);
                }
                else
                {
                    activeRace.Racer1.RecordRaceResult(false);
                    activeRace.Racer2.RecordRaceResult(true);
                }

                this.OnRaceComplete();

                //// Advance the winner to the next round
                //this.AdvanceWinner(activeRace);
            }
            else
            {
                _trackCommunication.StartRace();
            }

            // Play the tire wave
            _wavePlayer.SoundLocation = "EndRev.wav";
            _wavePlayer.PlaySync();
        }
コード例 #5
0
        public void RunRace(Race activeRace)
        {
            // Play our Rev Start wave
            _wavePlayer.SoundLocation = "StartRev.wav";
            _wavePlayer.PlaySync();

            // Are we in emulate mode?
            if (RaceDataStore.EmulateRace)
            {
                RunEmulatedRace(activeRace);
            }
            else
            {
                // Store a reference to the active Race
                _activeRace = activeRace;

                // Make sure the tournament race object is null
                _activeTournamentRace = null;

                _trackCommunication.StartRace();
            }

            _wavePlayer.SoundLocation = "EndRev.wav";
            _wavePlayer.PlaySync();
        }
コード例 #6
0
        private void toolStripButtonNextRace_Click(object sender, EventArgs e)
        {
            //TODO: Close race

            // Is the current race completed?
            if (this.IsRaceRecorded().Equals(false))
            {
                // Tell the user we can't continue
                MessageBox.Show(this,"Active race has not been completed.","Are you sure", MessageBoxButtons.OK, MessageBoxIcon.Warning);

                return;
            }

            try
            {
                // Advance the winner to the next round
                if (RaceDataStore.RaceProc.AdvanceWinner(_activeRace))
                {

                    // Get the next race
                    _activeRace = RaceDataStore.RaceProc.GetNextTournamentRace();

                    this.LoadRacerData();
                }
            }
            catch (NoMoreRacersException)
            {
                // Mark our heat as complete and increment the
                // heat number
                RaceDataStore.PrelimHeatCompleted = false;
                RaceDataStore.PrelimHeatNumber++;

                // Are we done with the prelims?
                if (RaceDataStore.PrelimHeatNumber > 4)
                {
                    if (OnPrelimCompleteEvent != null)
                    {
                        OnPrelimCompleteEvent();
                    }

                    MessageBox.Show("The prelims have completed. Stay tuned for the posting of the Sweet 16 Racers.");

                    this.Close();
                }
                else
                {
                    this.toolStripLabelHeat.Text = String.Concat("Heat ", RaceDataStore.PrelimHeatNumber);

                    this.ClearAllTextBoxes(this);

                    RaceDataStore.RaceProc.LoadNextHeat();

                    // Get the next race
                    //_activeRace = RaceDataStore.RaceProc.GetNextRace();

                    this.LoadRacerData();
                }
            }
        }