コード例 #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()
        {
            // TODO: Add your initialization logic here
            new Camera(this, Vector2.Zero,
                       new Vector2(tileMap.GetLength(1) * tileWidth, tileMap.GetLength(0) * tileHeight));
            new InputEngine(this);

            //Player Service
            Services.AddService(new TilePlayer(this, new Vector2(64, 128), 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));

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

            tilePlayer.AddHealthBar(new HealthBar(tilePlayer.Game, tilePlayer.PixelPosition));
            SetColliders(TileType.BLUEBOX);

            player = (TilePlayer)Services.GetService(typeof(TilePlayer));

            base.Initialize();
        }
コード例 #2
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()
        {
            explosion = Content.Load <SoundEffect>("SoundFiles/Explosion");
            shoot     = Content.Load <SoundEffect>("SoundFiles/TankShot");

            backgroundAudio = Content.Load <Song>("SoundFiles/Battle_in_the_winter");
            gameOver        = Content.Load <Song>("SoundFiles/Game_Over");
            winner          = Content.Load <Song>("SoundFiles/Winner");

            gameOverScreen = Content.Load <Texture2D>(@"Game-Over");
            youWinScreen   = Content.Load <Texture2D>(@"YouWin");
            // TODO: Add your initialization logic here
            new Camera(this, Vector2.Zero,
                       new Vector2(tileMap.GetLength(1) * tileWidth, tileMap.GetLength(0) * tileHeight));
            new InputEngine(this);
            Services.AddService(new TilePlayer(this, new Vector2(64, 128), 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));
            TilePlayer tilePlayer = Services.GetService <TilePlayer>();

            tilePlayer.AddHealthBar(new HealthBar(tilePlayer.Game, tilePlayer.PixelPosition));
            SetColliders(TileType.GROUND);
            SetColliders(TileType.BLUEBOX);
            SetColliders(TileType.GREEN);
            base.Initialize();
        }