Exemple #1
0
 public void Start(GameEngine engine)
 {
     Bus.Add(new SystemMessage(engine.Timer.LastTickTime, "VoxelRTS Graphics starting."));
     using (var p = new VoxelRTSWindow(engine))
     {
         p.LoadView(typeof(VoxelGreen), new VoxelGreenView());
         p.LoadView(typeof(Planet), new PlanetView());
         p.LoadView(typeof(TopMenu), new TopMenuView(p));
         p.Run();
     }
 }
Exemple #2
0
        public GameEngine(MessageBus bus, GameObjectFactory factory, WidgetFactory widgetFactory, IGraphicsLoader graphicsLoader, ISound sound)
        {
            _currentState   = new IdleState(this);
            Timer           = new AsyncObservableTimer();
            Bus             = bus;
            Factory         = factory;
            _graphicsLoader = graphicsLoader;
            Sound           = sound;

            WidgetFactory = widgetFactory;

            Bus.OfType <GraphicsLoadedMessage>().Subscribe(m => {
                Graphics = m.Graphics;
                WidgetFactory.Initialise(Graphics);
                Bus.Add(new GameStartMessage(Timer.LastTickTime));
            });


            IsRunning = false;
            Timer.Subscribe(Update);
            Timer.SubSample(5).Subscribe(t => Bus.SendAll());

            //Timer.Subscribe(t => Bus.Add(new GraphicsDirtyMessage(t)));
        }