public GameController(MainWindow window) { unitFactory = UnitFactory.Instance; behaviourFactory = BehaviourFactory.Instance; moveContainer = new MoveContainer(); drawContainer = new DrawContainer(); units = new ArrayList(); this.window = window; timer = new Timer(); dispatcher = Dispatcher.CurrentDispatcher; currentLevel = new BaseLevelState(this); //maak level 1 aan currentLevel.NextLevel(); Crow.AddUnitToFactory(); Duck.AddUnitToFactory(); Unit unit1 = unitFactory.CreateUnit("Duck", moveContainer, drawContainer, behaviourFactory, window); units.Add(unit1); //Thread t = new Thread(new ThreadStart(gameLoop)); //t.Start(); Unit unit2 = unitFactory.CreateUnit("Crow", moveContainer, drawContainer, behaviourFactory, window); units.Add(unit2); t2 = new Thread(new ThreadStart(gameLoop)); t2.Start(); }
public Unit CreateUnit(string name, MoveContainer mc, DrawContainer dc, BehaviourFactory bf, MainWindow window) { if (unitMap.ContainsKey(name)) { return unitMap[name].CreateInstance(mc, dc, bf, window); } throw new Exception("Unit with the name "+ name +" Not Found"); }
public Duck(MoveContainer mc, DrawContainer dc, BehaviourFactory bf, MainWindow window) : base(mc, dc, bf, window) { //rnd = new Random(); size = 40; x = 0; y = rnd.Next(26, 300); color = Brushes.PowderBlue; velocity = 1.0F; heading = 1.5F; InitUnit(); }
public Unit(MoveContainer mc, DrawContainer dc, BehaviourFactory bf, MainWindow window) { moveContainer = mc; drawContainer = dc; behaviourFactory = bf; this.window = window; moveBehaviour = behaviourFactory.CreateMoveBehaviour(this, "flying"); drawBehaviour = behaviourFactory.CreateDrawBehaviour(this, "flying"); moveContainer.Add(moveBehaviour); drawContainer.Add(drawBehaviour); this.window = window; dispatcher = Dispatcher.CurrentDispatcher; }
public Crow(MoveContainer mc, DrawContainer dc, BehaviourFactory bf, MainWindow window) : base(mc, dc, bf, window) { //rnd = new Random(); size = 40; x = 0; y = rnd.Next(26, 300); color = Brushes.Black; velocity = 1.0F; heading = 1.5F; this.window = window; dispatcher = Dispatcher.CurrentDispatcher; InitUnit(); }
public override Unit CreateInstance(MoveContainer mc, DrawContainer dc, BehaviourFactory bf, MainWindow window) { return new Duck(mc, dc, bf, window); }
public abstract Unit CreateInstance(MoveContainer mc, DrawContainer dc, BehaviourFactory bf, MainWindow window);