コード例 #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);
            Services.AddService(Content.Load <Texture2D>(@"Tiles/tank tiles 64 x 64"));

            // 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(6, 3, 2));
            TileRefs.Add(new TileRef(6, 2, 3));
            TileRefs.Add(new TileRef(0, 2, 4));
            // Names fo the Tiles

            new SimpleTileLayer(this, backTileNames, tileMap, TileRefs, tileWidth, tileHeight);
            List <Tile> found = SimpleTileLayer.getNamedTiles(backTileNames[(int)TileType.GREENBOX]);
            // TODO: use this.Content to load your game content here
        }
コード例 #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"));

            // 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(6, 3, 2));
            TileRefs.Add(new TileRef(6, 2, 3));
            TileRefs.Add(new TileRef(0, 2, 4));
            // Names fo the Tiles

            new SimpleTileLayer(this, backTileNames, tileMap, TileRefs, tileWidth, tileHeight);
            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(20, 2, 0),
                    new TileRef(20, 3, 0),
                    new TileRef(20, 4, 0),
                    new TileRef(20, 5, 0),
                    new TileRef(20, 6, 0),
                    new TileRef(20, 7, 0),
                    new TileRef(20, 8, 0),
                }, 64, 64, 0f);
                sentryList.Add(sentryTurret);
            }
        }
コード例 #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()
        {
            //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;
            }
        }
コード例 #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()
        {
            sFont = Content.Load <SpriteFont>("sFont");

            // 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"));

            // Tile References to be drawn on the Map corresponding to the entries in the defined
            // Tile Map
            // "free", "pavement", "blue steel", "green box", "home"
            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));

            // Names fo the Tiles

            new SimpleTileLayer(this, backTileNames, tileMap, TileRefs, tileWidth, tileHeight);
            List <Tile> found = SimpleTileLayer.getNamedTiles(backTileNames[(int)TileType.GREENBOX]);

            Projectile playerBullet = new Projectile(this, new List <TileRef>()
            {
                new TileRef(5, 0, 0)
            },
                                                     new AnimateSheetSprite(this, player.PixelPosition, new List <TileRef>()
            {
                new TileRef(7, 0, 0),
                new TileRef(8, 0, 0),
                new TileRef(0, 0, 0),
                new TileRef(1, 0, 0),
                new TileRef(2, 0, 0)
            }, tileWidth, tileHeight, 1), player.PixelPosition, 1);


            player.LoadProjectile(playerBullet);


            //List<Tile> found = SimpleTileLayer.getNamedTiles("green box");
            // added a senytry gameservice similer to a player. 29/11/17 at 13:44
            for (int i = 0; i < found.Count; i++)
            {
                sentrys = new Sentry(this, new Vector2(found[i].X * tileWidth, found[i].Y * tileHeight), new List <TileRef>()
                {
                    new TileRef(20, 2, 0),
                    new TileRef(20, 3, 0),
                    new TileRef(20, 4, 0),
                    new TileRef(20, 5, 0),
                    new TileRef(20, 6, 0),
                    new TileRef(20, 7, 0),
                    new TileRef(20, 8, 0),
                }, 64, 64, 0f);
                sentryList.Add(sentrys);

                Projectile projectile = new Projectile(this, new List <TileRef>()
                {
                    new TileRef(0, 0, 0)
                },
                                                       new AnimateSheetSprite(this, player.PixelPosition, new List <TileRef>()
                {
                    new TileRef(7, 0, 0),
                    new TileRef(8, 0, 0),
                    new TileRef(0, 0, 0),
                    new TileRef(1, 0, 0),
                    new TileRef(2, 0, 0)
                }, tileWidth, tileHeight, 1), player.PixelPosition, 1);

                sentryList[i].loadProjectile(projectile);
                sentryList[i].Health = 2;
            }

            player.playerCrossHair = new CrossHair(this, new List <TileRef>()
            {
                new TileRef(11, 6, 0)
            }, player.PixelPosition, 1);
            // insert soundEffects and songs!
            bulletExplosion = Content.Load <SoundEffect>("SoundEffects/atari_boom");
            Shooting        = Content.Load <SoundEffect>("SoundEffects/atari_boom2");
            backingTrack    = Content.Load <Song>("Songs/bgm_action_1");
        }
コード例 #5
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"));

            // Tile References to be drawn on the Map corresponding to the entries in the defined
            // Tile Map
            // "free", "pavement", "ground", "blue", "home", "grass" "end"
            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(0, 1, 5));
            TileRefs.Add(new TileRef(0, 4, 6));
            // Names fo the Tiles

            new SimpleTileLayer(this, backTileNames, tileMap, TileRefs, tileWidth, tileHeight);
            List <Tile> found = SimpleTileLayer.getNamedTiles("home");

            new SimpleTileLayer(this, backTileNames, tileMap, TileRefs, tileWidth, tileHeight);
            List <Tile> foundSentry = SimpleTileLayer.getNamedTiles(backTileNames[(int)TileType.GREENBOX]);

            Services.AddService(new TilePlayer(this, new Vector2((int)TileType.HOME), new List <TileRef>()
            {
                new TileRef(15, 2, 0),
                new TileRef(15, 3, 0),
                new TileRef(15, 4, 0),
                new TileRef(15, 5, 0),
                new TileRef(15, 6, 0),
                new TileRef(15, 7, 0),
                new TileRef(15, 8, 0),
            }, 64, 64, 0f));
            SetColliders(TileType.GREENBOX);
            SetColliders(TileType.BLUEBOX);

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

            tilePlayer.AddHealthBar(new HealthBar(tilePlayer.Game, tilePlayer.PixelPosition));

            player = (TilePlayer)Services.GetService(typeof(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);

            player.LoadProjectile(playerProjectile);


            for (int i = 0; i < foundSentry.Count; i++)
            {
                sentryTurret = new Sentry(this, new Vector2(foundSentry[i].X * tileWidth, foundSentry[i].Y * tileHeight), new List <TileRef>()
                {
                    new TileRef(20, 2, 0),
                    new TileRef(20, 3, 0),
                    new TileRef(20, 4, 0),
                    new TileRef(20, 5, 0),
                    new TileRef(20, 6, 0),
                    new TileRef(20, 6, 0),
                    new TileRef(20, 8, 0),
                }, 64, 64, 0);
                sentryList.Add(sentryTurret);
            }

            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);

                sentryList[i].LoadProjectile(projectile);
                sentryList[i].Health = 20;
            }


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

            //Background
            backgroundMusic = Content.Load <Song>(@"Audio/bckGroundMusic");
            MediaPlayer.Play(backgroundMusic);
            MediaPlayer.Volume      = 0.4f;
            MediaPlayer.IsRepeating = true;

            //Sound FX
            sfx[0] = Content.Load <SoundEffect>(@"Audio/Explosion 2"); //Player Shot
            sfx[1] = Content.Load <SoundEffect>(@"Audio/Beep");        //Sentry Shot
            sfx[2] = Content.Load <SoundEffect>(@"Audio/Explosion");   //Projectile Explosion
            sfx[3] = Content.Load <SoundEffect>(@"Audio/Ching");       //Victory
            sfx[4] = Content.Load <SoundEffect>(@"Audio/Error");       //Fail

            //Screens
            victory  = Content.Load <Texture2D>(@"Images/Victory");
            gameOver = Content.Load <Texture2D>(@"Images/GameOver");
        }