コード例 #1
0
ファイル: Bracket.cs プロジェクト: 15831944/KR_MN_Acad
 /// <summary>
 /// Создание скобы по распределению
 /// </summary>
 /// <param name="d">Диаметр скобы</param>
 /// <param name="h">Длина нахлеста скобы - вылет (от внутренней грани стержня)</param>
 /// <param name="t">Ширина скобы (по внутренней грани стержня) - округляется до 5</param>
 /// <param name="step">Шаг скобы</param>
 /// <param name="width">Ширина распределения</param>
 /// <param name="pos">Позиция (из атрибута блока)</param>
 /// <param name="block">Блок</param>
 public Bracket(int d, int h, int t, int step, int width, int rows, string pos, ISpecBlock block, string friendlyName)
     : base(d, CalcLength(h, t, d), width, step, rows, PREFIX, pos, block, friendlyName)
 {
     T    = RoundHelper.Round5(t);
     L    = h;
     Key += "t" + T + "l" + L;
 }
コード例 #2
0
    public List <GameObject> GetNearByBuilding(Vector3 position, int scope)
    {
        List <GameObject> result = new List <GameObject>();
        int distanceSqrt         = scope * scope;

        TilePosition tilePosition = PositionConvertor.GetActorTileIndexFromWorldPosition(position);
        int          radius       = Mathf.CeilToInt(scope / (float)Mathf.Min(ClientSystemConstants.ACTOR_TILE_MAP_TILE_SIZE.width,
                                                                             ClientSystemConstants.ACTOR_TILE_MAP_TILE_SIZE.height));
        List <TilePosition> affectedTiles = RoundHelper.FillCircle(tilePosition.Column, tilePosition.Row, radius);

        foreach (TilePosition tile in affectedTiles)
        {
            if (tile.IsValidActorTilePosition())
            {
                Vector2 p   = (Vector2)PositionConvertor.GetWorldPositionFromActorTileIndex(tile);
                Vector2 dis = p - (Vector2)position;
                if (dis.sqrMagnitude <= distanceSqrt)
                {
                    GameObject building = BattleMapData.Instance.GetBulidingObjectFromActorObstacleMap(tile.Row, tile.Column);
                    if (building != null && !result.Contains(building) && building.GetComponent <BuildingHPBehavior>() != null)
                    {
                        result.Add(building);
                    }
                }
            }
        }
        return(result);
    }
コード例 #3
0
ファイル: Bar.cs プロジェクト: 15831944/KR_MN_Acad
 public void AddCount(int count)
 {
     Count += count;
     // Масса всех стержней
     WeightTotal = RoundHelper.Round2Digits(Weight * Count);
     Amount      = WeightTotal;
 }
コード例 #4
0
    public void activated()
    {
        // Destroy this dialog to close
        destroy();

        RoundHelper.MonsterActivated();
    }
コード例 #5
0
        public void OrderPlayersTest()
        {
            var players = PlayersSetup.BuildFourAIPlayers();

            var first  = players[0];
            var second = players[1];
            var third  = players[2];
            var fourth = players[3];

            var afterFirst = RoundHelper.OrderPlayersForNewTrick(players, first);
            var newOrder   = string.Join("|", afterFirst.Select(t => t.PlayerNumber));

            Assert.AreEqual("0|1|2|3", newOrder);

            var afterSecond = RoundHelper.OrderPlayersForNewTrick(players, second);

            newOrder = string.Join("|", afterSecond.Select(t => t.PlayerNumber));
            Assert.AreEqual("1|2|3|0", newOrder);

            var afterThird = RoundHelper.OrderPlayersForNewTrick(players, third);

            newOrder = string.Join("|", afterThird.Select(t => t.PlayerNumber));
            Assert.AreEqual("2|3|0|1", newOrder);

            var afterFourth = RoundHelper.OrderPlayersForNewTrick(players, fourth);

            newOrder = string.Join("|", afterFourth.Select(t => t.PlayerNumber));
            Assert.AreEqual("3|0|1|2", newOrder);
        }
