WarTornLands.PlayerClasses.Player.LoadContent C# (CSharp) Method

LoadContent() protected method

protected LoadContent ( ) : void
return void
        protected void LoadContent()
        {
            AnimatedDrawer animS = new AnimatedDrawer(Game1.Instance.Content.Load<Texture2D>("sprite/character_64x128"));

            Animation anim = new Animation("walkDown");
            anim.AddFrame(new Rectangle(64 * 1, 0, 64, 128));
            anim.AddFrame(new Rectangle(64 * 2, 0, 64, 128));
            anim.AddFrame(new Rectangle(64 * 1, 0, 64, 128));
            anim.AddFrame(new Rectangle(64 * 3, 0, 64, 128));
            animS.AddAnimation(anim);
            animS.SetCurrentAnimation("walkDown");

            anim = new Animation("walkLeft");
            anim.AddFrame(new Rectangle(64 * 5, 0, 64, 128));
            anim.AddFrame(new Rectangle(64 * 6, 0, 64, 128));
            anim.AddFrame(new Rectangle(64 * 5, 0, 64, 128));
            anim.AddFrame(new Rectangle(64 * 7, 0, 64, 128));
            animS.AddAnimation(anim);

            anim = new Animation("walkRight");
            anim.AddFrame(new Rectangle(64 * 1, 128, 64, 128));
            anim.AddFrame(new Rectangle(64 * 2, 128, 64, 128));
            anim.AddFrame(new Rectangle(64 * 1, 128, 64, 128));
            anim.AddFrame(new Rectangle(64 * 3, 128, 64, 128));
            animS.AddAnimation(anim);

            anim = new Animation("walkUp");
            anim.AddFrame(new Rectangle(64 * 5, 128, 64, 128));
            anim.AddFrame(new Rectangle(64 * 6, 128, 64, 128));
            anim.AddFrame(new Rectangle(64 * 5, 128, 64, 128));
            anim.AddFrame(new Rectangle(64 * 7, 128, 64, 128));
            animS.AddAnimation(anim);

            anim=new Animation("standDown");
            anim.AddFrame(new Rectangle(0,0,64,128));
            animS.AddAnimation(anim);

            anim = new Animation("standLeft");
            anim.AddFrame(new Rectangle(4*64, 0, 64, 128));
            animS.AddAnimation(anim);

            anim = new Animation("standRight");
            anim.AddFrame(new Rectangle(0, 128, 64, 128));
            animS.AddAnimation(anim);

            anim = new Animation("standUp");
            anim.AddFrame(new Rectangle(4*64, 128, 64, 128));
            animS.AddAnimation(anim);

            this.AddModule(animS); /**/

            /*StaticDrawer sd = new StaticDrawer();
            sd.Texture = Game1.Instance.Content.Load<Texture2D>("sprite/potion");
            this.AddModule(sd);/**/
        }

Same methods

Player::LoadContent ( Microsoft.Xna.Framework.Content.ContentManager cm ) : void

Usage Example

Ejemplo n.º 1
0
        /// <summary>
        /// LoadContent wird einmal pro Spiel aufgerufen und ist der Platz, wo
        /// Ihr gesamter Content geladen wird.
        /// </summary>
        protected override void LoadContent()
        {
            // Erstellen Sie einen neuen SpriteBatch, der zum Zeichnen von Texturen verwendet werden kann.
            _spriteBatch = new SpriteBatch(GraphicsDevice);

            _tileSetTexture = Content.Load<Texture2D>(@"grass");
            _treeTexture = Content.Load<Texture2D>("tree");
            _deadTreeTexture = Content.Load<Texture2D>("deadtree");
            _gruselUteTexture = Content.Load<Texture2D>("wildboar");
            _blackHoleTexture = Content.Load<Texture2D>("blackhole");
            _potionTexture = Content.Load<Texture2D>("potion");
            _cestTexture = Content.Load<Texture2D>("Schatztruhe");

            _input = new InputManager(this);
            _interface = new Interface(this);

            _player = new Player(this);
            _parser = new XML_Parser(this);
            _dialogSystem = new DialogSystem(this);
            //_parser.SetFilename("Horst");
            //_parser.SaveText();
            _parser.SetFilename("0");

            //_parser.SetLevel();
            //_parser.SaveLevel();
            try
            {
                _parser.LoadLevel();
                _currentLevel = _parser.GetLevel();
            }
            catch (Exception e)
            {
                _currentLevel = new Level(this);
                int[,] layer0 = new int[,] {
                            {1,1,1,1,1,1,1,1},
                            {1,9,9,9,9,9,9,1},
                            {1,9,9,9,9,9,9,1},
                            {1,9,9,54,111,111,9,1},
                            {1,9,9,9,111,111,9,1},
                            {1,9,9,9,9,54,9,1},
                            {1,9,9,9,9,9,9,1},
                            {1,1,1,1,1,1,1,1}};
                int[,] layer1 = { { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 87 } };
                layer0[1, 5] = 65;
                _currentLevel.AddFloor(layer0);
                _currentLevel.AddCeiling(new int[0, 0]);
            }
            PlayerClasses.CollisionDetector.Setup(_currentLevel);

            this.Components.Add(_input);

            _currentLevel.LoadContent();

            _player.LoadContent(Content);

            // TODO: Verwenden Sie this.Content, um Ihren Spiel-Inhalt hier zu laden
        }