예제 #1
0
 public MainEventProcessor(GameObjectContainer gameObjectContainer, GameObjectFactory factory, EventBus eventBus)
 {
   _objectFactory = factory;
   _objectContainer = gameObjectContainer;
   _eventBus = eventBus;
   _initializeSubscriptions();
 }
예제 #2
0
    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]);
    }
예제 #3
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();
    }
예제 #4
0
    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;
    }
예제 #5
0
 public TimerQueue(EventBus eventBus)
 {
   _eventBus = eventBus;
   _Q = new List<TimedEvent>();
 }
예제 #6
0
 public EventMonitor(EventFactory eventFactory, EventBus eventBus)
 {
   _eventFactory = eventFactory;
   _eventBus = eventBus;
 }