コード例 #6
0
    private void Effect()
    {
        List <BuildingAI> affectedBuildings = new List <BuildingAI>();
        int distanceSqrt = this.Scope * this.Scope;

        Vector2      targetPosition = (Vector2)this.transform.position;
        TilePosition targetTile     = PositionConvertor.GetActorTileIndexFromWorldPosition(this.transform.position);
        int          radius         = Mathf.CeilToInt(this.Scope / (float)Mathf.Min(ClientSystemConstants.ACTOR_TILE_MAP_TILE_SIZE.width,
                                                                                    ClientSystemConstants.ACTOR_TILE_MAP_TILE_SIZE.height));

        List <TilePosition> affectedTiles = RoundHelper.FillCircle(targetTile.Column, targetTile.Row, radius);

        foreach (TilePosition tile in affectedTiles)
        {
            if (tile.IsValidActorTilePosition())
            {
                Vector2 p   = (Vector2)PositionConvertor.GetWorldPositionFromActorTileIndex(tile);
                Vector2 dis = p - targetPosition;
                if (dis.sqrMagnitude <= distanceSqrt)
                {
                    GameObject building = BattleMapData.Instance.GetBulidingObjectFromActorObstacleMap(tile.Row, tile.Column);
                    if (building != null)
                    {
                        BuildingAI ai = building.GetComponent <BuildingAI>();
                        if (ai != null && !affectedBuildings.Contains(ai))
                        {
                            affectedBuildings.Add(ai);
                            ai.SetTarget(this.gameObject, (Vector2)this.transform.position);
                        }
                    }
                }
            }
        }
    }
コード例 #7
0
ファイル: DetectBehavior.cs プロジェクト: KangLLL/century_war
    // Use this for initialization
    void Start()
    {
//		this.m_DetectScopeSqr = this.m_DetectScope * this.m_DetectScope;
        this.m_DetectScopeList = RoundHelper.FillCircle(0, 0, Mathf.FloorToInt(this.m_DetectScope /
                                                                               Mathf.Min(ClientSystemConstants.ACTOR_TILE_MAP_TILE_SIZE.width,
                                                                                         ClientSystemConstants.ACTOR_TILE_MAP_TILE_SIZE.height)));
    }
コード例 #8
0
    protected override void CalculateLightPositions(GameObject target, int targetRow, int targetColumn)
    {
        base.CalculateLightPositions(target, targetRow, targetColumn);
        IObstacleInfo property = this.m_MapData.GetObstacleInfoFormActorObstacleMap(targetRow, targetColumn);

        int radius = Mathf.FloorToInt(m_AttackScope /
                                      Mathf.Min(ClientSystemConstants.ACTOR_TILE_MAP_TILE_SIZE.width,
                                                ClientSystemConstants.ACTOR_TILE_MAP_TILE_SIZE.height));

        radius = Mathf.Max(0, radius - 1);
        foreach (TilePosition offset in property.ActorObstacleList)
        {
            TilePosition targetPosition = property.ActorPosition + offset;

            List <TilePosition> destinationTiles = RoundHelper.FillCircle(targetPosition.Column, targetPosition.Row, radius);
            foreach (TilePosition lightPosition in destinationTiles)
            {
                if (lightPosition.IsValidActorTilePosition())
                {
                    if (!this.m_PreviousTargetLightPositions.Contains(lightPosition.Column + (lightPosition.Row << 16)))
                    {
                        this.m_PreviousTargetLightPositions.Add(lightPosition.Column + (lightPosition.Row << 16));
                    }
                }
            }
        }
    }
