Beispiel #1
0
 public void ExitBulletView()
 {
     worldCamera = originalWorldCamera;
     Components.Remove(bulletViewCamera);
     physicsEngine.RemovePhysicsObject(bulletViewCamera);
     enteringBulletView = false;
     this.IsMouseVisible = true;
     canControlTank = true;
 }
Beispiel #2
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()
        {
            worldCamera = new Cameras.QuaternionCameraComponent(this);
            float fov = 9.0f/16.0f*this.GraphicsDevice.Viewport.AspectRatio*90.0f;
            worldCamera.Perspective(fov, 16.0f / 9.0f, 0.5f, 20000.0f);
            worldCamera.Position = new Vector3(0, -370, 160);
            worldCamera.LookAt(new Vector3(0.0f, 0.0f, 0.0f));
            worldCamera.ClickAndDragMouseRotation = true;
            worldCamera.CurrentBehavior = Cameras.QuaternionCamera.Behavior.AimMode;
            worldCamera.MovementSpeed = 100.0f;
            Components.Add(worldCamera);

            originalWorldCamera = worldCamera;
            bulletViewCamera = new PhysicsCamera(this);
            bulletViewCamera.Perspective(fov, 16.0f / 9.0f, 0.5f, 20000.0f);

            wireframeRasterizerState = new RasterizerState();
            wireframeRasterizerState.FillMode = FillMode.WireFrame;

            solidRasterizerState = new RasterizerState();
            solidRasterizerState.FillMode = FillMode.Solid;

            playerColors = new List<Vector3>();
            playerColors.Add(new Vector3(1.0f, 0.0f, 0.0f));
            playerColors.Add(new Vector3(0.0f, 1.0f, 0.0f));
            playerColors.Add(new Vector3(0.0f, 0.0f, 1.0f));
            playerColors.Add(new Vector3(1.0f, 1.0f, 0.0f));
            playerColors.Add(new Vector3(0.0f, 1.0f, 1.0f));
            playerColors.Add(new Vector3(1.0f, 0.0f, 1.0f));
            playerColors.Add(new Vector3(1.0f, 1.0f, 1.0f));
            playerColors.Add(new Vector3(1.0f, 0.5f, 0.5f));
            playerColors.Add(new Vector3(0.5f, 1.0f, 0.5f));
            playerColors.Add(new Vector3(0.5f, 0.5f, 1.0f));

            terrain = new Terrain.Terrain(this);
            Components.Add(terrain);

            physicsEngine = new PhysicsEngine(this, IntegrationMethod.RungeKutta4);
            Components.Add(physicsEngine);

            mainHUD = new HUD(this);
            Components.Add(mainHUD);

            drawUtils = new DrawUtils(this);
            Components.Add(drawUtils);

            tanks = new Tank[numPlayers];
            players = new Player[numPlayers];

            for (int i = 0; i < numPlayers; i++)
            {
                players[i] = new Player(this);
                tanks[i] = new Tank(this, Vector3.Zero, i, playerColors.ElementAt(i));
            }

            numPlayersAlive = numPlayers;

            currentTank = tanks[currentPlayer];

            weaponManager = new WeaponManager(this);

            bulletManager = new BulletManager(this);
            Components.Add(bulletManager);

            base.Initialize();
        }
Beispiel #3
0
 public void EnterBulletView()
 {
     worldCamera.CurrentBehavior = QuaternionCamera.Behavior.AimMode;
     enteringBulletView = false;
     this.IsMouseVisible = false;
     bulletViewCamera.FollowBullet = followBullet;
     Components.Add(bulletViewCamera);
     bulletViewCamera.Position = followBulletStartPos;
     bulletViewCamera.Velocity = followBulletStartVelocity;
     physicsEngine.AddPhysicsObject(bulletViewCamera);
     worldCamera = bulletViewCamera;
 }