Пример #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);

            gameState = GameState.menu;

            horizontalWall = Content.Load<Texture2D>(GameGraphics.HWALL);
            verticalWall = Content.Load<Texture2D>(GameGraphics.VWALL);
            textFont = Content.Load<SpriteFont>("Fonts/gamefont");

            // TODO: use this.Content to load your game content here
            Gru = new PlayableCharacter
                    (
                    Content.Load<Texture2D>(GameGraphics.GRU),
                    new Vector2(labyrinth.GetTile(START_X, START_Y).GetPosition().X, labyrinth.GetTile(START_X, START_Y).GetPosition().Y),
                    labyrinth.GetTile(START_X, START_Y)
                    );

            ship = new ExitShip(Content.Load<Texture2D>(GameGraphics.SHIP), labyrinth.GetRandomTile());

            policeList = new List<Police>();

            //L'entrée du téléporteur
            warpEntrance = Content.Load<Texture2D>(GameGraphics.WARP1);
            warpEntrancePos = new Vector2(labyrinth.GetTile(7, 4).GetPosition().X - Tile.TAILLE_LIGNE, labyrinth.GetTile(7, 4).GetPosition().Y + Tile.TAILLE_LIGNE);

            //Les sorties du téléporteur
            for (int i = 0; i < warpExit.Length; i++)
            {
                warpExit[i] = Content.Load<Texture2D>(GameGraphics.WARP2);
            }

            warpExitPos[0] = new Vector2(labyrinth.GetTile(0, 0).GetPosition().X, labyrinth.GetTile(0, 0).GetPosition().Y);
            warpExitPos[1] = new Vector2(labyrinth.GetTile(Labyrinth.WIDTH - 1, 0).GetPosition().X, labyrinth.GetTile(Labyrinth.WIDTH - 1, 0).GetPosition().Y);
            warpExitPos[2] = new Vector2(labyrinth.GetTile(0, Labyrinth.HEIGHT - 1).GetPosition().X, labyrinth.GetTile(0, Labyrinth.HEIGHT - 1).GetPosition().Y);
            warpExitPos[3] = new Vector2(labyrinth.GetTile(Labyrinth.WIDTH - 1, Labyrinth.HEIGHT - 1).GetPosition().X, labyrinth.GetTile(Labyrinth.WIDTH - 1, Labyrinth.HEIGHT - 1).GetPosition().Y);

            labyrinth.SpawnMoney(Content.Load<Texture2D>(GameGraphics.MONEY));

            currentPowerUp = CreateNewPowerUP();
            projectilesList = new List<Projectile>();

            gamepad = new Gamepad();
            gamepad.RegisterCommand(Buttons.DPadUp, new GruMoveUp(Gru));
            gamepad.RegisterCommand(Buttons.DPadDown, new GruMoveDown(Gru));
            gamepad.RegisterCommand(Buttons.DPadLeft, new GruMoveLeft(Gru));
            gamepad.RegisterCommand(Buttons.DPadRight, new GruMoveRight(Gru));
            gamepad.RegisterCommand(Buttons.LeftShoulder, new SpawnMinions(this));
            gamepad.RegisterCommand(Buttons.RightShoulder, new GruShoot(this));
            gamepad.RegisterCommand(Buttons.Back, new BackToMenu(this));
            gamepad.RegisterCommand(Buttons.Start, new PauseGame(this));
        }