//preparationWindow private void PrepareStageUI(SpriteBatch sprite) { switch (currentPreparationState) { case StagePreparationStates.CHECK_KINECT_CONNECTION: if (kinector.getConnectionStatus() != KinectStatus.Connected) { myUI.writeNotificationWindow(sprite, "NO KINECT SENSOR DETECTED", "Kinect device not properly connected.", Color.Red, Color.White, Color.LightGray); //myUI.WriteToPreparationWindow(sprite, "Kinect device not properly connected."); } else { myUI.writeNotificationWindow(sprite, "PREPARING SENSOR", "Kinect device ready.", Color.Yellow, Color.White, Color.LightGray); //myUI.WriteToPreparationWindow(sprite, "Kinect device ready"); } msgCtr += 1; if (msgCtr >= GameConfig.MESSAGE_SWITCH_TIME) { msgCtr = 0; if (kinector.getConnectionStatus() == KinectStatus.Connected) { currentPreparationState = StagePreparationStates.CHECK_SKELETON; } else { msgCtr = 200; currentPreparationState = StagePreparationStates.READY; } } break; case StagePreparationStates.CHECK_SKELETON: if (!kinector.hasFoundSkeleton()) { myUI.writeNotificationWindow(sprite, "UNABLE TO DETECT USER", "No user tracked yet.", Color.OrangeRed, Color.White, Color.LightGray); } else { myUI.writeNotificationWindow(sprite, "CALIBRATING", "A user is now being tracked", Color.Yellow, Color.White, Color.LightGray); msgCtr += 1; if (msgCtr >= GameConfig.MESSAGE_SWITCH_TIME) { msgCtr = 0; currentPreparationState = StagePreparationStates.CHECK_DEPTH; } } break; case StagePreparationStates.CHECK_DEPTH: if (kinector.hasFoundSkeleton()) { if (kinector.getDepth(JointType.HipCenter) < 2f) { myUI.writeNotificationWindow(sprite, "ADJUST USER POSITION", "Please move farther away from the sensor.", Color.OrangeRed, Color.White, Color.LightGray); } else { myUI.writeNotificationWindow(sprite, "IDEAL POSITION ACHIEVED", "1.5 meters away from sensor", Color.OrangeRed, Color.White, Color.LightGray); msgCtr = 0; currentPreparationState = StagePreparationStates.ADJUST_ANGLE; } } else { currentPreparationState = StagePreparationStates.CHECK_SKELETON; msgCtr = 0; } break; case StagePreparationStates.ADJUST_ANGLE: if (kinector.hasFoundSkeleton()) { if (kinector.getHeadPosition().Y > GameConfig.APP_HEIGHT/4 ) { if (msgCtr <= 0) { kinector.setElevationAngle(kinector.getElevationAngle() - 3); msgCtr = GameConfig.ANGLE_ADJUST_WAIT_TIME; } else { myUI.writeNotificationWindow(sprite, "ADJUSTING ANGLE", "Please wait...", Color.OrangeRed, Color.White, Color.LightGray); msgCtr--; } } else if (kinector.getCentralHipPosition().Y < GameConfig.APP_HEIGHT / 2) { if (msgCtr <= 0) { kinector.setElevationAngle(kinector.getElevationAngle() + 3); msgCtr = GameConfig.ANGLE_ADJUST_WAIT_TIME; } else { myUI.writeNotificationWindow(sprite, "ADJUSTING CAMERA ANGLE", "Please wait...", Color.OrangeRed, Color.White, Color.LightGray); msgCtr--; } } else { msgCtr = 0; currentPreparationState = StagePreparationStates.MEASURE_SEGMENTS; } } else { currentPreparationState = StagePreparationStates.CHECK_SKELETON; msgCtr = 0; } break; case StagePreparationStates.MEASURE_SEGMENTS: myUI.writeNotificationWindow(sprite, "SCALING BODY SEGMENTS", "Please Remain still.", Color.OrangeRed, Color.White, Color.LightGray); msgCtr += 1; //measure right limb size by getting mean average rightLimbEstSize += MathUtil.getDistance(kinector.getRightShoulderPosition(), kinector.getRightElbowPosition()) + MathUtil.getDistance(kinector.getRightElbowPosition(),kinector.getHandPosition()); rightLimbNCount += 1; //measure left limb size by getting mean average leftLimbEstSize += MathUtil.getDistance(kinector.getRightShoulderPosition(), kinector.getRightElbowPosition()) + MathUtil.getDistance(kinector.getRightElbowPosition(),kinector.getHandPosition()); leftLimbNCount += 1; if (msgCtr >= GameConfig.MESSAGE_SWITCH_TIME + 150) { //right limb mean rightLimbEstSize = rightLimbEstSize / rightLimbNCount + 30; rightReachablePoints = Randomizer.getEvenListOfPoints(rightLimbEstSize, 40, 40); //left limb mean leftLimbEstSize = leftLimbEstSize / leftLimbNCount + 30; leftReachablePoints = Randomizer.getEvenListOfPoints(leftLimbEstSize, 40, 40); soloBubblesToPop = rightReachablePoints.Count; msgCtr = 300; currentPreparationState = StagePreparationStates.READY; } break; case StagePreparationStates.READY: myUI.writeNotificationWindow(sprite, "READY", "Starting in " + msgCtr / 80 + " second/s", Color.LightYellow, Color.White, Color.LightGray); msgCtr -= 1; if (msgCtr <= 80) { if (rightLimbEstSize == 0 || leftLimbEstSize == 0) { //right limb mean rightLimbEstSize = 200; rightReachablePoints = Randomizer.getEvenListOfPoints(rightLimbEstSize, 40, 40); //left limb mean leftLimbEstSize = 200; leftReachablePoints = Randomizer.getEvenListOfPoints(leftLimbEstSize, 40, 40); } currentPreparationState = StagePreparationStates.FINISHED; } break; case StagePreparationStates.FINISHED: break; } }
/* =================================================================== * CONTENT LOADER * =================================================================== */ public override void LoadContent( ContentManager content ) { base.LoadBasicContent(content); //bubbles blueHands = new Dictionary<BubbleState, Texture2D>(); blueHands[BubbleState.NORMAL_STATE] = content.Load<Texture2D>("bubbles/bubble_hand_normal"); blueHands[BubbleState.HIGHLIGHTED_STATE] = content.Load<Texture2D>("bubbles/bubble_hand_highlighted"); blueHands[BubbleState.STATIC_INACTIVE] = content.Load<Texture2D>("bubbles/bubble_hand_inactive"); blueHands[BubbleState.LOCKED_IN] = content.Load<Texture2D>("bubbles/bubble_hand_locked"); //lines lineTexture = content.Load<Texture2D>("lines/line"); directionLineTexture = content.Load<Texture2D>("lines/directionLine"); basicFont = content.Load<SpriteFont>("fonts/BasicFont"); dot = content.Load<Texture2D>("effects/basic_particle"); effectHandler.LoadContent(content); currentPreparationState = StagePreparationStates.CHECK_KINECT_CONNECTION; myUI.LoadContent(content); }