protected override List<KeyValuePair<IGameObject, IGameObject>> spawnGameObjectsOnStart()
        {
            {// user dead sound
                SoundGameObject soundGameObject = new SoundGameObject(new Uri(@"Resources\Sounds\user_dead.wav", UriKind.Relative), false);
                GameLoop.getSpawnerManager().specialRequestToSpawn(new GameObjectSpawnRequest(soundGameObject, null));
            }

            List<KeyValuePair<IGameObject, IGameObject>> ret = base.spawnGameObjectsOnStart();
            ISceneManager sceneManager = GameLoop.getSceneManager();

            //add user object
            Image image = new Image();
            image.Source = new BitmapImage(new Uri(BitmapUtility.getImgResourcePath(@"hand.png")));
            image.Height = 150;
            image.Width = 150;

            Image notAlreadyTracketImage = new Image();
            notAlreadyTracketImage.Source = new BitmapImage(new Uri(BitmapUtility.getImgResourcePath(@"wave.png")));
            notAlreadyTracketImage.Height = 129;
            notAlreadyTracketImage.Width = 600;

            Geometry boundingBoxGeometry = new EllipseGeometry(new Point(75, 75), 10, 10);

            double halfCanvasWidth = sceneManager.getCanvasWidth() * 0.5;
            double halfCanvasHeight = sceneManager.getCanvasHeight() * 0.5;

            HandUserGameObject userGameObject = new HandUserGameObject(0, 0, boundingBoxGeometry, notAlreadyTracketImage, image, SkeletonSmoothingFilter.HIGH_SMOOTHING_LEVEL);
            ret.Add(new KeyValuePair<IGameObject, IGameObject>(userGameObject, null));
            #if DEBUG
            ret.Add(new KeyValuePair<IGameObject, IGameObject>(new BoundingBoxViewerGameObject(userGameObject), userGameObject));
            #endif

            //add game score and time labels
            CenteredScreenAreaGameObject centeredScreenAreaGameObject = new CenteredScreenAreaGameObject(sceneManager.getCanvasWidth(),
                                                                                                         sceneManager.getCanvasHeight(),
                                                                                                         1024,
                                                                                                         320);
            ret.Add(new KeyValuePair<IGameObject, IGameObject>(centeredScreenAreaGameObject, null));

            //init accumulators
            double currentHeight = 0;
            double finalScore = 0;

            double diffMultiplier = 1;
            switch (this.gameDifficulty)
            {
                case Configuration.GameDifficultyEnum.Medium:
                    diffMultiplier = 1.5;
                    break;
                case Configuration.GameDifficultyEnum.Hard:
                    diffMultiplier = 2;
                    break;
            }

            double controlMultiplier = 1;
            if (this.userControlMethod == Configuration.UserControlMethodEnum.Head)
            {
                controlMultiplier = 3;
            }

            //game score label
            double multiplier = POINTS_PER_BONUS * controlMultiplier * diffMultiplier;
            double currentScore = this.bonusPoints * multiplier;

            finalScore += currentScore;
            IGameObject gameObject = new GameLabelObject(0, currentHeight, "Saved fruits score : " + currentScore + " (" + this.bonusPoints + " x " + multiplier + ")", -1);
            ret.Add(new KeyValuePair<IGameObject, IGameObject>(gameObject, centeredScreenAreaGameObject));
            #if DEBUG
            ret.Add(new KeyValuePair<IGameObject, IGameObject>(new BoundingBoxViewerGameObject(gameObject), userGameObject));
            #endif
            currentHeight += VERTICAL_LABEL_SPACE + gameObject.getBoundingBoxGeometry().Bounds.Height;

            //game length label
            multiplier = diffMultiplier * POINTS_PER_MILLIS;

            currentScore = this.gameLength * multiplier;
            finalScore += currentScore;
            gameObject = new GameLabelObject(0, currentHeight, "Survival bonus       : " + Math.Round(currentScore, 1) + " (" + this.millis2time(this.gameLength) + ")", -1);
            ret.Add(new KeyValuePair<IGameObject, IGameObject>(gameObject, centeredScreenAreaGameObject));
            #if DEBUG
            ret.Add(new KeyValuePair<IGameObject, IGameObject>(new BoundingBoxViewerGameObject(gameObject), userGameObject));
            #endif
            currentHeight += VERTICAL_LABEL_SPACE + gameObject.getBoundingBoxGeometry().Bounds.Height;

            //rage score label
            multiplier = POINTS_PER_RAGE * diffMultiplier;
            currentScore = this.ragePoints * multiplier;
            finalScore += currentScore;
            gameObject = new GameLabelObject(0, currentHeight, "Enemy rage bonus  : " + currentScore + " (" + this.ragePoints + " x " + multiplier + ")", -1);
            ret.Add(new KeyValuePair<IGameObject, IGameObject>(gameObject, centeredScreenAreaGameObject));
            #if DEBUG
            ret.Add(new KeyValuePair<IGameObject, IGameObject>(new BoundingBoxViewerGameObject(gameObject), userGameObject));
            #endif
            currentHeight += VERTICAL_LABEL_SPACE + gameObject.getBoundingBoxGeometry().Bounds.Height;

            gameObject = this.createBackButton();

            //difficulty bonus label
            finalScore *= diffMultiplier;
            gameObject = new GameLabelObject(0, currentHeight, "Difficulty bonus     " + (diffMultiplier > 1 ? "x " + diffMultiplier : "NO BONUS"), -1);
            ret.Add(new KeyValuePair<IGameObject, IGameObject>(gameObject, centeredScreenAreaGameObject));
            #if DEBUG
            ret.Add(new KeyValuePair<IGameObject, IGameObject>(new BoundingBoxViewerGameObject(gameObject), userGameObject));
            #endif
            currentHeight += VERTICAL_LABEL_SPACE + gameObject.getBoundingBoxGeometry().Bounds.Height;

            //control bonus label
            finalScore *= controlMultiplier;
            gameObject = new GameLabelObject(0, currentHeight, "Control bonus        " + (controlMultiplier > 1 ? "x " + controlMultiplier : "NO BONUS"), -1);
            ret.Add(new KeyValuePair<IGameObject, IGameObject>(gameObject, centeredScreenAreaGameObject));
            #if DEBUG
            ret.Add(new KeyValuePair<IGameObject, IGameObject>(new BoundingBoxViewerGameObject(gameObject), userGameObject));
            #endif
            currentHeight += VERTICAL_LABEL_SPACE + gameObject.getBoundingBoxGeometry().Bounds.Height;

            //final score label
            gameObject = new GameLabelObject(0, currentHeight, "FINAL SCORE             : " + Math.Round(finalScore), -1);
            ret.Add(new KeyValuePair<IGameObject, IGameObject>(gameObject, centeredScreenAreaGameObject));
            #if DEBUG
            ret.Add(new KeyValuePair<IGameObject, IGameObject>(new BoundingBoxViewerGameObject(gameObject), userGameObject));
            #endif
            currentHeight += VERTICAL_LABEL_SPACE + gameObject.getBoundingBoxGeometry().Bounds.Height;

            gameObject = this.createBackButton();

            ret.Add(new KeyValuePair<IGameObject, IGameObject>(gameObject, null));
            #if DEBUG
            ret.Add(new KeyValuePair<IGameObject, IGameObject>(new BoundingBoxViewerGameObject(gameObject), gameObject));
            #endif

            return ret;
        }
