Ejemplo n.º 1
0
        private void HandleGameTimer(int param)
        {
            // Draw new Wpf scene by adding all objects to canvas
            playfield.Children.Clear();
            foreach (var player in this.players)
            {
                player.Value.Draw(playfield.Children);
            }
            //BannerText.Draw(playfield.Children);
            FlyingText.Draw(playfield.Children);

            this.CheckPlayers();
        }
Ejemplo n.º 2
0
        private void HandleGameTimer(int param)
        {
            // Every so often, notify what our actual framerate is
            if ((this.frameCount % 100) == 0)
            {
                this.myFallingThings.SetFramerate(1000.0 / this.actualFrameTime);
            }

            // Advance animations, and do hit testing.
            for (int i = 0; i < NumIntraFrames; ++i)
            {
                foreach (var pair in this.players)
                {
                    HitType hit = this.myFallingThings.LookForHits(pair.Value.Segments, pair.Value.GetId());
                    if ((hit & HitType.Squeezed) != 0)
                    {
                        this.squeezeSound.Play();
                    }
                    else if ((hit & HitType.Popped) != 0)
                    {
                        this.popSound.Play();
                    }
                    else if ((hit & HitType.Hand) != 0)
                    {
                        this.hitSound.Play();
                    }
                }

                this.myFallingThings.AdvanceFrame();
            }

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

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

            this.CheckPlayers();
        }
Ejemplo n.º 3
0
        private void HandleGameTimer(int param)
        {
            // Every so often, notify what our actual framerate is
            if ((this.frameCount % 100) == 0)
            {
                this.myFallingThings.SetFramerate(1000.0 / this.actualFrameTime);
            }

            // Advance animations, save current skeleton state, and do hit testing.
            for (int i = 0; i < NumIntraFrames; ++i)
            {
                BoneData rightShoulderData = new BoneData();
                foreach (var pair in this.players) // Although our game is designed for one player, this gives us the potential for multiplayer
                {
                    Bone     rightArm = new Bone(JointType.WristRight, JointType.ElbowRight);
                    BoneData rightArmData;
                    pair.Value.Segments.TryGetValue(rightArm, out rightArmData);
                    Bone rightShoulder = new Bone(JointType.ShoulderCenter, JointType.ShoulderRight);

                    pair.Value.Segments.TryGetValue(rightShoulder, out rightShoulderData);
                    this.rightWristXPosition.RemoveAt(0);
                    this.rightWristXPosition.Add(rightArmData.Segment.X1);
                    this.rightWristXVelocity.RemoveAt(0);
                    this.rightWristXVelocity.Add(rightArmData.XVelocity);
                    this.rightWristYPosition.RemoveAt(0);
                    this.rightWristYPosition.Add(rightArmData.Segment.Y1);
                    this.rightWristYVelocity.RemoveAt(0);
                    this.rightWristYVelocity.Add(rightArmData.YVelocity);
                    this.shoulderCenterXPosition.RemoveAt(0);
                    this.shoulderCenterXPosition.Add(rightShoulderData.Segment.X1);
                    this.shoulderCenterYPosition.RemoveAt(0);
                    this.shoulderCenterYPosition.Add(rightShoulderData.Segment.Y1);

                    // Decrement protegoDuration each frame until 0, at which point
                    if (this.protegoDuration > 0)
                    {
                        this.protegoDuration -= 1;
                    }
                    else
                    {
                        this.myFallingThings.RemoveShape(PolyType.Circle);
                    }


                    bool hit = this.myFallingThings.CheckPlayerHit(pair.Value.Segments, pair.Value.GetId());
                    if (hit)
                    {
                        // Game over
                        this.myFallingThings.PauseGame();
                        this.gamePaused = true;
                        FlyingText.NewFlyingText(this.screenRect.Width / 30, new Point(this.screenRect.Width / 2, this.screenRect.Height / 2), "Game over!", System.Windows.Media.Color.FromArgb(255, 255, 0, 0));
                        this.squeezeSound.Play();
                    }
                }

                this.myFallingThings.AdvanceFrame(rightShoulderData.Segment.X1, rightShoulderData.Segment.Y1);
            }

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

            FlyingText.Draw(playfield.Children);

            this.CheckPlayers();
        }