Beispiel #1
0
        public void Run()
        {
            Logger.Debug("Initialising GameController.");

            ShowSplashScreen();

            _configurationManager.LoadFromFile(PathHelpers.ExecutableRelativeFile("client_config.toml"));

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

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

            //Initialization of private members
            _messageLogger.Initialize();
            _entityNetworkManager.Initialize();
            _tileDefinitionManager.InitializeResources();

            var prototypeManager = IoCManager.Resolve <IPrototypeManager>();

            prototypeManager.LoadDirectory(PathHelpers.ExecutableRelativeFile("Prototypes"));
            prototypeManager.Resync();
            _networkManager.Initialize();
            _netGrapher.Initialize();
            _userInterfaceManager.Initialize();

            _stateManager.RequestStateChange <MainScreen>();

            FrameEventArgs _frameEvent;

            // EventArgs _frameEventArgs;
            _clock = new 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();
            }
            _networkManager.Disconnect();
            CluwneLib.Terminate();
            Logger.Info("GameController terminated.");

            IoCManager.Resolve <IConfigurationManager>().SaveToFile();
        }
Beispiel #2
0
        public Character(TileMap map, Vector2i initialPosition)
        {
            //Bind map
            this.map = map;
            this.map.Tiles[initialPosition.X, initialPosition.Y].Enter(this);

            //Prepare the sprite
            sprite = new Sprite();
            sprite.Texture = new Texture("Assets/Textures/playerTemp.png");
            sprite.Origin = sprite.Texture.Center();
            sprite.Position = new Vector2f(Position.X, Position.Y) * Tile.WorldSize + new Vector2f(Tile.WorldSize, Tile.WorldSize) / 2;

            //Start the updateTimer
            updateTimer = new Clock();
        }
Beispiel #3
0
        public void Run()
        {
            var clock = new Sfs.Clock();

            SetEventHandlers();
            while (_window.IsOpen)
            {
                _window.Clear();
                _window.DispatchEvents();
                Update(clock.ElapsedTime);
                clock.Restart();
                Render();
                _window.Display();
            }
        }
Beispiel #4
0
 public Battlefield(RenderWindow window)
 {
     this.window = window;
     world       = new World(new Vector2(0, 0));
     InitGlobalBounds();
     input                = new InputHandler();
     currentCommands      = new List <Command>(10);
     currentGameCommands  = new List <GameCommand>(10);
     currentPauseCommands = new List <PauseCommand>(10);
     initPlayer();
     c           = new EnemyShipContainer(this);
     timer       = new SFML.System.Clock();
     deltaTime   = SFML.System.Time.FromSeconds(10);
     debug       = new DebugPhysics(world, window);
     pauseScreen = new PauseScreen();
 }
Beispiel #5
0
        public Game()
        {
            View = new View
            {
                Size = new Vector2f(320, 240),
                Center = new Vector2f(320, 240)
            };
            _player = new Entity(EntityType.Player);
            _frameClock = new Clock();

            Map = new Map("testmap", 40, 30);

            for (var x = 0; x < Map.Size.X; x++)
            {
                for (var y = 0; y < Map.Size.Y; y++)
                {
                    Map.AddTile(TileType.Stonefloor, x, y, 0);
                }
            }

            Map.AmbientLightColor = new Color(70, 70, 70, 255);
            _player.Position = new Vector2f(20 * 32, 15 * 32);
            Map.AddEntity(_player);

            _playerLight = new PointLight(Color.White, 1.0f, 128, _player.Position);

            _mouseLight = new PointLight(Color.Red, 1.0f, 128, (Vector2f) InputHandler.MousePosition);

            Map.AddLight(_mouseLight);
            Map.AddLight(_playerLight);

            Map.AddTile(TileType.StonewallNorth, 22, 18, 1);
            Map.AddTile(TileType.StonewallNorth, 22, 14, 1);
            Map.AddTile(TileType.StonewallNorth, 18, 18, 1);
            Map.AddTile(TileType.StonewallNorth, 18, 14, 1);
            Map.AddTile(TileType.StonewallNorth, 20, 12, 1);
            Map.AddTile(TileType.StonewallNorth, 16, 16, 1);
            Map.AddTile(TileType.StonewallNorth, 20, 20, 1);
            Map.AddTile(TileType.StonewallNorth, 24, 16, 1);
        }
Beispiel #6
0
        private long totalFrameCount; // Total frame count.

        #endregion Fields

        #region Constructors

        public TimingData(Clock sfmltimer)
        {
            timer = sfmltimer;
        }