Beispiel #1
0
        protected override void LoadContent()
        {
            base.LoadContent();

            DetailTileSize = (ClientHeightHalf - (2 * Constants.Controls.Margin)) / MapDetailsRenderer2d.TilesToDisplay;
            DetailTileSizeHalf = DetailTileSize / 2;
            DetailsWidth = DetailTileSize * MapDetailsRenderer2d.TilesToDisplay;
            DetailsHeight = DetailsWidth;
            DetailsWidthHalf = DetailsWidth / 2;

            _camera = new Camera(ClientWidth, ClientHeight);
            _camera.Viewport = new Viewport(0, ClientHeightHalf, ClientWidthHalf, ClientHeightHalf);
            _camera.Position = Vector3.UnitZ * 4 + Vector3.UnitY * 6;
            _camera.FieldOfView = MathHelper.PiOver4;
            _camera.LookAt(-2 * Vector3.UnitZ);

            Tile.LoadContent(Content);

            _ui = new Window(null, this)
            {
                Position = new Point(ClientWidthHalf + DetailsWidthHalf + Constants.Controls.Margin, ClientHeightHalf - (2 * Constants.Controls.Margin)),
                Size = new Point(ClientWidth, ClientHeight),
            };

            var uixml = _ui.ToXElement();

            //_playerScreen = new PlayerScreen(_ui, this);
            //_playerScreen.Position = new Point(Constants.Controls.Margin, ClientHeightHalf - (2 * Constants.Controls.Margin));
            //_playerScreen.Player = _world.Player;

            //_controlScreen = new ControlScreen(_ui, this);
            //_controlScreen.Position = new Point(ClientWidthHalf + DetailsWidthHalf + Constants.Controls.Margin, ClientHeightHalf - (2 * Constants.Controls.Margin));

            //_ui.Load(Content);

            _world.LoadContent(Content);
            _world.Player.Position = new Point(9, 9);

            //_ui.SaveToFile(Path.Combine(WinForms.Application.StartupPath, "Data", "UI.xml"));
            _ui.LoadFromFile(Path.Combine(WinForms.Application.StartupPath, "Data", "UI.xml"));
            _ui.Load(Content);
            _ui.Layout();

            _playerScreen = _ui.GetControl<PlayerScreen>();
            _playerScreen.Player = _world.Player;
            _controlScreen = _ui.GetControl<ControlScreen>();

            _previousMilliseconds = 0;
        }