protected override void OnUpdate(GameTime gameTime, IEnumerable <ComponentUpdateResults> results) { if (elapsed < FADEIN_TIME) { elapsed += gameTime.ElapsedGameTime.Milliseconds; if (elapsed > FADEIN_TIME) { MapComponent mapComponent = Owner.FirstComponentOfType <MapComponent>(); mapComponent.Initialize(); // Aloitetaan komponentin eventtien kuuntelu. mapComponent.MapFinished += mapComponent_MapFinished; mapComponent.SceneFinished += mapComponent_SceneFinished; } } }
/// <summary> /// Luo uuden komponentin datan perusteella. /// </summary> public MapComponent MakeNew(MapComponentData mapComponentData) { Type componentType = null; MapComponent mapComponent = null; foreach (string componentNamespace in componentNamespaces) { componentType = Type.GetType(componentNamespace + "." + mapComponentData.ComponentName); if (componentType != null) { break; } } if (componentType != null) { ILayer layer = map.LayerManager.GetLayer <ILayer>(l => l.Name == mapComponentData.LayerName); mapComponent = (MapComponent)Activator.CreateInstance(componentType, game, map, layer); mapComponent.Initialize(mapComponentData); } return(mapComponent); }