Esempio n. 1
0
        //This method draws the model
        public void DrawModel(Camera camera)
        {
            Matrix[] transforms = new Matrix[ActualModel.Bones.Count]; //Represents the position of each model bone.
            ActualModel.CopyAbsoluteBoneTransformsTo(transforms); //Models have a method that populates an array.

            foreach (ModelMesh mesh in ActualModel.Meshes)
            {
                //BasicEffect is a simplified version of it's parent class Effect.  Effects allow objects to be placed on screen.
                foreach (BasicEffect basicEffect in mesh.Effects)
                {
                    basicEffect.EnableDefaultLighting();
                    basicEffect.Projection = camera.Projection;
                    basicEffect.View = camera.View;
                    //Note, fix up the lighting in here, it getting too dark!

                    basicEffect.EmissiveColor = new Vector3(0.7f);

                    //End Note.

                    basicEffect.World = Matrix.CreateScale(Scale) * World * mesh.ParentBone.Transform; //Positions the mesh in the correct place relavent to the world.
                }
                mesh.Draw();

            }
        }
Esempio n. 2
0
        public void Draw(Camera camera)
        {
            //Sets the CullMode to none and blendstate to additive (Explosions have a black background)
            RasterizerState rs = new RasterizerState();
            rs.CullMode = CullMode.None;
            _device.RasterizerState = rs;
            _device.BlendState = BlendState.Additive;

            foreach (Explosion explosion in _explosionList)
            {
                switch (explosion.ExplosionType)
                {
                    case ExplosionType.Big:
                        _textureQuad.SetTexture(explosion.Index);
                        _textureQuad.Draw(camera, explosion.Position);
                        break;
                    case ExplosionType.Small:
                        _smallTextureQuad.SetTexture(explosion.Index);
                        _smallTextureQuad.Draw(camera, explosion.Position);
                        break;
                }
            }

            //Resets the state of the BlendState and Rasterizer State
            RasterizerState rs2 = new RasterizerState();
            rs2.CullMode = CullMode.CullCounterClockwiseFace;
            _device.RasterizerState = rs2;
            _device.BlendState = BlendState.NonPremultiplied;
        }
Esempio n. 3
0
        public void DrawSkybox(Camera camera, Vector3 shipPosition)
        {
            //A TextureAddressMode.Clamp state removes the seams between the cube.
            SamplerState ss = new SamplerState();
            ss.AddressU = TextureAddressMode.Clamp;
            ss.AddressV = TextureAddressMode.Clamp;
            _device.SamplerStates[0] = ss;

            //Removes the ZBuffer so no size can be set for the skybox.
            DepthStencilState dss = new DepthStencilState();
            dss.DepthBufferEnable = false;
            _device.DepthStencilState = dss;

            Matrix[] transforms = new Matrix[_skyboxModel.Bones.Count]; //Represents the position of each model bone.
            _skyboxModel.CopyAbsoluteBoneTransformsTo(transforms); //Models have a method that populates an array.

            foreach (ModelMesh mesh in _skyboxModel.Meshes)
            {
                //BasicEffect is a simplified version of it's parent class Effect.  Effects allow objects to be placed on screen.
                foreach (BasicEffect basicEffect in mesh.Effects)
                {
                    basicEffect.Projection = camera.Projection;
                    basicEffect.View = camera.View;
                    basicEffect.World =  Matrix.CreateScale(80) * mesh.ParentBone.Transform * Matrix.CreateTranslation(shipPosition); //Positions the mesh in the correct place relavent to the world.

                }
                mesh.Draw();
            }

            //Reenabling the ZBuffer.
            dss = new DepthStencilState();
            dss.DepthBufferEnable = true;
            _device.DepthStencilState = dss;
        }
Esempio n. 4
0
        public void DrawEnemySquadron(Camera camera)
        {
            foreach (Friend friend in FriendList)
            {
                _friendModel.World = friend.ShipWorld;
                _friendModel.DrawModel(camera);
            }

            _weaponSystem.DrawWeapons(camera);
        }
Esempio n. 5
0
File: Sun.cs Progetto: robertg/Soar
        public void Draw(Camera camera)
        {
            //This sets the BlendState to Additive, which allows blending to occur between backgrounds.
            RasterizerState rs = new RasterizerState();
            rs.CullMode = CullMode.None;
            _device.RasterizerState = rs;
            _device.BlendState = BlendState.Additive;

            _textureQuad.Draw(camera, Position);

            RasterizerState rs2 = new RasterizerState();
            rs2.CullMode = CullMode.CullCounterClockwiseFace;
            _device.RasterizerState = rs2;
            _device.BlendState = BlendState.NonPremultiplied;
        }