コード例 #9
0
    protected override void Calculate()
    {
        TilePosition        affectPosition = PositionConvertor.GetActorTileIndexFromWorldPosition(this.DestinationObject.GetDestinationPosition(this.transform.position));
        List <TilePosition> affectedTiles  = RoundHelper.FillCircle
                                                 (affectPosition.Column, affectPosition.Row, Mathf.CeilToInt(this.DamageScope /
                                                                                                             (float)Mathf.Min(ClientSystemConstants.ACTOR_TILE_MAP_TILE_SIZE.height,
                                                                                                                              ClientSystemConstants.ACTOR_TILE_MAP_TILE_SIZE.width)));

        foreach (TilePosition tile in affectedTiles)
        {
            if (tile.IsValidActorTilePosition())
            {
                List <GameObject> characters = BattleMapData.Instance.ActorArray[tile.Row, tile.Column];
                foreach (GameObject character in characters)
                {
                    CharacterPropertyBehavior property = character.GetComponent <CharacterPropertyBehavior>();
                    if (property.CharacterType == CharacterType.Invader)
                    {
                        //float distance = Vector2.Distance((Vector2)this.transform.position, (Vector2)character.transform.position);

                        //float percentage = (1 - distance) / this.m_GroupDamageScope;
                        //percentage = Mathf.Max(percentage, 0);

                        CharacterHPBehavior hpBehavior = character.GetComponent <CharacterHPBehavior>();
                        hpBehavior.DecreaseHP(this.Damage, this.AttackCategory);

                        this.PushCharacter(character);
                    }
                }
            }
        }
    }
コード例 #10
0
        public sealed override ITicksInfo <DateTime> GetTicks(Range <DateTime> range, int ticksCount)
        {
            DateTime start  = range.Min;
            DateTime end    = range.Max;
            TimeSpan length = end - start;

            bool         isPositive = length.Ticks > 0;
            DifferenceIn diff       = difference;

            DateTime newStart = isPositive ? RoundDown(start, diff) : SafelyRoundUp(start);
            DateTime newEnd   = isPositive ? SafelyRoundUp(end) : RoundDown(end, diff);

            RoundingInfo bounds = RoundHelper.CreateRoundedRange(GetSpecificValue(newStart, newStart), GetSpecificValue(newStart, newEnd));

            int delta = (int)(bounds.Max - bounds.Min);

            if (delta == 0)
            {
                return new TicksInfo <DateTime> {
                           Ticks = new DateTime[] { newStart }
                }
            }
            ;

            int step = delta / ticksCount;

            if (step == 0)
            {
                step = 1;
            }

            DateTime tick          = GetStart(newStart, (int)bounds.Min, step);
            bool     isMinDateTime = IsMinDate(tick) && step != 1;

            if (isMinDateTime)
            {
                step--;
            }

            List <DateTime> ticks      = new List <DateTime>();
            DateTime        finishTick = AddStep(range.Max, step);

            while (tick < finishTick)
            {
                ticks.Add(tick);
                tick = AddStep(tick, step);
                if (isMinDateTime)
                {
                    isMinDateTime = false;
                    step++;
                }
            }

            TicksInfo <DateTime> res = new TicksInfo <DateTime> {
                Ticks = ticks.ToArray(), Info = diff
            };

            return(res);
        }
コード例 #11
0
ファイル: AttackBehavior.cs プロジェクト: KangLLL/century_war
 public virtual void Start()
 {
     this.m_AttackConfig     = this.GetComponent <AttackConfig>();
     this.m_AttackScopeSqr   = this.AttackScope * this.AttackScope;
     this.m_AttackScopeArray = RoundHelper.FillCircle(0, 0, Mathf.CeilToInt(this.AttackScope /
                                                                            Mathf.Min(ClientSystemConstants.ACTOR_TILE_MAP_TILE_SIZE.width,
                                                                                      ClientSystemConstants.ACTOR_TILE_MAP_TILE_SIZE.height)));
 }
