private void CleanDestroyAllEntities(bool includeEdges = true) { // Explode all entities ImmutableList <Entity> explosionEntities = Engine.GetEntitiesFor(Family .All(typeof(TransformComponent), typeof(ColoredExplosionComponent)) .Exclude(typeof(DontDestroyForGameOverComponent)) .Get()); foreach (Entity entity in explosionEntities) { TransformComponent transformComp = entity.GetComponent <TransformComponent>(); ColoredExplosionComponent coloredExplosionComp = entity.GetComponent <ColoredExplosionComponent>(); EventManager.Instance.QueueEvent(new CreateExplosionEvent(transformComp.Position, coloredExplosionComp.Color, false)); } // Destroy all entities Engine.DestroyEntitiesFor(Family.Exclude(typeof(DontDestroyForGameOverComponent), typeof(ParallaxBackgroundComponent), typeof(EdgeComponent)).Get()); // Destroy edges (if needed) if (includeEdges) { // Fade out edges foreach (Entity edgeEntity in Engine.GetEntitiesFor(Family.All(typeof(EdgeComponent), typeof(VectorSpriteComponent)).Get())) { ProcessManager.Attach(new SpriteEntityFadeOutProcess(Engine, edgeEntity, CVars.Get <float>("game_over_edge_fade_out_duration"), Easings.Functions.QuadraticEaseOut)) .SetNext(new EntityDestructionProcess(Engine, edgeEntity)); } } }
private void HandlePlayerLostEvent(PlayerLostEvent playerLostEvent) { Entity responsibleEntity = playerLostEvent.ResponsibleEntity; responsibleEntity.StripAllComponentsExcept(typeof(TransformComponent), typeof(VectorSpriteComponent), typeof(SpriteComponent), typeof(ColoredExplosionComponent), typeof(DontDestroyForGameOverComponent)); responsibleEntity.AddComponent(new DontDestroyForGameOverComponent()); // Make the camera zoom to include the entity responsibleEntity.AddComponent(new CameraTrackingComponent()); ProcessManager.Attach(new SpriteEntityFlashProcess(Engine, responsibleEntity, CVars.Get <int>("game_over_responsible_enemy_flash_count"), CVars.Get <float>("game_over_responsible_enemy_flash_period") / 2)) .SetNext(new DelegateProcess(() => { // Explosion TransformComponent transformComp = responsibleEntity.GetComponent <TransformComponent>(); ColoredExplosionComponent coloredExplosionComp = responsibleEntity.GetComponent <ColoredExplosionComponent>(); EventManager.Instance.QueueEvent(new CreateExplosionEvent(transformComp.Position, coloredExplosionComp.Color, false)); })).SetNext(new EntityDestructionProcess(Engine, responsibleEntity)).SetNext(new DelegateProcess(() => { EventManager.Instance.QueueEvent(new PlayerLostAnimationCompletedEvent(playerLostEvent.Player)); })); }
private void StartGame(Player[] players) { // Explode all entities ImmutableList <Entity> explosionEntities = SharedState.Engine.GetEntitiesFor(Family .All(typeof(TransformComponent), typeof(ColoredExplosionComponent), typeof(MenuBackgroundComponent)) .Get()); foreach (Entity entity in explosionEntities) { TransformComponent transformComp = entity.GetComponent <TransformComponent>(); ColoredExplosionComponent coloredExplosionComp = entity.GetComponent <ColoredExplosionComponent>(); EventManager.Instance.QueueEvent(new CreateExplosionEvent(transformComp.Position, coloredExplosionComp.Color, false)); } // Destroy all entities SharedState.Engine.DestroyEntitiesFor(Family.All(typeof(MenuBackgroundComponent)).Get()); ChangeState(new AdriftGameState(GameManager, SharedState, players)); }