/// <summary>
        /// Allows the game screen to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        public virtual void Update(GameTime gameTime)
        {
            if (showAvatar)
            {
                userAvatar.Update(gameTime);
                if (!IsFrozen)
                {
                    if (enablePause)
                    {
                        if (userAvatar.Avatar == userAvatar.AllAvatars[0])
                        {
                            //Freeze Screen, Show pause Screen\
                            screenPaused = true;
                            ScreenManager.AddScreen(new PauseScreen());
                            this.FreezeScreen();
                        }
                        else if (userAvatar.Avatar.Equals(userAvatar.AllAvatars[2]) && screenPaused == true)
                        {
                            //exit pause screen, unfreeze screen
                            this.UnfreezeScreen();
                        }
                    }
                }
            }

            if (frameNumber % 360 == 0 && voiceCommands != null)
            {
                voiceCommands.HeardString = "";
            }
            var currSkel = screenManager.Kinect.trackedSkeleton;
            int?currId   = null;

            if (currSkel != null)
            {
                currId = currSkel.TrackingId;
            }

            if (lastSkelId != currId)
            {
                depthTimer = 2;
                lastSkelId = currId;
            }

            if (depthTimer > 0)
            {
                depthTimer -= gameTime.ElapsedGameTime.TotalSeconds;
            }

            frameNumber++;
            if (voiceCommands != null)
            {
                switch (voiceCommands.HeardString)
                {
                case "One":
                    if (ScreenManager.Kinect.devices[0].IsSwitchedOn)
                    {
                        ScreenManager.Kinect.devices[0].switchOff(ScreenManager.Kinect.comm);
                    }
                    else
                    {
                        ScreenManager.Kinect.devices[0].switchOn(ScreenManager.Kinect.comm);
                    }
                    //this.FreezeScreen();
                    screenManager.AddScreen(new PauseScreen(ScreenManager.Kinect.devices[0].Name + " is " + ScreenManager.Kinect.devices[0].Status, 300));
                    voiceCommands.HeardString = "";
                    break;

                /*   case "Open":
                 *     if (ScreenManager.Kinect.devices[1].IsSwitchedOn)
                 *         ScreenManager.Kinect.devices[1].switchOff(ScreenManager.Kinect.comm);
                 *     else
                 *         ScreenManager.Kinect.devices[1].switchOn(ScreenManager.Kinect.comm);
                 *     screenManager.AddScreen(new PauseScreen(ScreenManager.Kinect.devices[1].Name + " is " + ScreenManager.Kinect.devices[1].Status,300));
                 *     //this.FreezeScreen();
                 *     voiceCommands.HeardString = "";
                 *     break;
                 * */
                //case "volume up":
                //    MediaPlayer.Volume++;
                //    voiceCommands.HeardString="";
                //    break;
                //case "volume down":
                //    MediaPlayer.Volume--;
                //    voiceCommands.HeardString = "";
                //    break;
                default: break;
                }
            }
        }
