void playTimed_Selected(object sender, PlayerIndexEventArgs e)
        {
            if (gamePlayScreen == null)
                gamePlayScreen = new SnakeWorld("test1");

            LoadingScreen.Load(ScreenManager, true, e.PlayerIndex,
                               gamePlayScreen);
        }
 void menuLevel_Selected(object sender, PlayerIndexEventArgs e)
 {
     string fileName = "";
     if (sender.GetType() == typeof(LevelMenuEntry))
     {
         fileName = (sender as LevelMenuEntry).FileName;
     }
     gamePlayScreen = new SnakeWorld(fileName);
     LoadingScreen.Load(ScreenManager, true, e.PlayerIndex,
                        gamePlayScreen);
 }
Example #3
0
        void GameOverBox_Accepted(object sender, PlayerIndexEventArgs e)
        {
            string currentLevelName = string.Empty;
            foreach (var screen in ScreenManager.GetScreens())
            {
                if (screen is SnakeWorld)
                {
                    currentLevelName = (screen as SnakeWorld).TiledMapName;
                }
                screen.ExitScreen();
            }

            gamePlayScreen = new SnakeWorld(currentLevelName);

            ScreenManager.AddScreen(gamePlayScreen,ControllingPlayer);
        }
        void LevelCompleteBox_Accepted(object sender, PlayerIndexEventArgs e)
        {
            string currentLevelName = string.Empty;
            List<LevelMenu> allLevels = new List<LevelMenu>(SnakeHelper.GetAllLevels(ScreenManager.Game.Content));

            foreach (var screen in ScreenManager.GetScreens())
            {
                if (screen is SnakeWorld)
                {
                    currentLevelName = (screen as SnakeWorld).TiledMapName;
                }
                screen.ExitScreen();
            }

            LevelMenu nextLevel = null;
            LevelMenu currentLevel = allLevels.Where(x => x.MapFileName == currentLevelName).FirstOrDefault();
            int currentIndex = allLevels.IndexOf(currentLevel);
            if (currentIndex < allLevels.Count - 1)
                nextLevel = allLevels[currentIndex + 1];

            gamePlayScreen = new SnakeWorld(nextLevel.MapFileName);

            ScreenManager.AddScreen(gamePlayScreen, ControllingPlayer);
        }