示例#1
0
        internal PvpStage(Game1 game1) : base(game1)
        {
            //Load Viewports
            defaultView      = Game1.graphics.GraphicsDevice.Viewport;
            upView           = downView = defaultView;
            upView.Height   /= 2;
            downView.Height /= 2;
            downView.Y       = upView.Height;

            //Load stuff
            currentLight = new Light(-Vector3.One, new Color(new Vector3(0.5f, 0.5f, 0.5f)), new Color(new Vector3(0.1f, 0.1f, 0.1f)));
            Bullet.LoadModel(game1.Content, Material.White, currentLight);
            Skybox.Load(game1.Content);

            //Load Players
            playerList = new List <Player>();
            playerOne  = new Player(new Vector3(50, 1, 64), new Vector3(0, MathHelper.TwoPi - MathHelper.PiOver2, 0), Vector3.Zero, 0.0005f, PlayerIndex.One);
            playerOne.LoadModelBones(game1.Content, Material.White, currentLight);
            playerList.Add(playerOne);
            playerTwo = new Player(new Vector3(70, 1, 64), new Vector3(0, MathHelper.PiOver2, 0), Vector3.Zero, 0.0005f, PlayerIndex.Two);
            playerTwo.LoadModelBones(game1.Content, Material.White, currentLight);
            playerList.Add(playerTwo);

            //Load Cameras
            currentCameraPlayerOne = new CameraThirdPersonFixed(game1.GraphicsDevice, new Vector3(64, 5, 65), playerOne.turret, 2.0f, new Vector3(0.0f, 0.1f, 1.0f), new Vector3(-0.2f, 0.3f, 0.2f), upView.AspectRatio);
            currentCameraPlayerTwo = new CameraThirdPersonFixed(game1.GraphicsDevice, new Vector3(64, 5, 65), playerTwo.turret, 2.0f, new Vector3(0.0f, 0.1f, 1.0f), new Vector3(-0.2f, 0.3f, 0.2f), downView.AspectRatio);

            //Load Particles
            particleSystemList = new List <ParticleSystem>();
            playerOneRain      = new ParticleSystem(ParticleType.Rain, new Vector3(64, 64, 64), new ParticleSpawner(30, false), game1.Content, 1000, 1000, 1);
            playerTwoRain      = new ParticleSystem(ParticleType.Rain, new Vector3(64, 64, 64), new ParticleSpawner(30, false), game1.Content, 1000, 1000, 1);

            //Load Floor
            Floor.Start(game1.Content, currentCameraPlayerOne, Material.White, currentLight);

            //Load Sounds
            engineSoundFX          = game1.Content.Load <SoundEffect>("engine").CreateInstance();
            engineSoundFX.IsLooped = true;
            engineSoundFX.Volume   = 0.1f;
            engineSoundFX.Play();

            rainSoundFX          = game1.Content.Load <SoundEffect>("rain").CreateInstance();
            rainSoundFX.IsLooped = true;
            rainSoundFX.Volume   = 0.2f;
            rainSoundFX.Play();

            explosionSoundFX = game1.Content.Load <SoundEffect>("explosion");

            battleSoundFX = game1.Content.Load <SoundEffect>("battle_begin");
            battleSoundFX.Play();
        }
示例#2
0
        internal override void Draw(GraphicsDevice device, SpriteBatch batch)
        {
            #region Top viewport
            device.Viewport = upView;
            Skybox.Draw(device, currentCameraPlayerOne);
            Floor.Draw(currentCameraPlayerOne);
            foreach (Enemy e in enemyList)
            {
                e.Draw(device, currentCameraPlayerOne);
            }
            playerOne.Draw(device, currentCameraPlayerOne);
            playerTwo.Draw(device, currentCameraPlayerOne);
            playerOneRain.Draw(device, currentCameraPlayerOne);
            foreach (ParticleSystem p in particleSystemList)
            {
                p.Draw(device, currentCameraPlayerOne);
            }
            Debug.Draw(currentCameraPlayerOne);
            #endregion

            #region Bottom viewport
            device.Viewport = downView;
            Skybox.Draw(device, currentCameraPlayerTwo);
            Floor.Draw(currentCameraPlayerTwo);
            foreach (Enemy e in enemyList)
            {
                e.Draw(device, currentCameraPlayerTwo);
            }
            playerOne.Draw(device, currentCameraPlayerTwo);
            playerTwo.Draw(device, currentCameraPlayerTwo);
            playerTwoRain.Draw(device, currentCameraPlayerTwo);
            foreach (ParticleSystem p in particleSystemList)
            {
                p.Draw(device, currentCameraPlayerTwo);
            }
            Debug.Draw(currentCameraPlayerTwo);
            #endregion

            device.Viewport = defaultView;

            batch.Begin();
            batch.DrawString(Debug.debugFont, playerOne.score.ToString(), new Vector2(device.Viewport.Width / 3, 10.0f), Color.White);
            batch.DrawString(Debug.debugFont, playerTwo.score.ToString(), new Vector2(device.Viewport.Width / 3 * 2, 10.0f), Color.White);
            batch.End();

            device.SamplerStates[0]  = SamplerState.LinearWrap;
            device.BlendState        = BlendState.Opaque;
            device.DepthStencilState = DepthStencilState.Default;
        }
