示例#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);

            mFont = Content.Load <SpriteFont>("Fonts/mainFont");

            menu = new Menu(mFont, graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight);

            map = new LevelMap(Content, "Maps/map");

            player     = new Player(map);
            map.Player = player;

            Dictionary <string, Animation> dicAnim = new Dictionary <string, Animation>
            {
                { "Walking_Down", new Animation(Content.Load <Texture2D>("Images/WalkingDown"), 3) },
                { "Walking_Left", new Animation(Content.Load <Texture2D>("Images/WalkingLeft"), 3) },
                { "Walking_Right", new Animation(Content.Load <Texture2D>("Images/WalkingRight"), 3) },
                { "Walking_Up", new Animation(Content.Load <Texture2D>("Images/WalkingUp"), 3) }
            };

            player.Init(dicAnim);

            uiItems = new List <UIItem>();

            UIItem parchmentUI = new UIItem(Content.Load <Texture2D>("Images/Parchment"), EItemType.PARCHMENT);

            // deactivate parchementUI it will be activated when the parchment will be picked
            parchmentUI.IsActive = false;

            UIItem key1UI = new UIItem(Content.Load <Texture2D>("Images/Key1"), EItemType.KEY_1);

            // deactivate key1UI it will be activated when the key_1 will be picked
            key1UI.IsActive = false;
            key1UI.Position = new Vector2(0, parchmentUI.Bounds.Bottom + 20);

            UIItem key2UI = new UIItem(Content.Load <Texture2D>("Images/Key2"), EItemType.KEY_2);

            // deactivate key2UI it will be activated when the object_2 will be picked
            key2UI.IsActive = false;
            key2UI.Position = new Vector2(0, key1UI.Bounds.Bottom + 20);

            uiItems.Add(parchmentUI);
            uiItems.Add(key1UI);
            uiItems.Add(key2UI);

            dialogueUIText = new UIText(mFont)
            {
                Position = new Vector2(0, graphics.PreferredBackBufferHeight - 50),
                IsActive = false,
                Text     = "..."
            };

            victoryText = new UIText(mFont)
            {
                IsActive  = false,
                Text      = "VICTORY",
                TextColor = Color.Red
            };

            victoryText.CenterOnScreen(graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight);

            Camera.Instance = new Camera(GraphicsDevice.Viewport, new Rectangle(0, 0, graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight));
            Camera.Init(Vector2.Zero, map.Bounds);

            InitGame();
        }