예제 #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()
        {
            //Audio Load
            bkMusic   = Content.Load <Song>("bkMusic");
            death     = Content.Load <SoundEffect>("Wasted");
            shot      = Content.Load <SoundEffect>("Grenade");
            explosion = Content.Load <SoundEffect>("Explosion");
            winner    = Content.Load <SoundEffect>("Winner");

            //Tiles for EndGame Screen
            txGameOver = Content.Load <Texture2D>(@"Tiles/Wasted");
            txwinner   = Content.Load <Texture2D>(@"Tiles/Winner");
            gameOver   = new Rectangle(0, 0, GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height);

            // 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(3, 3, 5));
            // Names of the Tiles
            new SimpleTileLayer(this, backTileNames, tileMap, TileRefs, tileWidth, tileHeight);

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

            //Projectile Service
            Projectile playerProjectile = new Projectile(this, new List <TileRef>()
            {
                new TileRef(7, 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);

            SetColliders(TileType.BLUEBOX);
            SetColliders(TileType.EXIT);

            playerProjectile.AddShot(shot);
            playerProjectile.AddExplosionSound(explosion);

            player.LoadProjectile(playerProjectile);

            //This is the only bit of code done by either of my teammates, this part was done by Conor Flannery
            //Sentry Turret
            List <Tile> found = SimpleTileLayer.getNamedTiles(backTileNames[(int)TileType.GREENBOX]);

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

            for (int i = 0; i < found.Count; i++)
            {
                sentryTurret = new SentryTurret(this, new Vector2(found[i].X * tileWidth, found[i].Y * tileHeight), 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);
                sentryList.Add(sentryTurret);
            }
            //This is the end of the code done by Conor Flannery

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

                projectile.AddShot(shot);
                projectile.AddExplosionSound(explosion);

                sentryList[i].LoadProjectile(projectile);
                sentryList[i].Health = 20;
            }
        }
예제 #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()
        {
            // 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
        }