Пример #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()
        {
            initialized[(int)gameState] = true;
            if (gameState == GameState.INITIALIZE)
            {
                LoadContent();
                gameState = GameState.TITLE;
            }

            if (gameState == GameState.SPLASHSCREEN)
            {
            }
            else if (gameState == GameState.TITLE)
            {
                gameTitle  = new ButtonString();
                comment    = new ButtonString();
                playButton = new ButtonString();
                quitButton = new ButtonString();
            }
            else if (gameState == GameState.PLAYING)
            {
                GridManager.Initialize(20, 15);

                snowballs = new List <Snowball>();

                contestantSpawnTime = 0;
                spawnTime           = 3.0f;
                contestants         = new List <DareContestant>();

                snowman = new Snowman();

                effects = new List <Effect>();

                furthestSnowFall = new SnowFall(SnowDepth.FURTHEST);
                farSnowFall      = new SnowFall(SnowDepth.FAR);
                nearSnowFall     = new SnowFall(SnowDepth.NEAR);
                nearestSnowFall  = new SnowFall(SnowDepth.NEAREST);

                Level   = 0;
                levelUp = false;

                EffectBank.Initialize();
            }
            else if (gameState == GameState.PAUSED)
            {
                menuLabel           = new ButtonString();
                resumeButton        = new ButtonString();
                quitFromPauseButton = new ButtonString();
            }
            else if (gameState == GameState.GAMEOVER)
            {
                gameOverLabel          = new ButtonString();
                scoreLabel             = new ButtonString();
                quitFromGameOverButton = new ButtonString();
            }

            base.Initialize();
        }
Пример #2
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            loaded[(int)gameState] = true;
            if (gameState == GameState.INITIALIZE)
            {
                // Create a new SpriteBatch, which can be used to draw textures.
                spriteBatch = new SpriteBatch(GraphicsDevice);
                gameFont    = Content.Load <SpriteFont>("Spritefonts/SpriteFont1");
            }

            if (gameState == GameState.SPLASHSCREEN)
            {
            }
            else if (gameState == GameState.TITLE)
            {
                gameTitle.Initialize(gameFont, "KILL THE SNOWMAN", new Vector2(WINDOW_WIDTH / 2, WINDOW_HEIGHT / 2 - 70));
                gameTitle.scale = 2.0f;
                comment.Initialize(gameFont, "Hey, Snowman is a\ngreat theme, idiot!", new Vector2(WINDOW_WIDTH * 4 / 5, WINDOW_HEIGHT * 3 / 4));
                comment.rotation = 0.12f;
                comment.scale    = 0.5f;
                playButton.Initialize(gameFont, "Play", new Vector2(WINDOW_WIDTH / 2, WINDOW_HEIGHT / 2));
                quitButton.Initialize(gameFont, "Quit", new Vector2(WINDOW_WIDTH / 2, WINDOW_HEIGHT / 2 + 50));
            }
            else if (gameState == GameState.PLAYING)
            {
                Snowball.LoadContent(Content);

                snowman.LoadContent(Content, "snowman_sheet");

                //snowballThrowSound = Content.Load<SoundEffect>("Audio/ThrowSnowball");

                furthestSnowFall.LoadContent(Content, "snowflake_01");
                farSnowFall.LoadContent(Content, "snowflake_01");
                nearSnowFall.LoadContent(Content, "snowflake_01");
                nearestSnowFall.LoadContent(Content, "snowflake_01");

                EffectBank.AddEffect(Content, "bloodeffect_01", 4, 1, 16);
                EffectBank.AddEffect(Content, "darecontestant_death", 8, 1, 24);
            }
            else if (gameState == GameState.PAUSED)
            {
                menuLabel.Initialize(gameFont, "Paused", new Vector2(WINDOW_WIDTH / 2, WINDOW_HEIGHT / 2 - 60));
                menuLabel.scale = 1.5f;
                resumeButton.Initialize(gameFont, "Play", new Vector2(WINDOW_WIDTH / 2, WINDOW_HEIGHT / 2));
                quitFromPauseButton.Initialize(gameFont, "Menu", new Vector2(WINDOW_WIDTH / 2, WINDOW_HEIGHT / 2 + 50));
            }
            else if (gameState == GameState.GAMEOVER)
            {
                gameOverLabel.Initialize(gameFont, "Game Over", new Vector2(WINDOW_WIDTH / 2, WINDOW_HEIGHT / 2 - 110));
                gameOverLabel.scale = 1.5f;
                scoreLabel.Initialize(gameFont, "Level: " + Level.ToString() + "\nSnowballs Thrown: " + snowman.SnowballsThrown.ToString() + "\nDownvotes Thwarted: " +
                                      snowman.KillCount.ToString(), new Vector2(WINDOW_WIDTH / 2, WINDOW_HEIGHT / 2));
                quitFromGameOverButton.Initialize(gameFont, "Menu", new Vector2(WINDOW_WIDTH / 2, WINDOW_HEIGHT / 2 + 100));
            }
        }