public GameController()
        {
            var    assemblies  = new List <Assembly>();
            string assemblyDir = Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath);

            assemblies.Add(Assembly.LoadFrom(Path.Combine(assemblyDir, "SS14.Client.Services.dll")));

            IoCManager.AddAssemblies(assemblies);

            _configurationManager = IoCManager.Resolve <IPlayerConfigurationManager>();
            _configurationManager.Initialize("./player_config.xml");

            _resourceManager = IoCManager.Resolve <IResourceManager>();

            _resourceManager.LoadBaseResources();
            _resourceManager.LoadLocalResources();

            //Setup Cluwne first, as the rest depends on it.
            SetupCluwne();

            //Initialization of private members
            _networkManager       = IoCManager.Resolve <INetworkManager>();
            _netGrapher           = IoCManager.Resolve <INetworkGrapher>();
            _stateManager         = IoCManager.Resolve <IStateManager>();
            _userInterfaceManager = IoCManager.Resolve <IUserInterfaceManager>();

            _stateManager.RequestStateChange <MainScreen> ();

            FrameEventArgs _frameEvent;
            EventArgs      _frameEventArgs;

            _clock = new SFML.System.Clock();

            while (CluwneLib.IsRunning == true)
            {
                var lastFrameTime = _clock.ElapsedTime.AsSeconds();
                _clock.Restart();
                _frameEvent = new FrameEventArgs(lastFrameTime);
                CluwneLib.ClearCurrentRendertarget(Color.Black);
                CluwneLib.Screen.DispatchEvents();
                CluwneLib.RunIdle(this, _frameEvent);
                CluwneLib.Screen.Display();
            }
            CluwneLib.Terminate();
            Console.WriteLine("Gameloop terminated.");
        }
Exemple #2
0
        public GameController()
        {
            _configurationManager = IoCManager.Resolve <IPlayerConfigurationManager>();
            _configurationManager.Initialize("./player_config.xml");

            _resourceManager = IoCManager.Resolve <IResourceManager>();

            _resourceManager.LoadBaseResources();
            _resourceManager.LoadLocalResources();

            //Setup Cluwne first, as the rest depends on it.
            SetupCluwne();

            //Initialization of private members
            _networkManager       = IoCManager.Resolve <INetworkManager>();
            _netGrapher           = IoCManager.Resolve <INetworkGrapher>();
            _stateManager         = IoCManager.Resolve <IStateManager>();
            _userInterfaceManager = IoCManager.Resolve <IUserInterfaceManager>();



            _stateManager.RequestStateChange <MainScreen> ();

            FrameEventArgs _frameEvent;
            EventArgs      _frameEventArgs;

            _clock = new SFML.System.Clock();


            while (CluwneLib.IsRunning == true)
            {
                var lastFrameTime = _clock.ElapsedTime.AsSeconds();
                _clock.Restart();
                _frameEvent = new FrameEventArgs(lastFrameTime);
                CluwneLib.ClearCurrentRendertarget(Color.Black);
                CluwneLib.Screen.DispatchEvents();
                CluwneLib.RunIdle(this, _frameEvent);
                CluwneLib.Screen.Display();
            }
            CluwneLib.Terminate();
            Console.WriteLine("Gameloop terminated.");
        }
        public GameController()
        {
            _configurationManager = IoCManager.Resolve<IConfigurationManager>();
            _configurationManager.Initialize("./config.xml");

            _resourceManager = IoCManager.Resolve<IResourceManager>();

            _resourceManager.LoadBaseResources();
            _resourceManager.LoadLocalResources();

            //Setup Cluwne first, as the rest depends on it.
            SetupCluwne ();

            //Initialization of private members
            _networkManager = IoCManager.Resolve<INetworkManager>();
            _netGrapher = IoCManager.Resolve<INetworkGrapher>();
            _stateManager = IoCManager.Resolve<IStateManager>();
            _userInterfaceManager = IoCManager.Resolve<IUserInterfaceManager>();

            SetupInput ();

            _stateManager.RequestStateChange<TestState> ();

            FrameEventArgs _frameEvent;
            EventArgs _frameEventArgs;
            _clock = new SFML.System.Clock();
            

            while (CluwneLib.IsRunning == true) 
            {
                var lastFrameTime = _clock.ElapsedTime.AsSeconds();
                _clock.Restart();
                _frameEvent = new FrameEventArgs(lastFrameTime);
                CluwneLib.Clear (Color.Black);
                CluwneLib.Screen.DispatchEvents();
                CluwneLib.RunIdle (this, _frameEvent);
                CluwneLib.Screen.Display();
            }
            CluwneLib.Terminate();
            Console.WriteLine("Gameloop terminated.");
        }
        /// <summary>
        /// Bucle principal de la aplicación 
        /// </summary>
        public void Run()
        {
            _logger.Log(LogLevel.Info, " >> Bucle principal del juego.");
            SFML.System.Clock clock = new SFML.System.Clock();
            SFML.System.Time timeSinceLastUpdate = SFML.System.Time.Zero;

            // Game Loop
            while (_window.IsOpen)
            {
                // Procesamos eventos. Este procesamiento de evento se podría quitar ya que sólo
                // tendría importancia para aquellos eventos que no afectasen al mundo
                // en este caso el Close. Si lo quitaramos sólo se retrasaría un poco (hasta el paso del tiempo
                // del frame) al ejecución del evento 
                _window.DispatchEvents();

                //// procesamos los eventos en el propio jugador
                //_player.HandleRealtimeInput(_world.CommandQueue);

                // para cada uno de los ciclos reinicio el reloj a cero y devuelvo
                // el tiempo que ha transcurrido
                timeSinceLastUpdate = clock.Restart();

                // si el tiempo transcurrido es mayor que el que queremos por cada frame
                while (timeSinceLastUpdate > _timePerFrame)
                {
                    timeSinceLastUpdate -= _timePerFrame;   // le quito un frame

                    // Procesamos eventos
                    _window.DispatchEvents();

                    //// procesamos los eventos en el propio jugador
                    //_player.HandleRealtimeInput(_world.CommandQueue);

                    if (!_isPaused)
                        Update(_timePerFrame);

                    // si después de este ciclo el tiempo que ha transcurrido sigue siendo mayor al de un frame
                    // repito el ciclo y voy actualizando el mundo, aunque no lo renderice
                    
                    // compruebo si la pila esta vacía (no hay escenas) y en ese caso salgo
                    if (_scnManager.IsEmpty)
                        _window.Close();
                }

                // en cada ciclo actualizo y renderizo
                if (!_isPaused)
                    Update(timeSinceLastUpdate);

                if (_scnManager.IsEmpty)
                    _window.Close();

                Render();
            }
        }
Exemple #5
0
 public Clock()
 {
     clock = new SClock();
 }