Exemplo n.º 1
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            this.IsMouseVisible = true;

            ContentLibrary.LoadContentLibrary(Content);

            m_scoreList = new List<Score>();
            m_scoreList = LevelIO.LoadScore("scores.bin");

            //GameState Manager Stuff
            m_gameStateManager = new GameStateManager(this);
            
            PlayingGameState m_playingGameState =
                new PlayingGameState(m_gameStateManager, windowRes);
            
            LevelEditor m_editor =
                new LevelEditor(m_gameStateManager, windowRes);

            SplashScreen m_splash =
                new SplashScreen(m_gameStateManager, windowRes);

            MenuGameState m_menu =
                new MenuGameState(m_gameStateManager, windowRes);

            PauseGameState m_pause =
                new PauseGameState(m_gameStateManager, windowRes);

            TutorialGameState m_tutorial =
                new TutorialGameState(m_gameStateManager, windowRes);

            Level1GameState m_level1 =
                new Level1GameState(m_gameStateManager, windowRes);

            Level2GameState m_level2 =
                new Level2GameState(m_gameStateManager, windowRes);

            Level3GameState m_level3 =
                new Level3GameState(m_gameStateManager, windowRes);

            m_gameStateManager.SetState("playingGS", m_playingGameState);
            m_gameStateManager.SetState("editor", m_editor);
            m_gameStateManager.SetState("splashScreen", m_splash);
            m_gameStateManager.SetState("menu", m_menu);
            m_gameStateManager.SetState("pause", m_pause);
            m_gameStateManager.SetState("tutorial", m_tutorial);
            m_gameStateManager.SetState("level1", m_level1);
            m_gameStateManager.SetState("level2", m_level2);
            m_gameStateManager.SetState("level3", m_level3);

            m_gameStateManager.PushState("splashScreen");
            base.Initialize();

            for (int i = 0; i < m_scoreList.Count; i++)
            {
                Console.WriteLine(m_scoreList[i].m_level);
                Console.WriteLine(m_scoreList[i].m_time);
                Console.WriteLine(m_scoreList[i].m_deaths);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// constructor for the Level1 GameState state
        /// </summary>
        /// <param name="a_gameStateManager">The manager for the gamestate</param>
        /// <param name="a_screenRes">the resolution for the screen</param>
        public Level1GameState(
            GameStateManager a_gameStateManager,
            Rectangle a_screenRes)
            : base(a_gameStateManager, a_screenRes)
        {    
            LevelIO.LoadLevel("level1.xml", this);
            m_player.m_body.Position = m_playerSpawnLocation;

            m_goal.Position = new Vector2(-2272, 209);
            m_goal.m_body.UserData = "menu";

            m_currentLevel = "Level 1";

            m_levelBoundary = 4100;
        }
Exemplo n.º 3
0
        /// <summary>
        /// constructor for the Level2 Gamestate
        /// </summary>
        /// <param name="a_gameStateManager">The manager for the gamestate</param>
        /// <param name="a_screenRes">the resolution for the screen</param>
        public Level2GameState(
            GameStateManager a_gameStateManager,
            Rectangle a_screenRes)
            : base(a_gameStateManager, a_screenRes)
        {
            LevelIO.LoadLevel("Level2.xml", this);
            m_player.m_body.Position = m_playerSpawnLocation;

            m_goal.Position = new Vector2(359.2854f, 32.14273f); 
            m_goal.m_body.UserData = "menu";

            m_currentLevel = "Level 2";

            m_levelBoundary = 3600;
        }
Exemplo n.º 4
0
        /// <summary>
        /// constructor for the Level2 Gamestate
        /// </summary>
        /// <param name="a_gameStateManager">The manager for the gamestate</param>
        /// <param name="a_screenRes">the resolution for the screen</param>
        public Level3GameState(
            GameStateManager a_gameStateManager,
            Rectangle a_screenRes)
            : base(a_gameStateManager, a_screenRes)
        {
            LevelIO.LoadLevel("Level3.xml", this);
            m_player.m_body.Position = m_playerSpawnLocation;

            m_goal.Position = new Vector2(-663.3053f, 1958.045f);
            m_goal.m_body.UserData = "menu";

            m_currentLevel = "Level 3";

            m_levelBoundary = 3600;
        }
Exemplo n.º 5
0
        /// <summary>
        /// Constructor for level editor gamestate
        /// </summary>
        /// <param name="a_gameStateManager">The Gamestatemanager that manages the level editor</param>
        /// <param name="a_screenRes">the resolution for the screen</param>
        public LevelEditor(
            GameStateManager a_gameStateManager,
            Rectangle a_screenRes)
            : base(a_gameStateManager, a_screenRes)
        {
            m_platformList = new List<Platform>();

            m_playerSpawnLocation = new Vector2(0, 0);
            m_playerSpawnIndicator = new Sprite(m_world, ContentLibrary.platformTexture, new Vector2(10, 50), 0, m_playerSpawnLocation);
            m_playerSpawnIndicator.m_body.BodyType = BodyType.Static;

            m_goalLocation = new Vector2(100, 0);
            m_goalIndicator = new Sprite(m_world, ContentLibrary.platformTexture, new Vector2(100, 100), 0, m_goalLocation);
            m_goalIndicator.m_body.BodyType = BodyType.Static;

            m_camera.EnableTracking = false;
        }
Exemplo n.º 6
0
        public SplashScreen(
            GameStateManager a_gameStateManager,
            Rectangle a_windowRes) 
            : base(a_gameStateManager,
            a_windowRes)
        {
            m_currentLevel = "splashScreen";

            m_background = new Sprite(m_world,
                ContentLibrary.teamLogoTexture,
                new Vector2(
                    ContentLibrary.teamLogoTexture.Width / 2,
                    ContentLibrary.teamLogoTexture.Height/ 2
                    ),
                1,
                new Vector2(0, 0)
                );

            m_background.m_body.BodyType = BodyType.Static;

            m_camera.TrackingBody = m_background.m_body;
        }
Exemplo n.º 7
0
        /// <summary>
        /// Constructor for the Gamestate class
        /// </summary>
        /// <param name="a_gameStateManager">The manager for the gamestate</param>
        /// <param name="a_windowRes">the resolution for the screen</param>
        public GameState(GameStateManager a_gameStateManager, Rectangle a_windowRes)
        {
            m_platformList = new List<Platform>();
            m_particleList = new List<Particle>();

            //Set Resoultion
            m_windowRes = a_windowRes;

            //World
            m_world = new World(new Vector2(0, 0));

            //Gravity
            m_gravity = new Gravity(m_world, new Vector2(0, 1), 7.0f);

            m_gameStateManager = a_gameStateManager;
            m_game = m_gameStateManager.m_game;
            m_camera = new Camera(m_game.GraphicsDevice);

            m_playerSpawnLocation = new Vector2(0, 0);

            //Particle stuff
            m_particleSpawnPosition = new Vector2();
        }
Exemplo n.º 8
0
        public PauseGameState(
            GameStateManager a_gameStateManager,
            Rectangle a_screenRes)
            : base(a_gameStateManager, a_screenRes)
        {
            m_currentLevel = "Pause";

            //GameState Portals
            m_menu = new Sprite
                (
                m_world,
                ContentLibrary.platformTexture,
                new Vector2(150, 110),
                1,
                new Vector2(-25, 450)
                );
            m_menu.m_body.UserData = "exit";
            m_menu.m_body.BodyType = BodyType.Static;
            m_menu.m_body.Rotation = 0;

            m_restart = new Sprite
                (
                m_world,
                ContentLibrary.platformTexture,
                new Vector2(110, 110),
                1,
                new Vector2(250, -200)
                );
            m_restart.m_body.UserData = "restart";
            m_restart.m_body.BodyType = BodyType.Static;
            m_restart.m_body.Rotation = -45;

            m_resume = new Sprite
                (
                m_world,
                ContentLibrary.platformTexture,
                new Vector2(110, 110),
                1,
                new Vector2(-300, -200)
                );
            m_resume.m_body.UserData = "resume";
            m_resume.m_body.BodyType = BodyType.Static;
            m_resume.m_body.Rotation = 45;

            m_text.Add("RESUME");
            m_text.Add("RESTART");
            m_text.Add("MENU");
            m_text.Add("BEST TIMES");

            m_textPos["RESUME"] = new Vector2(-230, -100);
            m_textPos["RESTART"] = new Vector2(140, -100);
            m_textPos["MENU"] = new Vector2(-50, 220);
            m_textPos["BEST TIMES"] = new Vector2(-60, 10);


            //NOTE::Rotation might actually be in radians
            
            m_player.m_body.OnCollision += SetState;

            LevelIO.LoadLevel("Pause.xml", this);

            m_player.m_body.Position = m_playerSpawnLocation;

            m_highScores = new Score[3];
            if (m_gameStateManager.m_game.m_scoreList.Count >= 3)
            {
                m_highScores[0] = m_gameStateManager.m_game.m_scoreList[0];
                m_highScores[1] = m_gameStateManager.m_game.m_scoreList[1];
                m_highScores[2] = m_gameStateManager.m_game.m_scoreList[2];
            }
            else if (m_gameStateManager.m_game.m_scoreList.Count == 2)
            {
                m_highScores[0] = m_gameStateManager.m_game.m_scoreList[0];
                m_highScores[1] = m_gameStateManager.m_game.m_scoreList[1];
                m_highScores[2] = new Score();
            }
            else if (m_gameStateManager.m_game.m_scoreList.Count == 1)
            {
                m_highScores[0] = m_gameStateManager.m_game.m_scoreList[0];
                m_highScores[1] = new Score();
                m_highScores[2] = new Score();
            }
            else
            {
                m_highScores[0] = new Score();
                m_highScores[1] = new Score();
                m_highScores[2] = new Score();
            }

            m_levelBoundary = 600;
        }
Exemplo n.º 9
0
        //
        public MenuGameState(
            GameStateManager a_gameStateManager,
            Rectangle a_screenRes)
            : base(a_gameStateManager, a_screenRes)
        {
            m_exit = new Sprite
                (
                m_world,
                ContentLibrary.platformTexture,
                new Vector2(100, 100),
                1,
                new Vector2(0, 700)
                );
            m_exit.m_body.UserData = "exit";
            m_exit.m_body.BodyType = BodyType.Static;

            m_level1 = new Sprite
                (
                m_world,
                ContentLibrary.platformTexture,
                new Vector2(100, 150),
                1,
                new Vector2(-500, 80)
                );
            m_level1.m_body.UserData = "level1";
            m_level1.m_body.BodyType = BodyType.Static;

            m_level2 = new Sprite
                (
                m_world,
                ContentLibrary.platformTexture,
                new Vector2(100, 150),
                1,
                new Vector2(0, -350)
                );
            m_level2.m_body.UserData = "level2";
            m_level2.m_body.BodyType = BodyType.Static;

            m_level3 = new Sprite
                (
                m_world,
                ContentLibrary.platformTexture,
                new Vector2(100, 150),
                1,
                new Vector2(450, 80)
                );
            m_level3.m_body.UserData = "level3";
            m_level3.m_body.BodyType = BodyType.Static;

            m_text.Add("EXIT");
            m_text.Add("LEVEL1");
            m_text.Add("LEVEL2");
            m_text.Add("LEVEL3");

            m_textPos["EXIT"] = new Vector2(-40, 280);
            m_textPos["LEVEL1"] = new Vector2(-270, 0);
            m_textPos["LEVEL2"] = new Vector2(-45, -145);

            m_textPos["LEVEL3"] = new Vector2(180, 0);
    
            //Camera
            m_camera.Zoom -= 0.2f;

            LevelIO.LoadLevel("Menu.xml", this);
            m_player.m_body.Position = m_playerSpawnLocation;

            m_player.m_body.OnCollision += SetState;

            m_currentLevel = "Menu";

            m_levelBoundary = 800;
        }