コード例 #12
0
ファイル: BarRunning.cs プロジェクト: 15831944/KR_MN_Acad
 /// <summary>
 /// Перед вызовом
 /// </summary>
 public override void Calc()
 {
     // Масса ед
     Weight = RoundHelper.Round3Digits(WeightUnit);
     // Масса общая
     WeightTotal = RoundHelper.Round2Digits(Weight * Meters);
     Amount      = WeightTotal;
 }
コード例 #13
0
ファイル: IntegerTicksProvider.cs プロジェクト: simple689/WPF
        public ITicksInfo <int> GetTicks(Range <int> range, int ticksCount)
        {
            double start  = range.Min;
            double finish = range.Max;

            double delta = finish - start;

            int log = (int)Math.Round(Math.Log10(delta));

            double newStart  = RoundHelper.Round(start, log);
            double newFinish = RoundHelper.Round(finish, log);

            if (newStart == newFinish)
            {
                log--;
                newStart  = RoundHelper.Round(start, log);
                newFinish = RoundHelper.Round(finish, log);
            }

            // calculating step between ticks
            double unroundedStep = (newFinish - newStart) / ticksCount;
            int    stepLog       = log;
            // trying to round step
            int step = (int)RoundHelper.Round(unroundedStep, stepLog);

            if (step == 0)
            {
                stepLog--;
                step = (int)RoundHelper.Round(unroundedStep, stepLog);
                if (step == 0)
                {
                    // step will not be rounded if attempts to be rounded to zero.
                    step = (int)unroundedStep;
                }
            }

            if (step < minStep)
            {
                step = minStep;
            }
            if (step > maxStep)
            {
                step = maxStep;
            }

            if (step <= 0)
            {
                step = 1;
            }

            int[] ticks = CreateTicks(start, finish, step);

            TicksInfo <int> res = new TicksInfo <int> {
                Info = log, Ticks = ticks
            };

            return(res);
        }
コード例 #14
0
ファイル: Spring.cs プロジェクト: 15831944/KR_MN_Acad
 /// <summary>
 /// Шпилька - с шагом по ширине распределения и кол рядов
 /// </summary>
 /// <param name="diam">Диам</param>
 /// <param name="lRab">Раст между раб стержнями (от центров раб стержней)</param>
 /// <param name="step">Шаг</param>
 /// <param name="width">Ширина распределения</param>
 /// <param name="rows">Рядов шпилек</param>
 /// <param name="pos">значение атр позиции</param>
 /// <param name="block">Блок</param>
 public Spring(int diam, int lRab, int step, int width, int rows, string pos, ISpecBlock block)
     : base(diam, GetLength(lRab, diam), width, step, rows, PREFIX, pos, block, friendlyName)
 {
     //descEnd = $", ш.{step}";
     tail  = getTail(diam);
     LRab  = RoundHelper.Round5(lRab);
     Class = ClassA240C;
     Gost  = GostOld;
 }
コード例 #15
0
    private List <TilePosition> GetTilePositionList(int scope)
    {
        TilePosition actorPosition = PositionConvertor.GetActorTileIndexFromWorldPosition
                                         (this.m_Property.AnchorTransform.position);
        int radius = Mathf.CeilToInt(scope / (float)Mathf.Min(ClientSystemConstants.ACTOR_TILE_MAP_TILE_SIZE.width,
                                                              ClientSystemConstants.ACTOR_TILE_MAP_TILE_SIZE.height));

        return(RoundHelper.FillCircle(actorPosition.Column, actorPosition.Row, radius));
    }
コード例 #16
0
ファイル: Shackle.cs プロジェクト: 15831944/KR_MN_Acad
 /// <summary>
 /// Хомут
 /// </summary>
 /// <param name="diam">Диаметр</param>
 /// <param name="wShackle">Ширина хомута (по внутр гряням)</param>
 /// <param name="hShackle">Высота хомута</param>
 /// <param name="step">Шаг</param>
 /// <param name="range">Ширина распределения</param>
 /// <param name="pos">Значение атр позиции из блока</param>
 /// <param name="block">Блок</param>
 public Shackle(int diam, int wShackle, int hShackle, int step, int range, int rows, string pos, ISpecBlock block)
     : base(diam, GetLenShackle(wShackle, hShackle, diam), range, step, rows, PREFIX, pos, block, friendlyName)
 {
     tail  = getTail(diam);
     L     = RoundHelper.Round5(wShackle);
     H     = RoundHelper.Round5(hShackle);
     Class = ClassA240C;
     Gost  = GostOld;
     Key   = GetName() + "t" + tail + "L" + L + "h" + H;
 }