示例#3
0
        /*//DEBUG
         * DebugLine debugLine1;
         * DebugLine debugLine2;
         * DebugLine debugLine3;
         * DebugLine debugLine4;
         * DebugLine debugLine5;
         * DebugLine debugLine6;
         *
         * List<DebugBox> boxes;*/

        //--------------------Constructors--------------------//
        internal GameStage(Game1 game1) : base(game1)
        {
            //Load Viewports
            defaultView      = Game1.graphics.GraphicsDevice.Viewport;
            upView           = downView = defaultView;
            upView.Height   /= 2;
            downView.Height /= 2;
            downView.Y       = upView.Height;

            //Load stuff
            currentLight = new Light(-Vector3.One, new Color(new Vector3(0.5f, 0.5f, 0.5f)), new Color(new Vector3(0.1f, 0.1f, 0.1f)));
            Bullet.LoadModel(game1.Content, Material.White, currentLight);
            Skybox.Load(game1.Content);
            Enemy.Load(game1.Content, Material.White, currentLight);

            //Load Players
            playerList = new List <Player>();
            playerOne  = new Player(new Vector3(64, 10, 64), Vector3.Zero, Vector3.Zero, 0.0005f, PlayerIndex.One);
            playerOne.LoadModelBones(game1.Content, Material.White, currentLight);
            playerList.Add(playerOne);
            playerTwo = new Player(new Vector3(65, 10, 65), Vector3.Zero, Vector3.Zero, 0.0005f, PlayerIndex.Two);
            playerTwo.LoadModelBones(game1.Content, Material.White, currentLight);
            playerList.Add(playerTwo);

            //Load Cameras
            currentCameraPlayerOne = new CameraThirdPersonFixed(game1.GraphicsDevice, new Vector3(64, 5, 65), playerOne.turret, 2.0f, new Vector3(0.0f, 0.1f, 1.0f), new Vector3(-0.2f, 0.3f, 0.2f), upView.AspectRatio);
            currentCameraPlayerTwo = new CameraThirdPersonFixed(game1.GraphicsDevice, new Vector3(64, 5, 65), playerTwo.turret, 2.0f, new Vector3(0.0f, 0.1f, 1.0f), new Vector3(-0.2f, 0.3f, 0.2f), downView.AspectRatio);

            //Load Enemies
            Random r = new Random();

            enemyList = new List <Enemy>();
            for (int i = 0; i < 60; i++)
            {
                enemyList.Add(new Enemy(new Vector3((float)r.NextDouble() * 128.0f, 0, (float)r.NextDouble() * 128.0f), Vector3.Zero, ENEMY_MODE_SCALE, this));
            }

            //Load Particles
            particleSystemList = new List <ParticleSystem>();
            playerOneRain      = new ParticleSystem(ParticleType.Rain, new Vector3(64, 64, 64), new ParticleSpawner(30, false), game1.Content, 1000, 1000, 1);
            playerTwoRain      = new ParticleSystem(ParticleType.Rain, new Vector3(64, 64, 64), new ParticleSpawner(30, false), game1.Content, 1000, 1000, 1);

            //Load Floor
            Floor.Start(game1.Content, currentCameraPlayerOne, Material.White, currentLight);

            //Load Sounds
            engineSoundFX          = game1.Content.Load <SoundEffect>("engine").CreateInstance();
            engineSoundFX.IsLooped = true;
            engineSoundFX.Volume   = 0.1f;
            engineSoundFX.Play();

            rainSoundFX          = game1.Content.Load <SoundEffect>("rain").CreateInstance();
            rainSoundFX.IsLooped = true;
            rainSoundFX.Volume   = 0.2f;
            rainSoundFX.Play();

            explosionSoundFX = game1.Content.Load <SoundEffect>("explosion");


            //TODO: END: CLEAN THIS BEFORE END
            //DEBUG

            /*
             * debugLine1 = new DebugLine(playerOne.cannon.position, playerOne.cannon.position + playerOne.cannon.Forward, Color.Blue);
             * debugLine2 = new DebugLine(playerOne.cannon.position, playerOne.cannon.position + playerOne.cannon.Right, Color.Red);
             * debugLine3 = new DebugLine(playerOne.cannon.position, playerOne.cannon.position + playerOne.cannon.Up, Color.Green);
             * debugLine4 = new DebugLine(playerOne.turret.position, playerOne.turret.position + playerOne.turret.Forward, Color.Cyan);
             * debugLine5 = new DebugLine(playerOne.turret.position, playerOne.turret.position + playerOne.turret.Right, Color.Magenta);
             * debugLine6 = new DebugLine(playerOne.turret.position, playerOne.turret.position + playerOne.turret.Up, Color.Yellow);
             *
             * Debug.AddLine("1", debugLine1);
             * Debug.AddLine("2", debugLine2);
             * Debug.AddLine("3", debugLine3);
             * Debug.AddLine("4", debugLine4);
             * Debug.AddLine("5", debugLine5);
             * Debug.AddLine("6", debugLine6);
             *
             * boxes = new List<DebugBox>();
             * boxes.Add(new DebugBox(playerOne.boundingBox));
             * boxes.Add(new DebugBox(playerTwo.boundingBox));
             * boxes.Add(new DebugBox(playerOne.turret.boundingBox));
             * boxes.Add(new DebugBox(playerOne.cannon.boundingBox));
             * boxes.Add(new DebugBox(playerTwo.turret.boundingBox));
             * boxes.Add(new DebugBox(playerTwo.cannon.boundingBox));
             * foreach(Enemy e in enemyList)
             * {
             *  boxes.Add(new DebugBox(e.boundingBox));
             * }
             * int aux = 0;
             * foreach (DebugBox b in boxes)
             * {
             *  Debug.AddBox(aux.ToString(), b);
             *  aux++;
             * }*/
        }