예제 #2
0
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        private List<KeyValuePair<IGameObject, IGameObject>> spawnBaseMenuInitialObject()
        {
            List<KeyValuePair<IGameObject, IGameObject>> gameObjectParentGameObjectPairList = new List<KeyValuePair<IGameObject, IGameObject>>();

            { // selection sound
                SoundGameObject soundGameObject = new SoundGameObject(new Uri(@"Resources\Sounds\selection.wav", UriKind.Relative), false);
                GameLoop.getSpawnerManager().specialRequestToSpawn(new GameObjectSpawnRequest(soundGameObject, null));
            }

            { // Menu theme
                SoundGameObject soundGameObject = new SoundGameObject(new Uri(@"Resources/Sounds/menu_theme.mp3", UriKind.Relative),
                                                                      0.4,
                                                                      true);
                gameObjectParentGameObjectPairList.Add(new KeyValuePair<IGameObject, IGameObject>(soundGameObject, null));
            }

            { //userObject

                Image image = new Image();
                image.Source = new BitmapImage(new Uri(BitmapUtility.getImgResourcePath(@"hand.png")));
                image.Height = 150;
                image.Width = 150;

                Image notAlreadyTracketImage = new Image();
                notAlreadyTracketImage.Source = new BitmapImage(new Uri(BitmapUtility.getImgResourcePath(@"wave.png")));
                notAlreadyTracketImage.Height = 129;
                notAlreadyTracketImage.Width = 600;

                Geometry boundingBoxGeometry = new EllipseGeometry(new Point(75, 75), 10, 10);

                HandUserGameObject userGameObject = new HandUserGameObject(0, 0, boundingBoxGeometry, notAlreadyTracketImage, image, SkeletonSmoothingFilter.HIGH_SMOOTHING_LEVEL);
                gameObjectParentGameObjectPairList.Add(new KeyValuePair<IGameObject, IGameObject>(userGameObject, null));
            #if DEBUG
                gameObjectParentGameObjectPairList.Add(new KeyValuePair<IGameObject, IGameObject>(new BoundingBoxViewerGameObject(userGameObject), userGameObject));
            #endif
            }

            { //logo

                Image logoImage = new Image();
                logoImage.Source = new BitmapImage(new Uri(BitmapUtility.getImgResourcePath(@"logo.png")));
                logoImage.Height = 221;
                logoImage.Width = 400;

                ImageGuiGameObject logoGameObject = new ImageGuiGameObject(600, 20, logoImage);
                gameObjectParentGameObjectPairList.Add(new KeyValuePair<IGameObject, IGameObject>(logoGameObject, null));

            }

            { //menu area

                ISceneManager sceneManager = GameLoop.getSceneManager();

                CenteredScreenAreaGameObject areaGameObject = new CenteredScreenAreaGameObject(sceneManager.getCanvasWidth(),
                                                                                                   sceneManager.getCanvasHeight(),
                                                                                                   1366,
                                                                                                   700);
                this.menuAreaGameObject = areaGameObject;
                gameObjectParentGameObjectPairList.Add(new KeyValuePair<IGameObject, IGameObject>(areaGameObject, null));
            #if DEBUG
                gameObjectParentGameObjectPairList.Add(new KeyValuePair<IGameObject, IGameObject>(new BoundingBoxViewerGameObject(areaGameObject), areaGameObject));
            #endif
            }

            this.spawnerStateFunction = this.spawnMainMenu;
            this.stateChanged = true;
            return gameObjectParentGameObjectPairList;
        }