Esempio n. 6
0
        public PlayerShip(List<Collidable> collidableRef, CollidableType type, float boundingRadius, Model model, Vector3 shipPosition, GraphicsDevice device, Vector3 cameraFollowPosition, float scale, float minShipSpeed, float maxShipSpeed, float acceleration, float turningSpeed,
            float maxTurningSpeed, float minTurningSpeed, WeaponSystem2D weaponSystem2D, MissleSystem2D missleSystem2D, SpawnerManager spawnerManager, PlayerConfig[] playerConfigurations)
        {
            CollidableReference = collidableRef;

            _shipModel = new BasicModel(model, scale);

            ShipWorld = Matrix.CreateTranslation(shipPosition) * Matrix.CreateScale(scale);
            _dockingPosition = shipPosition;
            ShipPosition = shipPosition;

            _shipRotation = Quaternion.Identity;

            Camera = new Camera(device, cameraFollowPosition);

            _keyboard = new KeyboardInput();

            _minShipSpeed = minShipSpeed;
            _maxShipSpeed = maxShipSpeed;
            _acceleration = acceleration;
            _turningSpeed = turningSpeed;
            _gamePadInput = new GamePadInput();

            _weaponSystem2D = weaponSystem2D;
            _device = device;
            _shipRotation.Normalize();

            //Collidable Properties
            this.CollidableType = type;
            this.BoundingSphereRadius = boundingRadius;

            _maxTurningSpeed = maxTurningSpeed;
            _minTurningSpeed = minTurningSpeed;

            Life = 0;

            _soundDump = new List<Sound>();

            spawnerManager.Selected += (object sender, EventArgs args) =>
                {
                    SpawnerManager SM = sender as SpawnerManager;
                    Spawn(SM._selected);
                };

            _missleSystem2D = missleSystem2D;

            _playerConfigurations = playerConfigurations;
        }
Esempio n. 7
0
        public void DrawEnemySquadron(Camera camera)
        {
            foreach (Enemy enemy in EnemyList)
            {
                if (!enemy.IsFrigate)
                {
                    _enemyModel.World = enemy.ShipWorld;
                    _enemyModel.DrawModel(camera);
                }
                else
                {
                    //The enemy is a frigate. Let's draw it.
                    (enemy as EnemyFrigate).Draw(camera);
                }
            }

            _enemyWeaponSystem.DrawWeapons(camera);
        }
Esempio n. 8
0
        public void Draw(Camera camera)
        {
            //Sets the CullMode to none and blendstate to additive (Explosions have a black background)
            RasterizerState rs = new RasterizerState();
            rs.CullMode = CullMode.None;
            _device.RasterizerState = rs;
            _device.BlendState = BlendState.Additive;

            foreach (Particle particle in _particleList)
            {
                        _textureQuad.SetTexture(particle.Index);
                        _textureQuad.Draw(camera, particle.Position);
            }

            //Resets the state of the BlendState and Rasterizer State
            RasterizerState rs2 = new RasterizerState();
            rs2.CullMode = CullMode.CullCounterClockwiseFace;
            _device.RasterizerState = rs2;
            _device.BlendState = BlendState.NonPremultiplied;
        }
Esempio n. 9
0
 public void OverlayDraw(Camera camera, Vector3 shipPosition)
 {
     _textureQuad.Draw(camera, shipPosition);
 }
