Пример #1
0
        private Label GetLabel()
        {
            if (this.brush == null)
            {
                this.brush = new SolidColorBrush(this.color);
            }

            if (this.label == null)
            {
                this.label = FallingThings.MakeSimpleLabel(this.text, this.boundsRect, this.brush);
                if (this.doScroll)
                {
                    this.label.FontSize = Math.Max(20, this.boundsRect.Height / 30);
                    this.label.Width    = 10000;
                }
                else
                {
                    this.label.FontSize = Math.Min(
                        Math.Max(10, this.boundsRect.Width * 2 / this.text.Length), Math.Max(10, this.boundsRect.Height / 20));
                }

                this.label.VerticalContentAlignment   = VerticalAlignment.Bottom;
                this.label.HorizontalContentAlignment = this.doScroll
                                                            ? HorizontalAlignment.Left
                                                            : HorizontalAlignment.Center;
                this.label.SetValue(Canvas.LeftProperty, this.offset * this.boundsRect.Width);
            }

            this.renderedRect = new Rect(this.label.RenderSize);

            if (this.doScroll)
            {
                this.offset -= 0.0015;
                if (this.offset * this.boundsRect.Width < this.boundsRect.Left - 10000)
                {
                    return(null);
                }

                this.label.SetValue(Canvas.LeftProperty, (this.offset * this.boundsRect.Width) + this.boundsRect.Left);
            }

            return(this.label);
        }
Пример #2
0
        private void WindowLoaded(object sender, EventArgs e)
        {
            playfield.ClipToBounds = true;

            this.myFallingThings = new FallingThings(MaxShapes, this.targetFramerate, NumIntraFrames);

            this.UpdatePlayfieldSize();

            this.myFallingThings.SetGravity(this.dropGravity);
            this.myFallingThings.SetDropRate(this.dropRate);
            this.myFallingThings.SetSize(this.dropSize);
            this.myFallingThings.SetPolies(PolyType.All);
            this.myFallingThings.SetGameMode(GameMode.Off);

            this.popSound.Stream = Properties.Resources.Pop_5;
            this.hitSound.Stream = Properties.Resources.Hit_2;
            this.squeezeSound.Stream = Properties.Resources.Squeeze;

            this.popSound.Play();

            TimeBeginPeriod(TimerResolution);
            var myGameThread = new Thread(this.GameThread);
            myGameThread.SetApartmentState(ApartmentState.STA);
            myGameThread.Start();

            FlyingText.NewFlyingText(this.screenRect.Width / 30, new Point(this.screenRect.Width / 2, this.screenRect.Height / 2), "Shapes!");
        }
Пример #3
0
        private void WindowLoaded(object sender, EventArgs e)
        {
            playfield.ClipToBounds = true;

            this.myFallingThings = new FallingThings(MaxShapes, this.targetFramerate, NumIntraFrames);

            this.UpdatePlayfieldSize();

            this.myFallingThings.SetGravity(this.dropGravity);
            this.myFallingThings.SetDropRate(this.dropRate);
            this.myFallingThings.SetSize(this.dropSize);
            this.myFallingThings.SetPolies(PolyType.Circle);
            this.myFallingThings.SetGameMode(GameMode.Off);

            this.popSound.Stream = Properties.Resources.Pop_5;
            this.hitSound.Stream = Properties.Resources.Hit_2;
            this.squeezeSound.Stream = Properties.Resources.Squeeze;

            this.popSound.Play();

            TimeBeginPeriod(TimerResolution);
            var myGameThread = new Thread(this.GameThread);
            myGameThread.SetApartmentState(ApartmentState.STA);
            myGameThread.Start();

            FlyingText.NewFlyingText(this.screenRect.Width / 30, new Point(this.screenRect.Width / 2, this.screenRect.Height / 2), "Equate!");

            myFallingThings.DropNewThing(PolyType.Circle, dropSize, System.Windows.Media.Color.FromRgb(0, 0, 0), StoredValueType.Addition);
            myFallingThings.DropNewThing(PolyType.Circle, dropSize, System.Windows.Media.Color.FromRgb(0, 0, 0), StoredValueType.Subtraction);
            myFallingThings.DropNewThing(PolyType.Circle, dropSize, System.Windows.Media.Color.FromRgb(0, 0, 0), StoredValueType.Multiplication);
            myFallingThings.DropNewThing(PolyType.Circle, dropSize, System.Windows.Media.Color.FromRgb(0, 0, 0), StoredValueType.Division);
        }
Пример #4
0
        private void Window_Loaded(object sender, EventArgs e)
        {
            playfield.ClipToBounds = true;

            fallingThings = new FallingThings(MaxShapes, targetFramerate, NumIntraFrames);

            UpdatePlayfieldSize();

            fallingThings.SetGravity(dropGravity);
            fallingThings.SetDropRate(dropRate);
            fallingThings.SetSize(dropSize);
            fallingThings.SetPolies(PolyType.All);
            fallingThings.SetGameMode(FallingThings.GameMode.Off);

            if ((nui != null) && InitializeNui())
            {
                nui.VideoFrameReady += new EventHandler<ImageFrameReadyEventArgs>(nui_ColorFrameReady);
                nui.SkeletonFrameReady += new EventHandler<SkeletonFrameReadyEventArgs>(nui_SkeletonFrameReady);

                try
                {
                    recognizer = new Recognizer();
                }
                catch
                {
                    recognizer = null;
                }
                if ((recognizer== null) || !recognizer.IsValid())
                {
                    BannerText.NewBanner(Properties.Resources.NoSpeechError, screenRect, false, Color.FromArgb(90, 255, 255, 255));
                    recognizer = null;
                }
                else
                    recognizer.SaidSomething += recognizer_SaidSomething;
            }
            else
            {
                BannerText.NewBanner(Properties.Resources.NoKinectError, screenRect, false, Color.FromArgb(90, 255, 255, 255));
            }

            popSound.Stream = Properties.Resources.Pop_5;
            hitSound.Stream = Properties.Resources.Hit_2;
            squeezeSound.Stream = Properties.Resources.Squeeze;

            popSound.Play();

            Win32.timeBeginPeriod(TimerResolution);
            var gameThread = new Thread(GameThread);
            gameThread.SetApartmentState(ApartmentState.STA);
            gameThread.Start();

            FlyingText.NewFlyingText(screenRect.Width / 30, new Point(screenRect.Width / 2, screenRect.Height / 2), "Shapes!");
        }