public void Handle(GameTime gameTime)
        {
            try
            {
                if (Keyboard.GetState().IsKeyDown(Keys.F1) && players.Count >= 1)
                {
                    viewportManager.SetViewports(new List <Car> {
                        players[0]
                    });
                }

                if (Keyboard.GetState().IsKeyDown(Keys.F2) && players.Count >= 2)
                {
                    viewportManager.SetViewports(new List <Car> {
                        players[1]
                    });
                }

                if (Keyboard.GetState().IsKeyDown(Keys.F3) && players.Count >= 3)
                {
                    viewportManager.SetViewports(new List <Car> {
                        players[2]
                    });
                }

                if (Keyboard.GetState().IsKeyDown(Keys.F4) && players.Count >= 4)
                {
                    viewportManager.SetViewports(new List <Car> {
                        players[3]
                    });
                }

                if (Keyboard.GetState().IsKeyDown(Keys.F5))
                {
                    viewportManager.SetViewports(players);
                }

                if (Keyboard.GetState().IsKeyDown(Keys.F6))
                {
                    viewportManager.Viewports.ForEach(vp => vp.UseCameraSetup(CameraSetup.CameraDefault));
                }

                if (Keyboard.GetState().IsKeyDown(Keys.F7))
                {
                    viewportManager.Viewports.ForEach(vp => vp.UseCameraSetup(CameraSetup.CameraInside));
                }

                if (Keyboard.GetState().IsKeyDown(Keys.F8))
                {
                    viewportManager.Viewports.ForEach(vp => vp.UseCameraSetup(CameraSetup.CameraRear));
                }
            }
            catch
            {
                // TODO: ignored
            }
        }
Пример #2
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            _background = Content.Load <Texture2D>("background");

            Road.LoadContent(Content, _graphics);
            FinishLine.LoadContent(Content, _graphics);

            _agentFactory.LoadContent(Content);
            _courseObjectFactory.LoadContent(Content);
            _playerFactory.LoadContent(Content);
            _dashboard.LoadContent(Content);
            // TEMP
            InitializeModel();

            _viewportManager.SetViewports(_players);
        }
        public void Handle(GameTime gameTime)
        {
            if (Keyboard.GetState().IsKeyDown(Keys.F9))
            {
                ToogleEnabled();
            }

            if (!_enabled)
            {
                return;
            }

            if ((gameTime.TotalGameTime - _lastViewportChange).TotalMilliseconds > _changeInterval)
            {
                _viewportManager.SetViewports(GetActivePlayers(), GetActiveCamera());
                _lastViewportChange = gameTime.TotalGameTime;
            }
        }
Пример #4
0
        public void Handle(GameTime gameTime)
        {
            if (Keyboard.GetState().IsKeyDown(Keys.F9))
            {
                ToogleEnabled();
            }

            if (!_enabled)
            {
                return;
            }

            if ((gameTime.TotalGameTime - lastViewportChange).TotalMilliseconds > changeInterval)
            {
                var playersInFocus = new List <Car>();
                if (activePlayerIndex == players.Count)
                {
                    playersInFocus = players;
                }
                else
                {
                    if (humanPlayerIndex != -1)
                    {
                        playersInFocus.Add(players[humanPlayerIndex]);
                    }

                    if (activePlayerIndex != humanPlayerIndex)
                    {
                        playersInFocus.Add(players[activePlayerIndex]);
                    }
                }

                viewportManager.SetViewports(playersInFocus, GetActiveCamera());

                activePlayerIndex = (++activePlayerIndex) % (players.Count + 1);

                lastViewportChange = gameTime.TotalGameTime;
            }
        }