예제 #1
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);
            Services.AddService(spriteBatch);

            // Load in the tile sheet.
            Texture2D tx = Content.Load <Texture2D>(@"Tiles/tank tiles 64 x 64");

            Services.AddService(tx);

            // Load in victory and game over textures.
            victory = Content.Load <Texture2D>(@"Winter Game Sprites/Victory");

            gameOver = Content.Load <Texture2D>(@"Winter Game Sprites/Game Over Edited");

            // Create font for the timer.
            timerFont = Content.Load <SpriteFont>("timerFont");

            // Load Sound effects
            playerFire      = Content.Load <SoundEffect>(@"Winter Game Sound Effects Wave/PlayerFire");
            sentryExplosion = Content.Load <SoundEffect>(@"Winter Game Sound Effects Wave/SentryExplosion");

            victoryFanfare = Content.Load <SoundEffect>(@"Winter Game Sound Effects Wave/TanksForPlaying");

            #region Load Tile Images
            // Tile References to be drawn on the Map corresponding to the entries in the defined
            // Tile Map
            // "crates", "pavement", "red water", "sentry", "home", "exit", "skull", locked".
            TileRefs.Add(new TileRef(11, 1, 0));
            TileRefs.Add(new TileRef(3, 3, 1));
            TileRefs.Add(new TileRef(0, 9, 0));
            TileRefs.Add(new TileRef(6, 2, 3));
            TileRefs.Add(new TileRef(0, 2, 4));
            TileRefs.Add(new TileRef(1, 2, 0));
            TileRefs.Add(new TileRef(6, 11, 0));
            TileRefs.Add(new TileRef(5, 3, 0));
            // Names for the Tiles

            new SimpleTileLayer(this, backTileNames, tileMap, TileRefs, tileWidth, tileHeight);
            #endregion

            // I haven't used the following line of code later on.
            List <Tile> found = SimpleTileLayer.GetNamedTiles("sentry");

            #region Load and Play BGM.
            // Load Background Music.
            this.backgroundMusic = Content.Load <Song>(@"Winter Game Music/Metal Fox");

            // Set volume.
            MediaPlayer.Volume      = 0.0f;
            MediaPlayer.IsRepeating = true;
            #endregion

            // TODO: use this.Content to load your game content here
        }
예제 #2
0
        private Vector2 ChooseRandomTile()
        {
            List <Tile> groundTiles = SimpleTileLayer.GetNamedTiles("ground");

            Vector2 randomTilePosition = new Vector2(
                groundTiles[Camera.random.Next(0, groundTiles.Count)].X * FrameWidth,
                groundTiles[Camera.random.Next(0, groundTiles.Count)].Y * FrameHeight);

            return(randomTilePosition);
        }
예제 #3
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);
            Services.AddService(spriteBatch);


            //Initialize a 17 second timer for the loading screen.
            float timer = 17;



            Song      startVoice = Content.Load <Song>(@"Winter Game Sounds/ballsofsteel");
            Texture2D txCoin     = Content.Load <Texture2D>(@"Winter Game Sprites/Insert Coin");

            Services.AddService(txCoin);



            //Trying to get the loading screen and the startup music to activate at the same time.
            //while under a 17 second timer (the length of the sound).
            if (timer <= 17)
            {
                //Loads the loading screen and proceeds to play the startup music.
                Song      startSong = Content.Load <Song>(@"Winter Game Sounds/ps_1");
                Texture2D txLoad    = Content.Load <Texture2D>(@"Winter Game Sprites/Loading Screen");
                Services.AddService(txLoad);



                //Set volume.
                MediaPlayer.Volume = 0.5f;
            }


            //When the loading screen is finished, this should load the game.
            else if (timer >= 17)
            {
                Services.AddService(Content.Load <Texture2D>(@"Tiles/tank tiles 64 x 64"));
            }



            // Create font for the timer.
            timerFont = Content.Load <SpriteFont>("timerFont");



            // Tile References to be drawn on the Map corresponding to the entries in the defined
            // Tile Map
            // "free", "pavement", "ground", "blue", "home"
            TileRefs.Add(new TileRef(4, 2, 0));
            TileRefs.Add(new TileRef(3, 3, 1));
            TileRefs.Add(new TileRef(0, 9, 0));
            TileRefs.Add(new TileRef(6, 2, 3));
            TileRefs.Add(new TileRef(0, 2, 4));
            // Names for the Tiles

            new SimpleTileLayer(this, backTileNames, tileMap, TileRefs, tileWidth, tileHeight);
            List <Tile> found = SimpleTileLayer.GetNamedTiles("green box");
            // TODO: use this.Content to load your game content here
        }
예제 #4
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);
            Services.AddService(spriteBatch);
            Services.AddService(Content.Load <Texture2D>(@"Tiles/tank tiles 64 x 64"));
            Services.AddService(Content.Load <SpriteFont>(@"Font"));

            // Tile References to be drawn on the Map corresponding to the entries in the defined
            // Tile Map
            // "free", "pavement", "ground", "blue", "home", "exit"
            TileRefs.Add(new TileRef(4, 2, 0));
            TileRefs.Add(new TileRef(3, 3, 1));
            TileRefs.Add(new TileRef(6, 3, 2));
            TileRefs.Add(new TileRef(6, 2, 3));
            TileRefs.Add(new TileRef(0, 2, 4));
            TileRefs.Add(new TileRef(1, 2, 5));

            // Names fo the Tiles
            new SimpleTileLayer(this, backTileNames, tileMap, TileRefs, tileWidth, tileHeight);

            TilePlayer player = Services.GetService <TilePlayer>();

            Projectile playerProjectile = new Projectile(this, new List <TileRef>()
            {
                new TileRef(8, 0, 0)
            },
                                                         new AnimateSheetSprite(this, player.PixelPosition, new List <TileRef>()
            {
                new TileRef(0, 0, 0),
                new TileRef(1, 0, 1),
                new TileRef(2, 0, 2)
            }, 64, 64, 0), player.PixelPosition, 1);

            playerProjectile.AddFireSound(shoot);
            playerProjectile.AddExplosionSound(explosion);
            player.LoadProjectile(playerProjectile);

            List <Tile> greenTiles = SimpleTileLayer.GetNamedTiles("green");

            //sentry sprite
            for (int i = 0; i < greenTiles.Count; i++)
            {
                TileSentry sentry = new TileSentry(this, new Vector2(greenTiles[i].X * 64, greenTiles[i].Y * 64), new List <TileRef>()
                {
                    new TileRef(21, 2, 0),
                    new TileRef(21, 3, 0),
                    new TileRef(21, 4, 0),
                    new TileRef(21, 5, 0),
                    new TileRef(21, 6, 0),
                    new TileRef(21, 7, 0),
                    new TileRef(21, 8, 0),
                }, 64, 64, 0f);
                sentries.Add(sentry);
            }

            for (int i = 0; i < sentries.Count; i++)
            {
                Projectile projectile = new Projectile(this, new List <TileRef>()
                {
                    new TileRef(8, 0, 0)
                },
                                                       new AnimateSheetSprite(this, sentries[i].PixelPosition, new List <TileRef>()
                {
                    new TileRef(0, 0, 0),
                    new TileRef(1, 0, 1),
                    new TileRef(2, 0, 2)
                }, 64, 64, 0), sentries[i].PixelPosition, 1);

                projectile.AddFireSound(shoot);
                projectile.AddExplosionSound(explosion);
                sentries[i].LoadProjectile(projectile);
                sentries[i].Health = 20;
            }


            // TODO: use this.Content to load your game content here
        }