コード例 #17
0
ファイル: HeroDialog.cs プロジェクト: Liquidlogic1/valkyrie
    // Null function for activated hero
    public void activated()
    {
        destroy();
        hero.activated = true;

        // Let the game know that a hero has activated
        RoundHelper.HeroActivated();

        updateDisplay();
    }
コード例 #18
0
ファイル: Spring.cs プロジェクト: 15831944/KR_MN_Acad
 /// <summary>
 /// Шпилька распределенная по площади стены
 /// </summary>
 /// <param name="diam">Диаметр шпильки</param>
 /// <param name="diamWork">Диам раб арм</param>
 /// <param name="lRab">Раст между раб стержнями (от центров раб стержней)</param>
 /// <param name="stepHor">Шаг шпилек по горизонтали</param>
 /// <param name="stepVert">Шаг шпилек по вертикали</param>
 /// <param name="widthHor">Ширина распределения по гориз</param>
 /// <param name="widthVertic">Ширина распр по вертик</param>
 /// <param name="pos">Позиция (из атр блока)</param>
 /// <param name="block">Блок</param>
 public Spring(int diam, int lRab, int stepHor, int stepVert, int widthHor, int widthVertic, string pos, ISpecBlock block)
     : base(diam, GetLength(lRab, diam), 1, PREFIX, pos, block, friendlyName)
 {
     Step            = stepHor;
     this.stepVertic = stepVert;
     //descEnd = $", ш.{stepHor}х{stepVert}";
     tail  = getTail(diam);
     LRab  = RoundHelper.Round5(lRab);
     Class = ClassA240C;
     Gost  = GostOld;
     Count = CalcCountByArea(widthHor, widthVertic, stepHor, stepVert);
     Key   = GetName() + "t" + tail + "lr" + LRab;
 }
コード例 #19
0
ファイル: Bar.cs プロジェクト: 15831944/KR_MN_Acad
 public virtual void Calc()
 {
     // Кол стержней
     if (Width != 0 && Step != 0)
     {
         Count = CalcCountByStep(Width, Step) * Rows;
     }
     // Масса ед. кг.
     Weight = RoundHelper.Round3Digits(WeightUnit * ConvertMmToMLength(Length));
     // Масса всех стержней
     WeightTotal = RoundHelper.Round2Digits(Weight * Count);
     Amount      = WeightTotal;
 }
コード例 #20
0
    public override void Start()
    {
        base.Start();

        List <TilePosition> blindArray = RoundHelper.FillCircle(0, 0, Mathf.FloorToInt(this.m_BlindScope /
                                                                                       Mathf.Min(ClientSystemConstants.ACTOR_TILE_MAP_TILE_SIZE.width,
                                                                                                 ClientSystemConstants.ACTOR_TILE_MAP_TILE_SIZE.height)));

        foreach (TilePosition b in blindArray)
        {
            this.AttackScopeArray.Remove(b);
        }
    }
コード例 #21
0
ファイル: Round.cs プロジェクト: FlorianRoudaut/Coinche
        public void Play()
        {
            Trump = SuitHelper.GetSuit("Heart");
            var trick = new Trick(Players, Trump);

            for (int i = 0; i < BelotteRules.TrickNumber; i++)
            {
                trick.Play(CardsHeldByPlayers, CardsPlayedByPlayers);

                var newPlayersOrder = RoundHelper.OrderPlayersForNewTrick(Players, trick.GetTaker());
                LastTrickWinner = trick.GetTaker();
                trick           = new Trick(newPlayersOrder, Trump);
            }
        }
