コード例 #1
0
        public void addMagicDots(bool useRandom)
        {
            int seed = (int)DateTime.Now.Ticks;

            while (_magicDots.Count < DENSITY)
            {
                seed += (int)DateTime.Now.Ticks;
                Random r = new Random(seed);

                double size  = DOT_SIZE_MIN + (DOT_SIZE_MAX - DOT_SIZE_MIN) * r.NextDouble();
                byte   red   = (byte)(COLOR_OFFSET + ((255 - COLOR_OFFSET) * r.NextDouble()));
                byte   green = (byte)(COLOR_OFFSET + ((255 - COLOR_OFFSET) * r.NextDouble()));
                byte   blue  = (byte)(COLOR_OFFSET + ((255 - COLOR_OFFSET) * r.NextDouble()));

                AirBubbleItem magicDot = new AirBubbleItem(red, green, blue, size);
                magicDot.X           = this.Width * r.NextDouble();
                magicDot.Y           = useRandom ? this.Height * r.NextDouble() : this.Height;
                magicDot.CenterX     = magicDot.X;
                magicDot.UpSpeed     = UP_SPEED_MIN + (UP_SPEED_MAX - UP_SPEED_MIN) * r.NextDouble();
                magicDot.SwingRadius = SWING_RADIUS_MIN + (SWING_RADIUS_MAX - SWING_RADIUS_MIN) * r.NextDouble();
                magicDot.SwingSpeed  = (int)(SWING_SPEED_MIN + (SWING_SPEED_MAX - SWING_SPEED_MIN) * r.NextDouble());
                magicDot.Counter     = (int)(180 * r.NextDouble());;
                magicDot.Run();

                _magicDots.Add(magicDot);
                LayoutRoot.Children.Add(magicDot);
            }
        }
コード例 #2
0
        void moveMagicDots()
        {
            for (int i = _magicDots.Count - 1; i >= 0; i--)
            {
                AirBubbleItem magicDot = _magicDots[i];
                magicDot.Run();

                if (magicDot.Y + DOT_SIZE_MAX < 0)
                {
                    LayoutRoot.Children.Remove(magicDot);
                    _magicDots.Remove(magicDot);
                }
            }
            addMagicDots(false);
        }