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 void SetLevel(BaseLevelState nextLevel) { if(nextLevel != null) { currentLevel = nextLevel; currentLevel.setGame(this); currentLevel.Draw(); window.setLevelLabel(currentLevel.id.ToString()); foreach (Unit unit in units) { unit.velocity = nextLevel.velocity; } } else //Finished last level { Finish(); } }