Esempio n. 10
0
        public void Draw(Camera camera, List<Friend> friendList, List<Enemy> enemyList, List<Objective> objectiveList)
        {
            if (!_respawn)
            {
                _spriteBatch.Begin();
                foreach (Contact contact in _contactList)
                {
                    _spriteBatch.Draw(_radarImages[(int)contact.State], new Vector2(_device.Viewport.Width - 140 + contact.Position.X, contact.Position.Y + 120), Color.White);
                }

                //Hard coded HUD Overlay Positions, dependant on the screenWidth and height.

                //Bottom Left Overlay
                _spriteBatch.Draw(_HUDImages[0], new Vector2(0, _device.Viewport.Height - 50), Color.White);
                if (_lifeInt > 70)
                    _spriteBatch.DrawString(_HUDFont, _life, new Vector2(0, _device.Viewport.Height - 45), Color.DarkGreen);
                else if (_lifeInt > 50)
                    _spriteBatch.DrawString(_HUDFont, _life, new Vector2(0, _device.Viewport.Height - 45), Color.Yellow);
                else
                    _spriteBatch.DrawString(_HUDFont, _life, new Vector2(0, _device.Viewport.Height - 45), Color.Red);
                _spriteBatch.DrawString(_HUDFont, _missles, new Vector2(110, _device.Viewport.Height - 45), Color.White);

                //Bottom Right Overlay
                _spriteBatch.Draw(_HUDImages[1], new Vector2(_device.Viewport.Width - 250, _device.Viewport.Height - 50), Color.White);
                _spriteBatch.DrawString(_HUDFont, _speed, new Vector2(_device.Viewport.Width - 200, _device.Viewport.Height - 45), Color.White);

                //Top Left Overlay
                _spriteBatch.Draw(_HUDImages[2], new Vector2(0, 0), Color.White);
                _spriteBatch.DrawString(_HUDFont, (int)_timeLeft.TotalMinutes + "m :" + (int)_timeLeft.Seconds + "s", new Vector2(45, 4), Color.White);

                //Middle Overlay
                _spriteBatch.Draw(_HUDImages[3], new Vector2(_device.Viewport.Width / 2 - 150, 0), Color.White);
                _spriteBatch.DrawString(_HUDFont, _amountFriends.ToString(), new Vector2(_device.Viewport.Width / 2 - 90, 0), Color.White); //Draws how many friends.
                _spriteBatch.DrawString(_HUDFont, _amountEnemies.ToString(), new Vector2(_device.Viewport.Width / 2 + 20, 0), Color.White); //Draws how many enemies.

                //Cross Hair
                _spriteBatch.Draw(_crosshair, new Vector2(_device.Viewport.Width / 2 - 18, _device.Viewport.Height / 2 - 110), Color.White);

                //Objective Drawing:
                _spriteBatch.DrawString(_HUDFont, "Objectives", new Vector2(0, 70), Color.White);

                for (int i = 0; i < objectiveList.Count; i++)
                {
                    if (objectiveList[i].IsDone && !objectiveList[i].IsFailed)
                        _spriteBatch.DrawString(_HUDFontSmall, objectiveList[i].Title, new Vector2(0, 70 + (i * 30 + 40)), Color.Green);
                    else if (objectiveList[i].IsDone)
                        _spriteBatch.DrawString(_HUDFontSmall, objectiveList[i].Title, new Vector2(0, 70 + (i * 30 + 40)), Color.Red);
                    else
                        _spriteBatch.DrawString(_HUDFontSmall, objectiveList[i].Title, new Vector2(0, 70 + (i * 30 + 40)), Color.White);
                }

                if (_leavingBattlefield)
                {
                    _spriteBatch.DrawString(_HUDFont, "You are leaving the Battlefield", new Vector2(_device.Viewport.Width / 2 - 300, _device.Viewport.Height - 300), Color.White);
                }

                if (_spaceBattle)
                {
                    _spriteBatch.DrawString(_HUDFont, "Score: " + _score, new Vector2(_device.Viewport.Width - 200, _device.Viewport.Height - 125), Color.White);
                }

                _spriteBatch.End();

                RasterizerState rs = new RasterizerState();
                rs.CullMode = CullMode.None;
                _device.RasterizerState = rs;
                _device.BlendState = BlendState.NonPremultiplied;

                foreach (Enemy enemy in enemyList)
                {
                    _enemyOverlay.OverlayDraw(camera, enemy.ShipPosition);
                }

                foreach (Friend friend in friendList)
                {
                    _friendOverlay.OverlayDraw(camera, friend.ShipPosition);
                }

                RasterizerState rs2 = new RasterizerState();
                rs2.CullMode = CullMode.CullCounterClockwiseFace;
                _device.RasterizerState = rs2;

            }
            else
            {
                _spawnerManager.DrawSpawner(_spriteBatch);

                _spriteBatch.Begin();
                //Middle Overlay
                _spriteBatch.Draw(_HUDImages[3], new Vector2(_device.Viewport.Width / 2 - 150, 0), Color.White);
                _spriteBatch.DrawString(_HUDFont, _amountFriends.ToString(), new Vector2(_device.Viewport.Width / 2 - 90, 0), Color.White); //Draws how many friends.
                _spriteBatch.DrawString(_HUDFont, _amountEnemies.ToString(), new Vector2(_device.Viewport.Width / 2 + 20, 0), Color.White); //Draws how many enemies.

                _spriteBatch.DrawString(_HUDFont, "Choose your ship, press F to spawn", new Vector2(_device.Viewport.Width / 2 - 350, _device.Viewport.Height - 300), Color.White);
                _spriteBatch.End();
            }
        }
