public NPC(Texture2D texture, Dictionary<AnimationKey, Animation> animations, IEContentManager content) : base(texture, animations) { speakingRadius = 80f; dialog = new DialogComponent(content); dialog.Hide(); }
public Engine(GraphicsDeviceManager Graphics) { services = new ServiceContainer(); services.AddService(typeof(IGraphicsDeviceService), Graphics); services.AddService(typeof(IGraphicsDeviceManager), Graphics); this.graphicsDevice = Graphics.GraphicsDevice; content = new IEContentManager(Services); spriteBatch = new SpriteBatch(GraphicsDevice); this.graphicsDevice = GraphicsDevice; }
public TextBox(SpriteFont spriteFont, IEContentManager Content, SpriteBatch spriteBatch) { this.spriteFont = spriteFont; this.content = Content; textboxTexture = Content.Load<Texture2D>("Content/GUI/textbox"); cursor = Content.Load<Texture2D>("Content/GUI/cursor"); blink = false; text = ""; this.Visible = true; this.Enabled = true; this.TabStop = true; this.HasFocus = false; this.spriteBatch = spriteBatch; }
public DialogComponent(IEContentManager content) { this.content = content; }
public DialogComponent(IEContentManager content, string textureFileName) { this.content = content; this.filename = textureFileName; }
// loads the tiles from xml-file generated by TileMapEditor TODO: Content pipeline public TileLoader(string filename, IEContentManager content) { this.content = content; list = new TileList(); input = new TInput(); XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(filename); //TODO: foreach (XmlNode node in xmlDoc.DocumentElement.ChildNodes) // tilesetFile nodes { //TODO Make tilesets if (node.Name == "tiles") // if node is <tiles> { foreach (XmlNode imageTileNode in node.ChildNodes) // <imageTiles> { int id = Int32.Parse(imageTileNode.Attributes["id"].Value); int width = Int32.Parse(imageTileNode.Attributes["width"].Value); int height = Int32.Parse(imageTileNode.Attributes["height"].Value); foreach (XmlNode imageTileNodes in imageTileNode.ChildNodes) { if (imageTileNodes.Name == "image") { string file = imageTileNodes.Attributes["file"].Value; string[] contentName = file.Split('.'); try { file = contentName[0]; } catch { throw new Exception("Invalid picture name at " + file); } texture = content.Load<Texture2D>("Content/images/" + contentName[0]); tile = new Tile(texture,id); list.Add(tile); } //TODO Optimize tilesets if (imageTileNodes.Name == "tilesetImage") { string file = imageTileNodes.Attributes["file"].Value; string[] contentName = file.Split('.'); try { file = contentName[0]; } catch { throw new Exception("Invalid picture name at " + file); } //Loads the whole texture. for optimizing just load the tileset //Once then use the same texture in all tiles texture = content.Load<Texture2D>("Content/images/" + contentName[0]); int x = Int32.Parse(imageTileNodes.Attributes["posX"].Value); int y = Int32.Parse(imageTileNodes.Attributes["posY"].Value); Rectangle tilesetPart = new Rectangle(x, y, width, height); tile = new Tile(texture, id, tilesetPart); tile.IsPartOfTileset = true; list.Add(tile); } } //TODO: Check for bugs //Load nulltiles with collision if (imageTileNode.Name == "nullTile") { foreach (XmlNode imageTileNodes in imageTileNode.ChildNodes) { if (imageTileNodes.Name == "collision") { string collision = imageTileNodes.Attributes["area"].Value; if (collision != "none") { tile = new Tile(CollisionType.Unpassable); } else { tile = new Tile(CollisionType.Passable); } tile.TileID = id; list.Add(tile); } } } } } } }
// If texture is null, we should load the texture with file name given // if filename is null, then there is something wrong TODO: fix that bug public void Load(IEContentManager content) { texture = content.Load<Texture2D>(filename); }
// Initializes the engine public static void SetupEngine(IGraphicsDeviceService GraphicsDeviceService) { // Setup GraphicsDevice and SpriteBatch Engine.GraphicsDevice = GraphicsDeviceService.GraphicsDevice; Engine.SpriteBatch = new SpriteBatch(GraphicsDeviceService.GraphicsDevice); Engine.Services = new IEServiceContainer(); Engine.Services.AddService(typeof(IGraphicsDeviceService), GraphicsDeviceService); Engine.Content = new IEContentManager(Services); // Setup background screen BackgroundScreen = new GameScreen("Engine.BackgroundScreen"); BackgroundScreen.OverrideUpdateBlocked = false; BackgroundScreen.OverrideDrawBlocked = true; BackgroundScreen.OverrideInputBlocked = false; DefaultScreen = BackgroundScreen; Engine.IsInitialized = true; blur = new GaussianBlur(Engine.GraphicsDevice.Viewport.Width, Engine.GraphicsDevice.Viewport.Height); }
// Initializes the engine public static void SetupEngine(IGraphicsDeviceService GraphicsDeviceService) { // Setup the GraphicsDevice and SpriteBatch Engine.GraphicsDevice = GraphicsDeviceService.GraphicsDevice; Engine.SpriteBatch = new SpriteBatch(GraphicsDeviceService.GraphicsDevice); Engine.IsInitialized = true; // Setup the service container and add the IGraphicsDeviceService to it Engine.Services = new IEServiceContainer(); Engine.Services.AddService(typeof(IGraphicsDeviceService), GraphicsDeviceService); // Setup the content manager using the service container Engine.Content = new IEContentManager(Services); BackgroundScreen = new GameScreen("Engine.BackgroundScreen"); BackgroundScreen.OverrideUpdateBlocked = true; BackgroundScreen.OverrideDrawBlocked = true; BackgroundScreen.OverrideInputBlocked = true; // Set the default screen to the background screen so new screens will // use it automatically unless told otherwise DefaultScreen = BackgroundScreen; }