Beispiel #1
0
        public void HiddenINPCEvents_Remove()
        {
            SetSource(Rectangles);
            // These INPC events don't have publicly visible properties so I don't know why/how they're being raised.
            INotifyPropertyChanged source = (INotifyPropertyChanged)View;

            VerifyPropertyChanged("#2", source, () => Rectangles.RemoveAt(1), "Count");
        }
Beispiel #2
0
 public void DeleteSelected()
 {
     for (int i = Rectangles.Count - 1; i >= 0; i--)
     {
         if (Rectangles[i].Selected)
         {
             Rectangles.RemoveAt(i);
         }
     }
 }
Beispiel #3
0
 // Checks for ball-rectangles collision and removes dead rectangles.
 private void CheckRectangleCollision(Ball ball)
 {
     for (int i = Rectangles.Count - 1; i >= 0; --i)
     {
         if (ball.CheckCollision(Rectangles.ElementAt(i)))
         {
             if (Rectangles.ElementAt(i).HitsRemaining <= 0)
             {
                 Rectangles.RemoveAt(i);
             }
             break;
         }
     }
 }
        private void BeginNewRectangle()
        {
            var rectangleIndex = GetNextRectangleIndex();

            CurrentRectangle = Rectangles[rectangleIndex];
            Rectangles.RemoveAt(rectangleIndex);

            var size = CurrentRectangle.Size;

            if (size[0] <= 2)
            {
                Vertical = true;
            }
            else if (size[1] <= 2)
            {
                Vertical = false;
            }
            else
            {
                var horizontalChance             = Biases[0];
                var verticalChance               = Biases[1];
                var proportionalSplitsMultiplier = Math.Abs(ProportionalSplits - 1) < 0.000001 ? double.MaxValue :  1 / (1 - ProportionalSplits) - 1;
                if (size[0] > size[1])
                {
                    horizontalChance *= proportionalSplitsMultiplier;
                }
                else if (size[0] < size[1])
                {
                    verticalChance *= proportionalSplitsMultiplier;
                }

                var sum = horizontalChance + verticalChance;
                Vertical = verticalChance > RNG.NextDouble() * sum;
            }


            if (Vertical)
            {
                var randPart = GetRandomPart(size[1]);
                var coord    = CurrentRectangle.From[1] - 1 + randPart;
                InitialPoint = new Point(CurrentRectangle.From[0] - 1, coord);
            }
            else
            {
                var randPart = GetRandomPart(size[0]);
                var coord    = CurrentRectangle.From[0] - 1 + randPart;
                InitialPoint = new Point(coord, CurrentRectangle.From[1] - 1);
            }
            LastPoint = InitialPoint;
        }