Esempio n. 11
0
        public void Update(Camera camera, Vector3 playerPos, Quaternion rotation)
        {
            foreach (Particle particle in _particleList)
            {
                if (particle.Index >= amtTextures - 1)
                {
                    particle.Reset(playerPos, rotation);
                }
                particle.Update();

                particle.Distance = Vector3.Distance(camera.CameraPosition, particle.Position);
            }
            SortByDistance();
        }
Esempio n. 12
0
        public void DrawWeapons(Camera camera)
        {
            if (_projectileList.Count() > 0)
            {
                //This sets the BlendState to Additive, which allows blending to occur between backgrounds.
                RasterizerState rs = new RasterizerState();
                rs.CullMode = CullMode.None;
                _device.RasterizerState = rs;
                _device.BlendState = BlendState.Additive;

                foreach (Projectile projectile in _projectileList)
                {
                    _textureQuad.Draw(camera, projectile.Position);
                }

                RasterizerState rs2 = new RasterizerState();
                rs2.CullMode = CullMode.CullCounterClockwiseFace;
                _device.RasterizerState = rs2;
                _device.BlendState = BlendState.NonPremultiplied;
            }
        }
Esempio n. 13
0
 public virtual void Draw(GraphicsDevice device, Camera camera)
 {
 }
Esempio n. 14
0
 public void DrawBase(Camera camera)
 {
     _baseModel.DrawModel(camera);
 }
Esempio n. 15
0
File: Dock.cs Progetto: robertg/Soar
 public void Draw(Camera camera)
 {
     _model.DrawModel(camera);
 }
Esempio n. 16
0
 public override void Draw(GraphicsDevice device, Camera camera)
 {
     _model.DrawModel(camera);
 }
Esempio n. 17
0
        /// <summary>
        /// Draws the Model of the Enemy Frigate.
        /// </summary>
        /// <param name="camera">Represents the player camera variable.</param>
        public void Draw(Camera camera)
        {
            _model.DrawModel(camera);

            //Draw Weapons:
            foreach (WeaponSystem2D ws in _weaponsList)
            {
                ws.DrawWeapons(camera);
            }
        }
Esempio n. 18
0
        /// <summary>
        /// Draws a billboard that rotates around a certain axis.
        /// </summary>
        public void Draw(Camera camera, Vector3 objectPosition, Quaternion rotateAxis)
        {
            _effect.GraphicsDevice.SetVertexBuffer(vertexBuffer);
            _effect.World = Matrix.CreateConstrainedBillboard(objectPosition, camera.CameraPosition, Vector3.Transform(Vector3.Zero, rotateAxis), null, null);
            //_effect.World = Matrix.CreateConstrainedBillboard(objectPosition, camera.CameraPosition, Vector3.Transform(Vector3.Zero, rotateAxis), Vector3.Transform(Vector3.Zero, camera.CameraRotation), Vector3.Transform(Vector3.Zero, rotateAxis));
            _effect.View = camera.View;
            _effect.Projection = camera.Projection;

            foreach (EffectPass pass in _effect.CurrentTechnique.Passes)
            {
                pass.Apply();
                _effect.GraphicsDevice.DrawPrimitives(PrimitiveType.TriangleStrip, 0, 2);
            }
        }
Esempio n. 19
0
        public void Draw(Camera camera)
        {
            _sun.Draw(camera);

            //Draws each Asteroid dependant on the type of asteroid they are.  This ensures as little memory is used.
            foreach (Asteroid asteroid in _asteroidList)
            {
                _asteroidModels[(int)asteroid.AsteroidType].World = asteroid.World;
                _asteroidModels[(int)asteroid.AsteroidType].Rotation = asteroid.Rotation;
                _asteroidModels[(int)asteroid.AsteroidType].DrawModel(camera);
            }

            _levelPlanet.DrawPlanet(camera);
            PlayerStarBase.DrawBase(camera);
            EnemyStarBase.DrawBase(camera);
            _dock.Draw(camera);

            foreach (Objective obj in ObjectiveList)
            {
                obj.Draw(_device, camera);
            }
        }
Esempio n. 20
0
        public void Draw(Camera camera)
        {
            Level.Draw(camera);
            EnemySquadron.DrawEnemySquadron(camera);
            FriendSquadron.DrawEnemySquadron(camera);

            ExplosionEngine.Draw(camera);
        }
Esempio n. 21
0
 public void DrawPlanet(Camera camera)
 {
     //Draws the planet.
     _planetModel.DrawModel(camera);
 }
Esempio n. 22
0
 public override void Draw(GraphicsDevice device, Camera camera)
 {
     base.Draw(device, camera);
 }