Exemplo n.º 1
0
        public void LoadContent(ContentManager contentManager, Level level)
        {
            var info = level.Info;

            MainMap         = level.Map;
            MainMap.X       = 0;
            MainMap.Y       = 0;
            heroEntity.MaxY = MainMap.Height;

            Marshes = MainMap.GetMarshes();
            Pikes   = MainMap.GetPikes();
            //   Back = contentManager.Load<Texture2D>("moutains");

            TextureManager.Initialize(contentManager, "Farmer", "guard");

            foreach (var obstacle in obstacleEntities)
            {
                obstacle.LoadImage(contentManager, info.Graphics.ObstaclesFolder);
            }

            foreach (var lad in Laders)
            {
                if (Constants.LaderTexture == null)
                {
                    Constants.LaderTexture = contentManager.Load <Texture2D>("lader");
                }

                lad.Image = Constants.LaderTexture;
                lad.InvokeLoad();
                //lad.LoadImage(contentManager, "");
            }

            foreach (var monster in MonsterEntities)
            {
                monster.LoadContent(contentManager);

                monster.InitializeAnimationsAsDefault();

                if (CheckMarshes(monster) != null)
                {
                    monster.InMarsh = true;
                }
            }

            foreach (var fire in FiringMonsterEntities)
            {
                fire.LoadContent(contentManager);

                //fire.InitializeAnimationsAsDefault();
                if (CheckMarshes(fire) != null)
                {
                    fire.InMarsh = true;
                }
            }

            foreach (var marsh in Marshes)
            {
                marsh.LoadContent(contentManager, "marsh/earth");
            }

            foreach (var trilad in TriangularLaders)
            {
                trilad.LoadImage(contentManager, "TriLader");
            }

            heroEntity.LoadImage(contentManager, info.Graphics.HeroFolder + "protagonist");

            Background.Load(contentManager, info.Graphics.BackgroundElementsFolder, 16);

            // PlaceOnTop(heroEntity, Floor);

            foreach (var weapon in HeroWeapons)
            {
                weapon.LoadImage(contentManager, "gun");
                weapon.BulletsImage   = contentManager.Load <Texture2D>("bullet");
                weapon.RechargeEffect = new MySoundEffect(contentManager, "sounds/recharge");
                weapon.ShootingEffect = new MySoundEffect(contentManager, "sounds/shoot");
            }

            LastContentManager = contentManager;
            LastLevel          = level;

            heroEntity.LoadContent(contentManager, "hero/");

            heroEntity.InitializeAnimationsAsDefault();

            CurrentCoinTexture    = contentManager.Load <Texture2D>("monster/Coin");
            CurrentCoinSourceRect = new Rectangle(0, 0, 15, 16);
            CoinAnimation         = Animation.CreateFromPhoto(CurrentCoinTexture, heroEntity, false, false, 15, 16, 7, 1000, 7, true);
        }