Esempio n. 1
0
 public Camera(GameEngine engine)
 {
     Vector3? cameratarget = new Vector3(1, 1, 1);
     Vector3? cameraposition = new Vector3(1, 1, 1);
     _engine = engine;
     View = Matrix.CreateLookAt(cameraposition.Value, cameratarget.Value, new Vector3(0, 1, 0));
     Projection = Matrix.CreatePerspectiveFieldOfView(MathHelper.PiOver4, MyGame.Device.Viewport.AspectRatio, 1, 150);
     cameraFrustum.Matrix = View * Projection;
 }
Esempio n. 2
0
        public TheGame(MyGame __game)
        {
            _engine = new GameEngine(__game);
            _staticData = StaticObjects.Instance();
            _level = new GameLevel(_engine.gameScene);

            _characters = new Dictionary<string, CharacterLogicController>();
               // _weapons = new Dictionary<string, WeaponLogicController>();

            _hotkeys = new List<HotKey>();
            _hotkeys.Add(new HotKey(new Keys[] { Keys.I }, SwichGunState));

            KeyboardManager.Manager.AddKeyboardUser(this);
        }
Esempio n. 3
0
        public Camera(GameEngine engine, Vector3? cameraposition = null, Vector3? cameratarget = null)
        {
            if (cameratarget == null)
                cameratarget = new Vector3(30, 30, 0);
            if (cameraposition == null)
                cameraposition = new Vector3(30, 30, 10);
            _engine = engine;
            _position = cameraposition.Value;
            _target = cameratarget.Value;
            _direction = (_target - _position);
            _direction.Normalize();

            float katet = -(cameratarget.Value.Y - cameraposition.Value.Y);
            float gipotenuza = (cameraposition.Value - cameratarget.Value).Length();
            CameraPitch = -MathHelper.PiOver2 + Convert.ToSingle(Math.Acos(Convert.ToDouble(katet / gipotenuza)));
            float determ = (cameratarget.Value.Z - cameraposition.Value.Z);
            if (determ == 0)
                determ = 0.001f;
            CameraYaw = Convert.ToSingle(Math.Atan(Convert.ToSingle((cameratarget.Value.X - cameraposition.Value.X) / determ)));
            View = Matrix.CreateLookAt(cameraposition.Value, cameratarget.Value, new Vector3(0, 1, 0));
            Projection = Matrix.CreatePerspectiveFieldOfView(MathHelper.PiOver4, MyGame.Device.Viewport.AspectRatio, 1, 100);
            cameraFrustum.Matrix = View * Projection;
        }
Esempio n. 4
0
        public GameEngine(MyGame game)
        {
            screenLog = new ScreenLog();
            _hotkeys = new List<HotKey>();
            _hotkeys.Add(new HotKey(new Keys[] { Keys.O }, SwichDebugRender));
            _hotkeys.Add(new HotKey(new Keys[] { Keys.P }, SwichBehaviourModel));

            KeyboardManager.Manager.AddKeyboardUser(this);

            game._engine = this;
            packs = new PackList();
             //   newPacks = new ContentNew.PackList();
            Instance = this;
            lightDir.Normalize();

            gameScene = new EngineScene();
            Scene = gameScene.Scene;

            //разме рэкрана
            MyGame.DeviceManager.PreferredBackBufferWidth = (int)(GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width *0.8 );
            MyGame.DeviceManager.PreferredBackBufferHeight = (int) (GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height*0.8);
            GameConfiguration.ScreenResolution = new Vector2(MyGame.DeviceManager.PreferredBackBufferWidth, MyGame.DeviceManager.PreferredBackBufferHeight);

            MyGame.DeviceManager.IsFullScreen = false;

            _cashe = new ObjectCashe();
        }