Exemple #2
0
        /// <summary>
        /// Allows the game screen to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        public virtual void Update(GameTime gameTime)
        {
            if (showAvatar)
            {
                userAvatar.Update(gameTime);
                if (!IsFrozen)
                {
                    if (enablePause)
                    {
                        //Freeze Screen, Show pause Screen\
                        screenPaused = true;
                        this.FreezeScreen();
                    }
                    else if (userAvatar.Avatar.Equals(userAvatar.AllAvatars[2]) && screenPaused == true)
                    {
                        //exit pause screen, unfreeze screen
                        this.UnfreezeScreen();
                        if (userAvatar.Avatar == userAvatar.AllAvatars[0])
                        {
                            //Freeze Screen, Show pause Screen\
                            screenPaused = true;
                            ScreenManager.AddScreen(new PopupScreen());
                            this.FreezeScreen();
                        }
                        else if (userAvatar.Avatar.Equals(userAvatar.AllAvatars[2]) && screenPaused == true)
                        {
                            //exit pause screen, unfreeze screen
                            this.UnfreezeScreen();
                        }
                    }
                }

                var currSkel = screenManager.Kinect.trackedSkeleton;
                int?currId   = null;
                if (currSkel != null)
                {
                    currId = currSkel.TrackingId;
                }

                if (lastSkelId != currId)
                {
                    depthTimer = 2;
                    lastSkelId = currId;
                }

                if (depthTimer > 0)
                {
                    depthTimer -= gameTime.ElapsedGameTime.TotalSeconds;
                }
            }

            if (frameNumber % 240 == 0 && voiceCommands != null)
            {
                voiceCommands.HeardString = "";
            }
            frameNumber++;

            /*if (voiceCommands != null)
             * {
             *  switch (voiceCommands.HeardString)
             *  {
             *      case "play project music":
             *          if (MediaPlayer.State.Equals(MediaState.Stopped) || MediaPlayer.State.Equals(MediaState.Paused))
             *          {
             *              playQueue = random.Next(songsarray.Length-1);
             *              MediaPlayer.Play(songsarray[playQueue]);
             *              /*
             *                                          screenManager.AddScreen(new PauseScreen());
             * MediaPlayer.PlayPosition.Minutes;
             *
             *          }
             *          break;
             *      case "stop":
             *          if (MediaPlayer.State.Equals(MediaState.Playing))
             *              MediaPlayer.Pause();
             *          break;
             *
             *      case "play mediaplayer":
             *          if (MediaPlayer.State.Equals(MediaState.Stopped) || MediaPlayer.State.Equals(MediaState.Paused))
             *          {
             *              //int i = random.Next(0, sampleMediaLibrary.Songs.Count - 1);
             *              //MediaPlayer.Play(sampleMediaLibrary.Songs[i]);
             *              MediaPlayer.Play(sampleMediaLibrary.Songs);
             *          }
             *          break;
             *      case "resume":
             *          if (MediaPlayer.State.Equals(MediaState.Paused))
             *              MediaPlayer.Resume();
             *          break;
             *      case "next":
             *          //MediaPlayer.MoveNext();
             *          //MediaPlayer.Stop();
             *          MediaPlayer.MoveNext();
             *          //MediaPlayer.Resume();
             *          //MediaPlayer.Play(sampleMediaLibrary.Songs[++playQueue]);
             *          break;
             *      case "previous":
             *          //MediaPlayer.Stop();
             *          MediaPlayer.MovePrevious();
             *          //MediaPlayer.Resume();
             *          //MediaPlayer.Play(sampleMediaLibrary.Songs[--playQueue]);
             *          break;
             *      case "mute":
             *          MediaPlayer.IsMuted = true;
             *          break;
             *      case "unmute":
             *          MediaPlayer.IsMuted = false;
             *          break;
             *      case "device one":
             *          if (ScreenManager.Kinect.devices[0].IsSwitchedOn)
             *              ScreenManager.Kinect.devices[0].switchOff(ScreenManager.Kinect.comm);
             *          else
             *              ScreenManager.Kinect.devices[0].switchOn(ScreenManager.Kinect.comm);
             *          //this.FreezeScreen();
             *          screenManager.AddScreen(new PopupScreen(ScreenManager.Kinect.devices[0].Name +" is "+ScreenManager.Kinect.devices[0].Status,300));
             *          voiceCommands.HeardString = "";
             *          break;
             *      case "device two":
             *          if (ScreenManager.Kinect.devices[1].IsSwitchedOn)
             *              ScreenManager.Kinect.devices[1].switchOff(ScreenManager.Kinect.comm);
             *          else
             *              ScreenManager.Kinect.devices[1].switchOn(ScreenManager.Kinect.comm);
             *          screenManager.AddScreen(new PopupScreen(ScreenManager.Kinect.devices[1].Name + " is " + ScreenManager.Kinect.devices[1].Status,300));
             *          //this.FreezeScreen();
             *          voiceCommands.HeardString = "";
             *          break;
             *      //case "volume up":
             *      //    MediaPlayer.Volume++;
             *      //    voiceCommands.HeardString="";
             *      //    break;
             *      //case "volume down":
             *      //    MediaPlayer.Volume--;
             *      //    voiceCommands.HeardString = "";
             *      //    break;
             *      default: break;
             *  }
             * }*/
        }