public override void Initialize(World world) { _scenarioEntity = world.CreateEntity(); _lua.LoadCLRPackage(); var characters = new Characters(); _lua["Characters"] = characters; var scenario = new Scenario(); _lua["Scenario"] = scenario; _lua.DoFile(_startScript); if (_lua.GetString("Background") != "") { _backgroundSprite = new SpriteComponent(_content.GetType().GetProperty(_lua.GetString("Background")).GetValue(_content) as Texture2D); _backgroundSprite.IsBackground = true; _scenarioEntity.Attach(_backgroundSprite); } // Create character's entity foreach (var chr in characters.Pool) { var name = chr.Value.Name; var spritePath = chr.Value.SpritePath; _l.Debug(String.Format("Add chr: name {0}, sprite {1}", name, spritePath)); _characterEntities[name] = world.CreateEntity(); var spriteComponent = new SpriteComponent(_content.GetType().GetProperty(spritePath).GetValue(_content) as Texture2D); // TODO: calculate position according to attributes spriteComponent.Position = new Rectangle(150, 30, _content.ChrKaren.Width / 2, _content.ChrKaren.Height / 2); spriteComponent.Depth = 0.0f; _characterSprites.Add(name, spriteComponent); _characterEntities[name].Attach(spriteComponent); } _currentNode = scenario.Start; // TODO: check node type _state = State.Dialog; _ui.IsDialogBackgroundVisible = true; }