public MainEventProcessor(GameObjectContainer gameObjectContainer, GameObjectFactory factory, EventBus eventBus)
 {
   _objectFactory = factory;
   _objectContainer = gameObjectContainer;
   _eventBus = eventBus;
   _initializeSubscriptions();
 }
    public MatchManager(GameModel gameModel, TimerQueue timedQ, EventBus eventBus, EventFactory eventFactory, List<string> levelPaths)
    {
      _pointsPerCity = 100;
      _pointsPerRemainingShots = 10;
      _currentLevelIndex = 0;
      _userScore = 0;
      _timerQ = timedQ;
      _gameModel = gameModel;
      _levels = new List<Level>();
      _eventFactory = eventFactory;
      _eventBus = eventBus;

      foreach (string path in levelPaths)
      {
        try
        {
          _levels.Add(new Level(path));
        }
        catch (Exception e)
        {
          Console.WriteLine("ERROR caught exception loading level from path: "+path+e.Message+e.StackTrace);
        }
      }

      //initiaize the first level
      _loadLevel(_levels[0]);
    }
    /// <summary>
    /// 
    /// </summary>
    private void _run()
    {
      //initialize the game params first
      GameParameters.Initialize((int)_viewFramework.GetScreenDimension().X, (int)_viewFramework.GetScreenDimension().Y);
      
      GameLogger.Initialize(Console.Out);
      EventBus eventBus = new EventBus();
      EventFactory eventFactory = new EventFactory();
      EventMonitor eventMonitor = new EventMonitor(eventFactory,eventBus);
      //this thread will be blocked at GetIGameSpriteFactory() until ContentManager is initialized
      GameObjectFactory gameObjectFactory = new GameObjectFactory(eventMonitor, _viewFramework.GetIGameSpriteFactory());
      GameObjectContainer gameObjects = new GameObjectContainer();
      MainEventProcessor mainEventListener = new MainEventProcessor(gameObjects, gameObjectFactory, eventBus);
      GameModel gameModel = new GameModel(gameObjects, gameObjectFactory);
      GameController gameController = new GameController(eventBus, gameModel, eventFactory, _viewFramework);

      //controller runs forever-loop
      gameController.Run();
    }
    public GameController(EventBus eventBus, GameModel model, EventFactory factory, IGameViewFramework viewFramework)
    {
      _gameModel = model;
      _eventBus = eventBus;
      _timerQ = new TimerQueue(eventBus);
      _eventFactory = factory;
      _tickMS = (int)GameParameters.REFRESH_RATE_MS;

      //TODO: The level paths should be an input from some game configuration file, instead of hardcoding them here
      //initialize the level paths. Does this belon here, or in model?
      _levels = new List<string>();
      for (int i = 1; i <= 3; i++)
      {
        _levels.Add(Environment.CurrentDirectory + "\\Levels\\Level" + i.ToString() + ".xml");
      }
      _matchManager = new MatchManager(model, _timerQ, eventBus, _eventFactory, _levels);

      //TODO: setting these could be moved outside this constructor. This object needs no persistent reference to view.
      viewFramework.SetKeyboardInputHandler(OnKeyboardInput);
      viewFramework.SetMouseInputHandler(OnMouseInput);
      _matchManager.OnLevelCompletion += viewFramework.OnLevelCompletion;
      _matchManager.OnGameOver += viewFramework.OnGameOver;
    }
Beispiel #5
0
 public TimerQueue(EventBus eventBus)
 {
   _eventBus = eventBus;
   _Q = new List<TimedEvent>();
 }
 public EventMonitor(EventFactory eventFactory, EventBus eventBus)
 {
   _eventFactory = eventFactory;
   _eventBus = eventBus;
 }