Exemplo n.º 1
0
        public GameType update(Joint leftHand, Joint rightHand, Kinect.WordCommands command)
        {
            switch (command)
            {
            case Kinect.WordCommands.START:
            {
                if (gameMode == Mode.Start)
                {
                    timer.isEnabled = true;
                    gameMode        = Mode.Play;
                }

                if (gameMode == Mode.Finish)
                {
                    sounds.PlaySound(AvailableSounds.CARTOON_HOP);
                    resetGame();
                }

                break;
            }

            case Kinect.WordCommands.STOP:
            {
                if (gameMode == Mode.Start || gameMode == Mode.Finish)
                {
                    sounds.PlaySound(AvailableSounds.CARTOON_HOP);
                    return(GameType.Kindergarten);
                }
                else
                {
                    timer.cleanTimer();
                    gameMode = Mode.Finish;
                }

                break;
            }
            }

            switch (gameMode)
            {
            case Mode.Start:
            {
                break;
            }

            case Mode.Play:
            {
                time++;

                //---------------------------------
                // TIMER
                if (timer.isWorking && timer.isEnabled)
                {
                    timer.countTimeLeft();
                }
                else if (timer.isEnabled && !timer.isWorking)
                {
                    timer.startTimer();
                }

                if (timer.seconds < 0 && timer.isEnabled)
                {
                    //Czas sie skonczyl
                    timer.cleanTimer();
                    gameMode = Mode.Finish;
                }
                //---------------------------------

                if (time > NEW_APPLE_TIME)
                {
                    generateApple();
                    time = 0;
                }

                foreach (Apple apple in airApple)
                {
                    apple.updateFall();

                    if (player.rectBasket_Left.Intersects(apple.cardRectangle))
                    {
                        if (apple.visible)
                        {
                            if (Settings.PLAY_PICK_APPLE_SOUND)
                            {
                                sounds.PlaySound(AvailableSounds.TICK);
                            }
                            apple.visible = false;
                            player.points++;
                        }
                    }
                    if (player.rectBasket_Right.Intersects(apple.cardRectangle))
                    {
                        if (apple.visible)
                        {
                            if (Settings.PLAY_PICK_APPLE_SOUND)
                            {
                                sounds.PlaySound(AvailableSounds.TICK);
                            }
                            apple.visible = false;
                            player.points++;
                        }
                    }
                }

                player.setBasketPosition(colorStream.SkeletonToColorMap(leftHand.Position), colorStream.SkeletonToColorMap(rightHand.Position));

                break;
            }

            case Mode.Finish:
            {
                sounds.PlaySoundOnce(AvailableSounds.END_GAME);
                if (!cloud.isSent)
                {
                    cloud.isSent = true;
                    setScoreToCloud();
                }

                break;
            }
            }

            return(GameType.PickingApples);
        }
Exemplo n.º 2
0
        public GameType update(Rectangle cursorRect, Skeleton skeleton, Kinect.WordCommands command)
        {
            switch (command)
            {
            case Kinect.WordCommands.START:
            {
                if (gameMode == Mode.START)
                {
                    time.isEnabled = true;
                    gameMode       = Mode.PLAY;
                }

                if (gameMode == Mode.FINISH)
                {
                    resetGame();
                }
                break;
            }

            case Kinect.WordCommands.STOP:
            {
                if (player.State != MediaState.Stopped)
                {
                    player.Stop();
                }

                if (gameMode == Mode.FINISH || gameMode == Mode.START)
                {
                    sounds.PlaySound(AvailableSounds.BTN_ON_CLICK);
                    return(GameType.Kindergarten);
                }
                else
                {
                    //sounds.PlaySound(AvailableSounds.FANFARE);
                    time.cleanTimer();
                    gameMode = Mode.FINISH;
                }

                break;
            }
            }

            switch (gameMode)
            {
            case Mode.START:
            {
                return(GameType.Gymnastics);
            }

            case Mode.PLAY:
            {
                controller.updateSkeleton(skeleton);
                controller.incrementTime();

                if (isMoveDone)
                {
                    isMoveDone = false;
                    points++;
                    controller.getRandomMove();
                    player.Stop();
                }
                else
                {
                    isMoveDone = controller.isMoveDone();
                }

                //---------------------------------
                // TIMER
                if (time.isWorking && time.isEnabled)
                {
                    time.countTimeLeft();
                }
                else if (time.isEnabled && !time.isWorking)
                {
                    time.startTimer();
                }

                if (time.seconds < 0 && time.isEnabled)
                {
                    //Czas sie skonczyl
                    //sounds.PlaySound(AvailableSounds.FANFARE);
                    time.cleanTimer();
                    gameMode = Mode.FINISH;
                }
                //---------------------------------


                //---------------------------------
                // VIDEO
                if (player.State == MediaState.Stopped)
                {
                    player.IsLooped = true;
                    player.Play(moveVideos[controller.getMove()].video);
                }
                //---------------------------------
                // AUDIO
                PlayMoveSound(controller.getMove());
                //---------------------------------

                return(GameType.Gymnastics);
            }

            case Mode.FINISH:
            {
                sounds.PlaySoundOnce(AvailableSounds.END_GAME);

                if (!cloud.isSent)
                {
                    cloud.isSent = true;
                    setScoreToCloud();
                    //bestScore = Json.Deserialize(cloud.response);
                }
                return(GameType.Gymnastics);
            }
            }

            return(GameType.Gymnastics);
        }