コード例 #22
0
        public void SetNewTimerInterval()
        {
            int interval = new DbHelper().SelectNextInterval();

            if (interval < 0)
            {
                interval = m_sleepTick;
            }
            if (interval == 0)
            {
                interval = 1;
            }
            m_log.DebugFormat("Picked new timer interval which is {0} ms ({1} min.)",
                              interval, RoundHelper.Round(interval / 1000.0m / 60.0m, 2));
            m_timer.Interval = interval;
        }
コード例 #23
0
        public Task <decimal> CalculateTaxAsync(Item item, int count)
        {
            var     subtotal = item.Price * count;
            decimal tax      = 0;

            if (!item.IsExemptFromBasicSalesTax)
            {
                tax += RoundHelper.RoundToNearest(subtotal * this.salesTax, TaxRoundsUpTo);
            }

            if (item.IsImported)
            {
                tax += RoundHelper.RoundToNearest(subtotal * this.importTax, TaxRoundsUpTo);
            }

            return(Task.FromResult(subtotal + tax));
        }
コード例 #24
0
        public string FormatNextTaskRemindingDate()
        {
            int    maxTimeTextLength = 38; // Text length without task description
            int    maxLength         = 64; // for NotifyIcon.Text property it's maximum
            int    maxTaskNameLength = maxLength - maxTimeTextLength;
            string text     = "Nothing to be mindered about";
            Task   nextTask = new DbHelper().NextTaskToShow();

            if (nextTask == null)
            {
                return(text);
            }
            if (string.IsNullOrEmpty(nextTask.Text) == false &&
                nextTask.Text.Length > maxTaskNameLength)
            {
                nextTask.Text = nextTask.Text.Substring(0, maxTaskNameLength);
            }
            DateTime?nextDate = nextTask.DateRemainder;

            if (nextDate.HasValue == false)
            {
                return(text);
            }

            text = string.Format("Task {0} minders at {1}", nextTask.Text, DBTypesConverter.ToFullDateStringByCultureInfo(nextDate.Value));
            TimeSpan difference = nextDate.Value.Subtract(DateTime.Now);

            decimal days = RoundHelper.Round((decimal)difference.TotalDays, 0);

            if (days < 1)
            {
                text = string.Format("Task {0} minders at {1}", nextTask.Text, nextDate.Value.ToShortTimeString());
            }

            decimal minutes = RoundHelper.Round((decimal)difference.TotalMinutes, 0);

            if (difference.TotalHours < 1)
            {
                text = string.Format("Task {0} minders in {1} minutes", nextTask.Text, minutes);
            }
            if (minutes < 1)
            {
                text = (string.Format("Task {0} minders in less than a minute", nextTask.Text));
            }
            return(text);
        }
コード例 #25
0
 private void AutoAdjustCoordinate()
 {
     if (this.Points.Length != 0)
     {
         this.CalcXYZRange();
         _roundZRange     = RoundHelper.CreateRoundedRange(this.ZRange.Min, this.ZRange.Max);
         _axisGrid.XRange = RoundHelper.CreateRoundedRange(this.XRange.Min, this.XRange.Max);
         _axisGrid.YRange = RoundHelper.CreateRoundedRange(this.YRange.Min, this.YRange.Max);
         if (_roundZRange.Min == _roundZRange.Max)
         {
             _axisGrid.ZRange = new Range <double>(_roundZRange.Max / 2.0, _roundZRange.Max);
         }
         else
         {
             _axisGrid.ZRange = _roundZRange;
         }
     }
 }
コード例 #26
0
        private string GetRoundedValue(double min, double max, double value)
        {
            double roundedValue = value;
            var    log          = RoundHelper.GetDifferenceLog(min, max);
            string format       = "G3";
            double diff         = Math.Abs(max - min);

            if (1E3 < diff && diff < 1E6)
            {
                format = "F0";
            }
            if (log < 0)
            {
                format = "G" + (-log + 2).ToString();
            }

            return(roundedValue.ToString(format));
        }
