//public void test_Add() //{ // Entity e = ef.CreateEnemy(EntityFactory.EntitiyType.Boss1); // e.Movement = mf.CreateMovement(MovementFactory.MovementType.Bounce, e); // e.Position = new Vector2(300, 300); // this.SubscribeAll(e); // this.entities.Add(e); //} /// <summary> /// Add a player to this game through the queue /// </summary> /// <param name="spawner"> Add a spawner as well? </param> public void AddPlayerOne(SpawnerFactory.SpawnerType spawner = SpawnerFactory.SpawnerType.None) { Entity player = ef.CreateEnemy(EntityFactory.EntitiyType.Player); player.MakeInvincible(3); player.Position = new Vector2(600, 600); GUIComponent plComponent = new PlayerLives(); eventManager.ReadyEnqueue(plComponent, new AddGUIEventArgs(plComponent, player)); eventManager.ReadyEnqueue(player, new AddPlayerEventArgs((Player)player)); if (spawner != SpawnerFactory.SpawnerType.None) { BulletSpawner s = this.sf.CreateSpawner(spawner, player); MirrorMovement m = (MirrorMovement)mf.CreateMovement(MovementFactory.MovementType.Mirror, player); m.ThisSprite = s; s.Movement = m; eventManager.ReadyEnqueue(s, new AddSpawnerEventArgs(player, s)); } }
/// <summary> /// Add a guiComponent from the EventManager Concurrent Queue /// </summary> /// <param name="e"></param> private void ReadGUIComponent(AddGUIEventArgs e) { if (e.Component is PlayerLives) { PlayerLives p = (PlayerLives)e.Component; p.Parent = (Player)e.Parent; this.gui_components.Add(p); return; } if (e.Component is GameOverComponent) { this.gui_components.Add(e.Component); return; } if (e.Component is HealthBarComponent) { this.gui_components.Add(e.Component); return; } throw new NotImplementedException(); }