예제 #1
0
        public override void LoadContent()
        {
            try
            {
                texture = GameLoop.gameInstance.Content.Load <Texture2D>("Sprites/" + assetName);
            }
            catch (Exception e1)
            {
                try
                {
                    texture = GameLoop.gameInstance.Content.Load <Texture2D>(fullPath);
                }
                catch (Exception e2)
                {
                    try
                    {
                        string p = Path.Combine(layer.level.contentPath, Path.GetFileName(fullPath));
                        //texture = TextureManager.Instance.LoadFromFile(p);
                        texture = TextureManager.Instance.LoadFromFile(Path.Combine(Directory.GetCurrentDirectory(), "Content", "Sprites", assetName + Path.GetExtension(fullPath)));


                        if (texture == null)
                        {
                            throw new Exception();
                        }
                    }
                    catch (Exception e3)
                    {
                        texture = TextureManager.Instance.LoadFromFile(fullPath);
                    }
                }
            }

            if (texture != null)
            {
                origin = new Vector2((float)(texture.Width / 2), (float)(texture.Height / 2));
            }
            else
            {
                DebugLogManager.writeToLogFile(@"Unable to load texture: " + assetName + @" . Using fallback!");
                texture = GameLoop.gameInstance.Content.Load <Texture2D>(@"Sprites/fallback");
            }
            this.ToFixture();

            if (fixture != null)
            {
                fixture.Body.Rotation = rotation;
            }
            if (fixtures != null)
            {
                fixtures[0].Body.Rotation = rotation;
            }
        }
예제 #2
0
 public static Level LoadLevelFile(string levelPath)
 {
     try
     {
         FileStream      file       = FileManager.LoadLevelFile(levelPath);
         BinaryFormatter serializer = new BinaryFormatter();
         Level           level      = (Level)serializer.Deserialize(file);
         file.Close();
         return(level);
     }
     catch (Exception e)
     {
         DebugLogManager.writeToLogFile("LoadLevelFile Exception: " + e.Message);
         return(new Level());
     }
 }
예제 #3
0
        public void loadContentInEditor(GraphicsDeviceManager graphicsM, GraphicsDevice graphics, ContentManager content)
        {
            particleRenderer = new ParticleRenderer(graphicsM);
            particleRenderer.particleRenderer.LoadContent(content);
            this._graphicsM = graphicsM;
            this._contentM  = content;
            Rt = new RenderTarget2D(graphics, graphics.Viewport.Width, graphics.Viewport.Height);

            foreach (LevelObject lo in loList)
            {
                if (lo is DrawableLevelObject)
                {
                    DrawableLevelObject dlo = (DrawableLevelObject)lo;
                    try
                    {
                        dlo.loadContentInEditor(graphics);
                    }
                    catch (Exception e)
                    {
                        DebugLogManager.writeToLogFile("Wasn't able to load " + dlo.name + " in Layer " + this.name);
                    }
                }
                else if (lo is ParticleObject)
                {
                    ParticleObject p = (ParticleObject)lo;
                    particleRenderer.addParticleObjectsInEditor(p, content);
                }
            }

            particleRenderer.initializeParticlesInEditor(content);
            if (Effects == null)
            {
                Effects = new List <EffectObject>();
            }

            foreach (EffectObject eo in Effects)
            {
                //eo.Initialise();
                eo.loadContentInEditor(graphics, content);
            }
        }