예제 #1
0
        /// <summary>
        /// Constructor.
        /// </summary>
        public NextLevelScreen(GameData.LevelData levelData )
            : base("Next Level")
        {
            this.levelData = levelData;
            // Create our menu entries.

            levelNumEntry = new MenuEntry("Level "+(levelData.currentlevelNum+1)+":");
            currentLevelEntry = new MenuEntry("\""+GameConstants.LEVELNAMES[levelData.currentlevelNum]+"\"");
            //timeCompleteEntry = new MenuEntry(time);
            blankEntry = new MenuEntry ( "" );
            nextLevelEntry = new MenuEntry ( "Start" );
            scoreScreenEntry = new MenuEntry ( "Score Screen" );
            mainMenuEntry = new MenuEntry ( "Main Menu" );

            // Hook up menu event handlers.
            mainMenuEntry.Selected += mainMenuEntrySelected;
            scoreScreenEntry.Selected += scoreScreenEntrySelected;
            nextLevelEntry.Selected += nextLevelEntrySelected;

            // Add entries to the menu.
            MenuEntries.Add ( levelNumEntry );
            MenuEntries.Add(currentLevelEntry);
            MenuEntries.Add ( blankEntry );
            MenuEntries.Add ( blankEntry );

            // check to see if there are still levels left before adding nextLevelEntry
            if (levelData.currentlevelNum < GameConstants.LEVELS)
            {
                MenuEntries.Add(nextLevelEntry);
            }
            // load credits
            else if (levelData.currentlevelNum == GameConstants.LEVELS)
            {
                // load game complete screen with credits if all levels are finished
                //LoadingScreen.Load(ScreenManager, true, e.PlayerIndex,
                //               new GameCompleteScreen());
            }

            MenuEntries.Add ( scoreScreenEntry );
            MenuEntries.Add(mainMenuEntry);

            //Select the first selectable entry
            while (menuEntries[selectedEntry].HasNoHandle) {
                selectedEntry++;
            }
        }
예제 #2
0
        /// <summary>
        /// Constructor.
        /// </summary>
        public GameOverScreen(GameData.LevelData levelData )
            : base("Game Over")
        {
            // Create our menu entries.
            retryLevelEntry = new MenuEntry("Retry Level");
            mainMenuEntry = new MenuEntry("Main Menu");

            // Hook up menu event handlers.
            mainMenuEntry.Selected += mainMenuEntrySelected;
            retryLevelEntry.Selected += retryLevelEntrySelected;

            // Add entries to the menu.
            MenuEntries.Add(retryLevelEntry);
            MenuEntries.Add(mainMenuEntry);

            this.levelData = levelData;
        }
예제 #3
0
        /// <summary>
        /// Constructor. Initialize game data here
        /// </summary>
        public GameplayScreen(int levelNum)
        {
            this.levelNum = levelNum;
            // Sets level data to level and sets level par time from file.
            levelData = new GameData.LevelData(levelNum, TimeSpan.Zero);

            // transition time used for screen transitions
            TransitionOnTime = TimeSpan.FromSeconds(1);
            TransitionOffTime = TimeSpan.FromSeconds(0.5);

            pauseAction = new InputAction(
                new Buttons[] { Buttons.Start, Buttons.Back },
                new Keys[] { Keys.Escape },
                true);

            // initialize rendercontext and camera
            _renderContext = new RenderContext();
            _camera = new BaseCamera();
            _camera.Translate(new Vector3(0, 0, 10));
            _renderContext.Camera = _camera;

            // initialize models,textures,sounds
            _models = new Dictionary<string, Model>();
            _textures = new Dictionary<string, Texture2D>();
            _sounds = new Dictionary<string, SoundEffect>();

            random = new Random();
            //init fps counter
            fpsCount = new FPSCounter(_renderContext);
            healthGearAnglesList = new List<float>();
            messageActive = false;
        }
        /// <summary>
        /// Constructor.
        /// </summary>
        public LevelCompleteScreen(GameData.LevelData levelData )
            : base("Level Complete")
        {
            this.levelData = levelData;
            gameData = new GameData();
            if (gameData.saveGameData.levelCompleted < levelData.currentlevelNum)
                gameData.saveGameData.levelCompleted = levelData.currentlevelNum;
            gameData.saveGameData.levelData[levelData.currentlevelNum-1].time = levelData.time.ToString();

            int levelScore = 0;
            levelScore += (int)GameConstants.SCORE.levelComplete; // add score for completing level
            // Score for health
            if(levelData.remainingHealth == GameConstants.HEALTH)
            {
                levelScore += (int)GameConstants.SCORE.fullHealth;
            }
            if (levelData.remainingHealth == GameConstants.HEALTH-1)
            {
                levelScore += (int)GameConstants.SCORE.medHealth;
            }
            if (levelData.remainingHealth == GameConstants.HEALTH-2)
            {
                levelScore += (int)GameConstants.SCORE.lowHealth;
            }

            //if(new TimeSpan( levelData.time < levelData.levelParTime)
            //{
            //    score += GameConstants.SCORE.parTimeComplete;
            //}

            gameData.saveGameData.score += levelScore;
            if(gameData.saveGameData.levelData[levelData.currentlevelNum - 1].levelHighScore < levelScore)
                gameData.saveGameData.levelData[levelData.currentlevelNum - 1].levelHighScore = levelScore;
            gameData.GetContainer();
            gameData.Save();

            // Create our menu entries.
            string time = string.Format("Time Completed: {0}", levelData.time);
            time = time.Remove(time.Length - 8);

            currentLevelEntry = new MenuEntry("\""+GameConstants.LEVELNAMES[levelData.currentlevelNum-1]+"\"");
            //timeCompleteEntry = new MenuEntry(time);
            remaingingHealthEntry = new MenuEntry("Remaining Health: " + levelData.remainingHealth.ToString());
            levelScoreEntry = new MenuEntry("Level Score: " + levelScore);
            highScoreEntry = new MenuEntry("Game Score: " + gameData.saveGameData.score.ToString());
            blankEntry = new MenuEntry ( "" );
            continueEntry = new MenuEntry("Continue");
            mainMenuEntry = new MenuEntry ( "Back to Main Menu" );

            // Hook up menu event handlers.
            mainMenuEntry.Selected += mainMenuEntrySelected;
            continueEntry.Selected += continueEntrySelected;

            // Add entries to the menu.
            MenuEntries.Add(currentLevelEntry);
            //MenuEntries.Add(timeCompleteEntry);
            MenuEntries.Add(remaingingHealthEntry);
            MenuEntries.Add(levelScoreEntry);
            MenuEntries.Add ( highScoreEntry );
            MenuEntries.Add ( blankEntry );

            // check to see if there are still levels left before adding nextLevelEntry
            if (levelData.currentlevelNum < GameConstants.LEVELS)
            {
                MenuEntries.Add(continueEntry);
            }
            // load credits
            else if (levelData.currentlevelNum == GameConstants.LEVELS)
            {
                // load game complete screen with credits if all levels are finished
                //LoadingScreen.Load(ScreenManager, true, e.PlayerIndex,
                //               new GameCompleteScreen());
            }

            MenuEntries.Add(mainMenuEntry);

            //Select the first selectable entry
            while (menuEntries[selectedEntry].HasNoHandle) {
                selectedEntry++;
            }
        }