MyPolarBear.GameObjects.PolarBear.LoadContent C# (CSharp) Method

LoadContent() public method

public LoadContent ( ) : void
return void
        public override void LoadContent()
        {
            //Texture = ContentManager.GetTexture("IceWalkingRight");

            Animation ani = new Animation(ContentManager.GetTexture("UrsoWalkingRight"), 2, 8, 0, true, SpriteEffects.None);
            mAnimator.Animations.Add("NormalWalkRight", ani);

            ani = new Animation(ContentManager.GetTexture("UrsoWalkingRight"), 2, 8, 0, true, SpriteEffects.FlipHorizontally);
            mAnimator.Animations.Add("NormalWalkLeft", ani);

            ani = new Animation(ContentManager.GetTexture("UrsoWalkingFront"), 5, 8, 0, true, SpriteEffects.None);
            mAnimator.Animations.Add("NormalWalkFront", ani);

            ani = new Animation(ContentManager.GetTexture("UrsoWalkingBack"), 5, 8, 0, true, SpriteEffects.None);
            mAnimator.Animations.Add("NormalWalkBack", ani);

            ani = new Animation(ContentManager.GetTexture("IceWalkingRight"), 5, 8, 0, true, SpriteEffects.None);
            mAnimator.Animations.Add("IceWalkRight", ani);

            ani = new Animation(ContentManager.GetTexture("IceWalkingRight"), 5, 8, 0, true, SpriteEffects.FlipHorizontally);
            mAnimator.Animations.Add("IceWalkLeft", ani);

            ani = new Animation(ContentManager.GetTexture("IceWalkingFront"), 4, 8, 0, true, SpriteEffects.None);
            mAnimator.Animations.Add("IceWalkFront", ani);

            ani = new Animation(ContentManager.GetTexture("IceWalkingBack"), 4, 8, 0, true, SpriteEffects.None);
            mAnimator.Animations.Add("IceWalkBack", ani);

            ani = new Animation(ContentManager.GetTexture("FireWalkingRight"), 4, 8, 0, true, SpriteEffects.None);
            mAnimator.Animations.Add("FireWalkRight", ani);

            ani = new Animation(ContentManager.GetTexture("FireWalkingRight"), 4, 8, 0, true, SpriteEffects.FlipHorizontally);
            mAnimator.Animations.Add("FireWalkLeft", ani);

            ani = new Animation(ContentManager.GetTexture("FireWalkingFront"), 5, 8, 0, true, SpriteEffects.None);
            mAnimator.Animations.Add("FireWalkFront", ani);

            ani = new Animation(ContentManager.GetTexture("FireWalkingBack"), 5, 8, 0, true, SpriteEffects.None);
            mAnimator.Animations.Add("FireWalkBack", ani);

            bMoving = false;
            mAnimator.PlayAnimation("NormalWalkRight", false);

            base.LoadContent();

            CollisionBox = new Rectangle(CollisionBox.X, CollisionBox.Y, 25, 25);
        }

Usage Example

Beispiel #1
0
        public void LoadContent()
        {
            LoadLevel("levelforest");

            UpdateKeeper.getInstance().updateAll(new GameTime());
            AGrid.GetInstance().setLevel(UpdateKeeper.getInstance().getLevelElements());

            polarBear = new PolarBear(new Vector2(-1950, 1800));
            ScreenManager.camera.FocusEntity = polarBear;
            forestBoss = new Boss(new Vector2(0, -1500));
            forestBoss.LoadContent();
            polarBear.LoadContent();
            UpdateKeeper.getInstance().addEntity(polarBear);
            DrawKeeper.getInstance().addEntity(polarBear);
            UpdateKeeper.getInstance().addEntity(forestBoss);
            DrawKeeper.getInstance().addEntity(forestBoss);

            Enemy ene;

            for (int i = 0; i < maxEnemies; i++)
            {
                ene = new Enemy(new Vector2(random.Next(350, 400), random.Next(350, 400)));
                ene.Velocity = new Vector2(random.Next(1, 10), random.Next(1, 10));
                ene.CurrentState = Enemy.State.Evil;
                ene.LoadContent();
                UpdateKeeper.getInstance().addEntity(ene);
                DrawKeeper.getInstance().addEntity(ene);
            }

            for (int i = 0; i < bossMinions; i++)
            {
                ene = new Enemy(new Vector2(random.Next(-200, 200), random.Next(-1500, -1000)));
                ene.Velocity = new Vector2(0, 0);
                ene.CurrentState = Enemy.State.Evil;
                ene.LoadContent();
                UpdateKeeper.getInstance().addEntity(ene);
                DrawKeeper.getInstance().addEntity(ene);
            }

            Animal tiger = new Animal(new Vector2(-1750, 1300), Animal.Types.Tiger, Animal.Genders.Male);
            tiger.LoadContent();
            UpdateKeeper.getInstance().addEntity(tiger);
            DrawKeeper.getInstance().addEntity(tiger);

            tiger = new Animal(new Vector2(1700, 300), Animal.Types.Tiger, Animal.Genders.Female);
            tiger.LoadContent();
            UpdateKeeper.getInstance().addEntity(tiger);
            DrawKeeper.getInstance().addEntity(tiger);

            Animal lion = new Animal(new Vector2(1900, 1900), Animal.Types.Lion, Animal.Genders.Male);
            lion.LoadContent();
            UpdateKeeper.getInstance().addEntity(lion);
            DrawKeeper.getInstance().addEntity(lion);

            lion = new Animal(new Vector2(-1300, -1650), Animal.Types.Lion, Animal.Genders.Female);
            lion.LoadContent();
            UpdateKeeper.getInstance().addEntity(lion);
            DrawKeeper.getInstance().addEntity(lion);

            Animal panther = new Animal(new Vector2(-550, 1350), Animal.Types.Panther, Animal.Genders.Male);
            panther.LoadContent();
            UpdateKeeper.getInstance().addEntity(panther);
            DrawKeeper.getInstance().addEntity(panther);

            panther = new Animal(new Vector2(1900, -1900), Animal.Types.Panther, Animal.Genders.Female);
            panther.LoadContent();
            UpdateKeeper.getInstance().addEntity(panther);
            DrawKeeper.getInstance().addEntity(panther);
        }