private void CreateEnemySource(float absoluteTime) { var containerEnemySource = registry.CreateComponentContainer(); var periodicUpdate = new ComponentPeriodicUpdate(absoluteTime, 0.5f); periodicUpdate.PeriodElapsed += (s, time) => { CreateEnemy(time); }; registry.RegisterComponentTo(containerEnemySource, periodicUpdate); }
private void CreateEnemy(float absoluteTime) { var container = registry.CreateComponentContainer(); var frame = new Box2D(0.5f, 1.0f, 0.06f, 0.1f); var compFrame = new Component <Box2D>(frame); registry.RegisterComponentTo(container, compFrame); var enemy = new Enemy(compFrame, absoluteTime, -0.3f); registry.RegisterComponentTo(container, enemy); var periodicEnemyBullet = new ComponentPeriodicUpdate(absoluteTime, 1.5f); periodicEnemyBullet.PeriodElapsed += (s, time) => { CreateEnemyBullet(time, frame.X, frame.Y); CreateEnemyBullet(time, frame.MaxX, frame.Y); }; registry.RegisterComponentTo(container, periodicEnemyBullet); registry.RegisterComponentTo(container, new ComponentClipper(visibleFrame, frame, () => Remove(container))); registry.RegisterComponentTo(container, new Collidable(frame)); registry.RegisterComponentTo(container, new Component <IDrawable>(renderer.CreateDrawable("enemy", frame))); }
private void CreateEnemy(float absoluteTime) { var container = registry.CreateComponentContainer(); var frame = new Box2D(0.5f, 1.0f, 0.06f, 0.1f); var compFrame = new Component<Box2D>(frame); registry.RegisterComponentTo(container, compFrame); var enemy = new Enemy(compFrame, absoluteTime, - 0.3f); registry.RegisterComponentTo(container, enemy); var periodicEnemyBullet = new ComponentPeriodicUpdate(absoluteTime, 1.5f); periodicEnemyBullet.OnPeriodElapsed += (s, time) => { CreateEnemyBullet(time, frame.X, frame.Y); CreateEnemyBullet(time, frame.MaxX, frame.Y); }; registry.RegisterComponentTo(container, periodicEnemyBullet); registry.RegisterComponentTo(container, new ComponentClipper(visibleFrame, frame, () => Remove(container))); registry.RegisterComponentTo(container, new Collidable(frame)); registry.RegisterComponentTo(container, new Component<IDrawable>(renderer.CreateDrawable("enemy", frame))); }
private void CreateEnemySource(float absoluteTime) { var containerEnemySource = registry.CreateComponentContainer(); var periodicUpdate = new ComponentPeriodicUpdate(absoluteTime, 0.5f); periodicUpdate.OnPeriodElapsed += (s, time) => { CreateEnemy(time); }; registry.RegisterComponentTo(containerEnemySource, periodicUpdate); }