예제 #1
0
        private void AddToScore(int player, int points, Point center)
        {
            if (scores.ContainsKey(player))
            {
                scores[player] = scores[player] + points;
            }
            else
            {
                scores.Add(player, points);
            }

            FlyingText.NewFlyingText(sceneRect.Width / 300, center, "+" + points);
        }
예제 #2
0
        public static void Draw(UIElementCollection children)
        {
            for (int i = 0; i < FlyingTexts.Count; i++)
            {
                FlyingText flyout = FlyingTexts[i];
                if (flyout.alpha <= 0)
                {
                    FlyingTexts.Remove(flyout);
                    i--;
                }
            }

            foreach (var flyout in FlyingTexts)
            {
                flyout.Advance();
                children.Add(flyout.label);
            }
        }
예제 #3
0
        private void HandleGameTimer(int param)
        {
            // Every so often, notify what our actual framerate is
            if ((frameCount % 100) == 0)
            {
                myFallingThings.SetFramerate(1000.0 / actualFrameTime);
            }

            // Advance animations, and do hit testing.
            for (int i = 0; i < NumIntraFrames; ++i)
            {
                foreach (var pair in players)
                {
                    HitType hit = myFallingThings.LookForHits(pair.Value.Segments, pair.Value.GetId());
                    if ((hit & HitType.Correct) != 0)
                    {
                        squeezeSound.Play();
                        FlyingText.NewFlyingText(screenRect.Width / 30, new Point(screenRect.Width / 2, screenRect.Height / 2), "YES!");
                    }
                    else if ((hit & HitType.Incorrect) != 0)
                    {
                        popSound.Play();
                        FlyingText.NewFlyingText(screenRect.Width / 30, new Point(screenRect.Width / 2, screenRect.Height / 2), "Wrong :(");
                    }
                }

                myFallingThings.AdvanceFrame();
            }



            // Draw new Wpf scene by adding all objects to canvas
            playfield.Children.Clear();
            myFallingThings.DrawFrame(playfield.Children);
            foreach (var player in players)
            {
                player.Value.Draw(playfield.Children);
            }

            BannerText.Draw(playfield.Children);
            FlyingText.Draw(playfield.Children);

            this.CheckPlayers();
        }
예제 #4
0
        private void WindowLoaded(object sender, EventArgs e)
        {
            playfield.ClipToBounds = true;

            //Have player enter name (Using speech recognition. Letter by letter or whole word. Whatever works)

            //Have player select difficulty. (Again, with speech recognition)



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

            UpdatePlayfieldSize();

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

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

            popSound.Play();

            TimeBeginPeriod(TimerResolution);
            var myGameThread = new Thread(GameThread);

            myGameThread.SetApartmentState(ApartmentState.STA);
            myGameThread.Start();

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

            SoundPlayer welcomeSound = new SoundPlayer(@"C:\Sounds\testyourfootballknowledge.wav");

            welcomeSound.Play();

            playerMusic = new MediaPlayer();
            playerMusic.Open(new Uri(@"/Sounds/fox.mp3", UriKind.RelativeOrAbsolute));
            playerMusic.Play();
        }
예제 #5
0
        private void RecognizerSaidSomething(object sender, SpeechRecognizer.SaidSomethingEventArgs e)
        {
            return;

            if (e.Matched != "?")
            {
                FlyingText.NewFlyingText(this.screenRect.Width / 30, new Point(this.screenRect.Width / 2, this.screenRect.Height / 2),
                                         e.Matched);
                switch (e.Verb)
                {
                case SpeechRecognizer.Verbs.Easy:
                    this.myFallingThings.SetGameDifficulty(1);
                    break;

                case SpeechRecognizer.Verbs.Medium:
                    this.myFallingThings.SetGameDifficulty(2);
                    break;

                case SpeechRecognizer.Verbs.Hard:
                    this.myFallingThings.SetGameDifficulty(3);
                    break;

                case SpeechRecognizer.Verbs.Pause:
                    this.myFallingThings.SetDropRate(0);
                    this.myFallingThings.SetGravity(0);
                    break;

                case SpeechRecognizer.Verbs.Resume:
                    this.myFallingThings.SetDropRate(this.dropRate);
                    this.myFallingThings.SetGravity(this.dropGravity);
                    break;

                case SpeechRecognizer.Verbs.Reset:
                    this.dropRate    = DefaultDropRate;
                    this.dropSize    = DefaultDropSize;
                    this.dropGravity = DefaultDropGravity;
                    this.myFallingThings.SetPolies(DropType.All);
                    this.myFallingThings.SetDropRate(this.dropRate);
                    this.myFallingThings.SetGravity(this.dropGravity);
                    this.myFallingThings.SetSize(this.dropSize);
                    this.myFallingThings.SetShapesColor(Color.FromRgb(0, 0, 0), true);
                    this.myFallingThings.Reset();
                    break;

                case SpeechRecognizer.Verbs.DoShapes:
                    this.myFallingThings.SetPolies(e.Shape);
                    break;

                case SpeechRecognizer.Verbs.RandomColors:
                    this.myFallingThings.SetShapesColor(Color.FromRgb(0, 0, 0), true);
                    break;

                case SpeechRecognizer.Verbs.Colorize:
                    this.myFallingThings.SetShapesColor(e.RgbColor, false);
                    break;

                case SpeechRecognizer.Verbs.ShapesAndColors:
                    this.myFallingThings.SetPolies(e.Shape);
                    this.myFallingThings.SetShapesColor(e.RgbColor, false);
                    break;

                case SpeechRecognizer.Verbs.More:
                    this.dropRate *= 1.5;
                    this.myFallingThings.SetDropRate(this.dropRate);
                    break;

                case SpeechRecognizer.Verbs.Fewer:
                    this.dropRate /= 1.5;
                    this.myFallingThings.SetDropRate(this.dropRate);
                    break;

                case SpeechRecognizer.Verbs.Bigger:
                    this.dropSize *= 1.5;
                    if (this.dropSize > MaxShapeSize)
                    {
                        this.dropSize = MaxShapeSize;
                    }

                    this.myFallingThings.SetSize(this.dropSize);
                    break;

                case SpeechRecognizer.Verbs.Biggest:
                    this.dropSize = MaxShapeSize;
                    this.myFallingThings.SetSize(this.dropSize);
                    break;

                case SpeechRecognizer.Verbs.Smaller:
                    this.dropSize /= 1.5;
                    if (this.dropSize < MinShapeSize)
                    {
                        this.dropSize = MinShapeSize;
                    }

                    this.myFallingThings.SetSize(this.dropSize);
                    break;

                case SpeechRecognizer.Verbs.Smallest:
                    this.dropSize = MinShapeSize;
                    this.myFallingThings.SetSize(this.dropSize);
                    break;

                case SpeechRecognizer.Verbs.Faster:
                    this.dropGravity *= 1.25;
                    if (this.dropGravity > 4.0)
                    {
                        this.dropGravity = 4.0;
                    }

                    this.myFallingThings.SetGravity(this.dropGravity);
                    break;

                case SpeechRecognizer.Verbs.Slower:
                    this.dropGravity /= 1.25;
                    if (this.dropGravity < 0.25)
                    {
                        this.dropGravity = 0.25;
                    }

                    this.myFallingThings.SetGravity(this.dropGravity);
                    break;
                }
            }
        }