示例#1
0
        public SandboxGame()
        {
            var deviceManager = new GraphicsDeviceManager(this);

            Content.RootDirectory = "Content";
            _penumbra             = new PenumbraComponent(this)
            {
                SpriteBatchTransformEnabled = false,
                AmbientColor = Color.Black
            };
            Components.Add(_penumbra);
            _penumbraController = new PenumbraControllerComponent(this, _penumbra);
            Components.Add(_penumbraController);
            Scenarios = new ScenariosComponent(this, _penumbra, _penumbraController);
            Components.Add(Scenarios);
            var ui = new UIComponent(this, _penumbraController)
            {
                DrawOrder = int.MaxValue
            };

            Components.Add(ui);
            _camera = new CameraMovementComponent(this);
            Components.Add(_camera);
            Components.Add(new FpsGarbageComponent(this));

            // There's a bug when trying to change resolution during window resize.
            // https://github.com/mono/MonoGame/issues/3572
            deviceManager.PreferredBackBufferWidth  = 1280;
            deviceManager.PreferredBackBufferHeight = 720;
            Window.AllowUserResizing = false;
            IsMouseVisible           = true;
        }
        public SandboxGame()
        {
            _deviceManager = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";
            _penumbra = new PenumbraComponent(this, Transforms.OriginCenter_XRight_YUp | Transforms.Custom)
            {
                AmbientColor = Color.Black
            };
            Components.Add(_penumbra);
            _penumbraController = new PenumbraControllerComponent(this, _penumbra);
            Components.Add(_penumbraController);
            _scenarios = new ScenariosComponent(this, _penumbra, _penumbraController, _consoleInterpreter);
            Components.Add(_scenarios);
            var ui = new UIComponent(this, _penumbraController)
            {
                DrawOrder = int.MaxValue
            };
            Components.Add(ui);
            _camera = new CameraMovementComponent(this, _penumbra);
            Components.Add(_camera);
            Components.Add(new FpsGarbageComponent(this));
            _console = new ConsoleComponent(this);
            Components.Add(_console);

            // There's a bug when trying to change resolution during window resize.
            // https://github.com/mono/MonoGame/issues/3572
            _deviceManager.PreferredBackBufferWidth = 1280;
            _deviceManager.PreferredBackBufferHeight = 720;
            Window.AllowUserResizing = false;
            IsMouseVisible = true;
        }
        public UIComponent(SandboxGame game, PenumbraControllerComponent penumbraController)
            : base(game)
        {
            _penumbraController = penumbraController;
            _scenarios = game.Scenarios;

            penumbraController.ShadowTypeChanged += (s, e) => SetShadowTypeInfo();
            SetShadowTypeInfo();

            Enabled = false;
            Visible = true;
        }