コード例 #27
0
ファイル: Test2.xaml.cs プロジェクト: foman/Plotter3D
        /// <summary>
        /// Initializes a new instance of the Test2 class.
        /// </summary>
        public Test2()
        {
            InitializeComponent();

            var range = RoundHelper.CreateRoundedRange(2.1, 3.5);

            double a  = 10.2;
            double b  = 1;
            var    ia = (int)a;
            var    ib = (int)b;

            ia = ia - (ia + ib) % ib;
            var c = a + b / 2;

            var d = c % b;

            a = a - d;
        }
コード例 #28
0
        public ITicksInfo <double> GetTicks(Range <double> range, int ticksCount)
        {
            double min = LogByBase(range.Min);
            double max = LogByBase(range.Max);

            double minDown = Math.Floor(min);
            double maxUp   = Math.Ceiling(max);

            double logLength = LogByBase(range.GetLength());

            ticks = CreateTicks(range);

            int log = RoundHelper.GetDifferenceLog(range.Min, range.Max);
            TicksInfo <double> result = new TicksInfo <double> {
                Ticks = ticks, TickSizes = ArrayExtensions.CreateArray(ticks.Length, 1.0), Info = log
            };

            return(result);
        }
コード例 #29
0
ファイル: Test3.xaml.cs プロジェクト: csunking/CSharp3DChart
        private Range <double> CreateRangeOfZAxis()
        {
            double minZ = Data[0, 0].Z, maxZ = Data[0, 0].Z;

            for (int i = 0; i <= Data.GetUpperBound(0); i++)
            {
                for (int j = 0; j <= Data.GetUpperBound(1); j++)
                {
                    if (Data[i, j].Z < minZ)
                    {
                        minZ = Data[i, j].Z;
                    }
                    else
                    if (Data[i, j].Z > maxZ)
                    {
                        maxZ = Data[i, j].Z;
                    }
                }
            }

            return(RoundHelper.CreateRoundedRange(minZ, maxZ));
        }
コード例 #30
0
ファイル: RoundsControl.cs プロジェクト: lorcanthrope/Maidens
        private void CreateNewRound()
        {
            if (txt_Motion.ReadOnly)
            {
                txt_Motion.ReadOnly = false;
                txt_Motion.Text     = string.Empty;
                dgv_Round.Visible   = false;

                MessageBox.Show("Enter the motion for debate in this round");
                return;
            }

            string motion = txt_Motion.Text;

            if (string.IsNullOrWhiteSpace(motion))
            {
                MessageBox.Show("Please enter a motion for debate in this round");
                return;
            }

            if (_context.Speakers.Count(s => s.Active) % 6 != 0)
            {
                MessageBox.Show(string.Format("There are an incorrect number of speakers active to draw a round. You require either {0} or {1} and you currently have {2}", Math.Floor(((decimal)_context.Speakers.Count(s => s.Active) / 6 - 1) * 6), Math.Ceiling(((decimal)_context.Speakers.Count(s => s.Active) / 6 + 1) * 6), _context.Speakers.Count(s => s.Active)));
                return;
            }

            if (_context.Speakers.Count / 6 > _context.Venues.Count(v => v.Active))
            {
                MessageBox.Show(string.Format("There are not enough venues active to draw a round. You require {0} and you currently have {1}.", _context.Speakers.Count(s => s.Active) / 6, _context.Venues.Count(v => v.Active)));
                return;
            }

            bool  isPowerPaired = chk_Powerpair.Checked;
            Round round         = RoundHelper.DrawRound(_tournament, motion, isPowerPaired);

            LoadRounds();
            cmb_Rounds.SelectedIndex = cmb_Rounds.Items.Count - 1;
            LoadRound();
        }