コード例 #1
0
        /// <summary>
        /// Start a new match.
        /// (This method is working on another thread.)
        /// </summary>
        private void StartNewMatch(object o)
        {
            Interlocked.Exchange(ref this._isEndStart, 0);
            MatchInput matchIn = null;

            if (hmid == Guid.Empty && amid == Guid.Empty)
            {
                double time;
                if (!double.TryParse(o.ToString(), out time))
                {
                    time = 120;
                }
                matchIn = DataMgr.CreateDebugMatch((int)time);
            }
            else
            {
                matchIn = LocalHelper.GetLocalMatchInput(hmid, homeIsNpc, amid, awayIsNpc, _time);
            }
            if (matchIn == null)
            {
                MessageBox.Show("创建比赛失败,创建MatchInput失败,请检查输入账号.");
                return;
            }
            IMatch match = new MatchEntity(matchIn, StatisticsAddProcess);

            if (_openStatistics)
            {
                _statisticsMatch = new StatisticsMatchEntity(match);
            }
            using (var watch = new Games.NB.Match.Log.LogWatch())
            {
                EmulatorHelper.CreateMatch(match, _statisticsMatch);
                watch.LogCostTime(string.Format("Guid:{0}[{1}] vs Guid:{2}[{3}]. Result {4}:{5})",
                                                match.Input.HomeManager.Mid, match.Input.HomeManager.Name,
                                                match.Input.AwayManager.Mid, match.Input.AwayManager.Name,
                                                match.HomeScore, match.AwayScore));
                var bytes = IOUtil.BinWrite(match.Report, ReportAsset.RPTVerNo);
                watch.LogCostTime("BinWrite");
                _match = IOUtil.BinRead <MatchReport>(bytes, 0);
                watch.LogCostTime("BinRead");
            }
            if (_match == null)
            {
                MessageBox.Show("创建比赛失败");
                return;
            }
            else
            {
                MessageBox.Show("创建比赛成功");
            }
            DataMgr.FillFormData(_match);
            DataMgr.FillRoundData(_match);
            try
            {
                //_match = MatchFacade.CreateMatch(DataMgr.CreateDebugMatch((int)time * 60, 335, 300)).Report;
                this._maxRound = GetMaxRound();
                Interlocked.Exchange(ref this._isEndStart, 1);
                _loadingTimer.Start();
                _waitTimer.Start();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + ":\n" + ex.StackTrace, "系统错误");
            }
        }