コード例 #1
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here
            var cam = new Camera(this);

            Components.Add(cam);

            cam.Position     = new Vector3(0, 15, -15);
            cam.Up           = Vector3.UnitY;
            cam.LookAtTarget = cam.Up * 12;

            var ksh = new KeyboardStateHandler(this);

            ksh.KeyHold += Ksh_KeyHold;
            ksh.KeyDown += Ksh_KeyDown;

            Components.Add(ksh);
            Components.Add(new MouseCameraControl(this));
            Components.Add(new FpsCounter(this));

            _pmxVmdAnimator = new PmxVmdAnimator(this);
            Components.Add(_pmxVmdAnimator);

            _pmxRenderer = new PmxRenderer(this);
            Components.Add(_pmxRenderer);

            _boneDebugVisualizer = new BoneDebugVisualizer(this);
            Components.Add(_boneDebugVisualizer);

            IsMouseVisible = true;

            base.Initialize();
        }
コード例 #2
0
ファイル: Theater.cs プロジェクト: KinoMyu/MilliSim
        private void AppendComponents()
        {
            var components = Components;

            var keyboardStateHandler = new KeyboardStateHandler(this);

            components.Add(keyboardStateHandler);

            keyboardStateHandler.KeyDown += KeyboardStateHandler_KeyDown;
            keyboardStateHandler.KeyUp   += KeyboardStateHandler_KeyUp;
        }
コード例 #3
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here
            IsMouseVisible = true;

            _keyboardStateHandler        = new KeyboardStateHandler(this);
            _keyboardStateHandler.KeyUp += _keyboardStateHandler_KeyUp;

            Components.Add(_keyboardStateHandler);

            base.Initialize();
        }
コード例 #4
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here
            IsMouseVisible = true;

            _graphics.PreferredBackBufferWidth  = WindowWidth;
            _graphics.PreferredBackBufferHeight = WindowHeight;
            _graphics.ApplyChanges();

            _videoPlayer = new VideoPlayer(GraphicsDevice);
            //_videoPlayer.IsLooped = true;

            _keyboardStateHandler = new KeyboardStateHandler(this);

            _keyboardStateHandler.KeyUp += KeyboardStateHandler_KeyUp;

            Components.Add(_keyboardStateHandler);

            base.Initialize();
        }
コード例 #5
0
        private void AppendComponents()
        {
            var keyboardStateHandler = new KeyboardStateHandler(this);

            Components.Add(keyboardStateHandler);

            Components.Add(new MouseCameraControl(this));

            keyboardStateHandler.KeyHold += (s, e) => {
                var cam = this.FindSingleElement <Cameraman>()?.Camera;

                if (cam == null)
                {
                    return;
                }

                switch (e.KeyCode)
                {
                case Keys.A:
                    cam.Strafe(-0.1f);
                    break;

                case Keys.D:
                    cam.Strafe(0.1f);
                    break;

                case Keys.W:
                    cam.Walk(0.1f);
                    break;

                case Keys.S:
                    cam.Walk(-0.1f);
                    break;

                case Keys.Left:
                    cam.Yaw(0.01f);
                    break;

                case Keys.Right:
                    cam.Yaw(-0.01f);
                    break;

                case Keys.Up:
                    cam.Pitch(-0.01f);
                    break;

                case Keys.Down:
                    cam.Pitch(0.01f);
                    break;

                case Keys.R: {
                    var camera = this.FindSingleElement <Cameraman>()?.Camera;
                    camera?.Reset();
                }
                break;

                case Keys.F6: {
                    var syncTimer = this.FindSingleElement <SyncTimer>();
                    syncTimer?.Stop();
                }
                break;
                }
            };

            keyboardStateHandler.KeyDown += (s, e) => {
                switch (e.KeyCode)
                {
                case Keys.Space: {
                    var audioController = this.FindSingleElement <BackgroundMusic>();
                    var music           = audioController?.Music;
                    var syncTimer       = this.FindSingleElement <SyncTimer>();

                    Debug.Assert(syncTimer != null, nameof(syncTimer) + " != null");

                    if (music == null)
                    {
                        break;
                    }

                    var isPlaying = syncTimer.IsRunning;

                    if (!isPlaying)
                    {
                        syncTimer.Start();
                    }
                    else
                    {
                        syncTimer.Pause();
                    }
                }
                break;
                }
            };
        }