Exemple #1
0
 public CameraManager(FreeCamera camera)
 {
     Camera = camera;
     State = CameraState.Static;
 }
Exemple #2
0
        /// <summary>
        ///     Load graphics content for the game.
        /// </summary>
        public override void Activate(bool instancePreserved)
        {
            if (instancePreserved)
            {
                return;
            }
            if (_content == null)
            {
                _content = new ContentManager(ScreenManager.Game.Services, "Content");
            }
            _sceneRenderer = new SimpleSceneRenderer(ScreenManager.GraphicsDevice, _content)
                                 {
                                     RenderShadows = false
                                 };

            var pp = ScreenManager.GraphicsDevice.PresentationParameters;
            var aspectRatio = pp.BackBufferWidth/(float) pp.BackBufferHeight;
            _camera = new FreeCamera(SCENE_CENTER, MathHelper.ToRadians(45), aspectRatio, 0.1f,
                                     1000.0f);

            _cameraManager = new CameraManager(_camera);

            _scene = new Scene {CameraManager = _cameraManager, Ambient = new Color(0.7f, 0.7f, 0.7f)};

            var dirLight = new Light(LightType.Directional, Color.Red)
                               {
                                   Direction =
                                       new Vector3(0.45f, -0.15f, 0.875f),
                                   Position = new Vector3(5.6f, 7.6f, 12.0f)
                               };
            _scene.ShadowCastingLights.Add(dirLight);
            InitializeScene();

            // add the debug puzzleboard control
            int boardMargin = 15;
            int boardWidth = (pp.BackBufferWidth - 3*boardMargin)/3;
            int boardHeight = 5*boardWidth/7;

            var finder = new BoardLayoutFinder();
            ProcessLayouts(finder);

            var board1 = new PuzzleBoard(6, 5) {Player = _player1};
            board1.Randomize();
            _puzzleBoard1 = new PuzzleBoardWidget(this, _content, new Point(boardMargin, boardMargin),
                                                  new Point(boardWidth, boardHeight));
            _puzzleBoard1.LayoutFinder = finder;
            _puzzleBoard1.Board = board1;
            _puzzleBoard1.LayoutAccepted += LayoutAccepted;

            var board2 = new PuzzleBoard(6, 5);
            board2.Player = _player2;
            board2.Randomize();
            _puzzleBoard2 = new PuzzleBoardWidget(this, _content,
                                                  new Point(pp.BackBufferWidth - boardWidth - 2*boardMargin,
                                                            boardMargin), new Point(boardWidth, boardHeight));
            _puzzleBoard2.LayoutFinder = finder;
            _puzzleBoard2.Board = board2;

            _puzzleBoard2.LayoutAccepted += LayoutAccepted;

            //_particleManager = new ParticleManager((Game)ScreenManager.Game);
            //_particleManager.AddSystem<DustParticleSystem>(DUST_PARTICLE_SYSTEM, 10, player1.InitialPosition.Z + 0.1f);

            // once the load has finished, we use ResetElapsedTime to tell the game's
            // timing mechanism that we have just finished a very long frame, and that
            // it should not try to catch up.
            ScreenManager.Game.ResetElapsedTime();
        }