Ejemplo n.º 1
0
        /// <summary>
        /// Add a new particle system
        /// </summary>
        public void Add(ParticleSystem ps)
        {
            // add to list of active particle systems
            systems.AddLast(ps);

            // set particles to vertex array
            int count = ps.AddToVertArray(vertices, vertexCount,
                GameOptions.MaxParticles - vertexCount);

            // if any particles created
            if (count > 0)
            {
                // set new particles to vertex buffer
                vertexBuffer.SetData<VertexPositionNormalTexture>(vertices);

                // add the number particles created 
                // (one vertex per particle as we are using point sprites)
#endregion


                vertexCount += count;
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Create a new particle system and add it to the particle system manager
        /// </summary>
        public ParticleSystem AddParticleSystem(
            ParticleSystemType type,
            Matrix transform)
        {
            ParticleSystem ps = null;

            switch (type)
            {
                case ParticleSystemType.ShipExplode:
                    ps = new ParticleSystem(
                                ParticleSystemType.ShipExplode,
                                200,                    // num particles
                                0.0f,                   // emission angle (0 for omni)
                                0.8f, 0.8f,             // particle and total time
                                20.0f, 50.0f,           // min and max size
                                600.0f, 1000.0f,        // min and max vel
                                new Vector4(1.0f, 1.0f, 1.0f, 1.6f),    // start color
                                new Vector4(1.0f, 1.0f, 1.0f, 0.0f),    // end color
                                particleTextures[(int)type],          // texture
                                DrawMode.Additive,       // draw mode
                                transform);              // transform
                    break;
                case ParticleSystemType.ShipTrail:
                    ps = new ParticleSystem(
                                ParticleSystemType.ShipTrail,
                                100,                    // num particles
                                5.0f,                   // emission angle (0 for omni)
                                0.5f, 2.0f,             // particle time and total time
                                50.0f, 100.0f,          // min and max size
                                1000.0f, 1500.0f,       // min and max vel
                                new Vector4(0.5f, 0.2f, 0.0f, 1.0f),    // start color
                                new Vector4(1.0f, 0.0f, 0.0f, 0.0f),    // end color
                                particleTextures[(int)type],            // texture
                                DrawMode.AdditiveAndGlow,  // draw mode
                                transform);                // transform
                    break;
                case ParticleSystemType.MissileExplode:
                    ps = new ParticleSystem(
                                ParticleSystemType.MissileExplode,
                                200,                    // num particles
                                0.0f,                   // emission angle (0 for omni)
                                0.5f, 0.5f,             // particle and total time
                                20.0f, 60.0f,           // min and max size
                                800.0f, 1200.0f,        // min and max vel
                                new Vector4(1.0f, 1.0f, 1.0f, 1.5f),    // start color
                                new Vector4(1.0f, 1.0f, 1.0f, -0.5f),   // end color
                                particleTextures[(int)type],          // texture
                                DrawMode.AdditiveAndGlow,      // draw mode
                                transform);              // transform
                    break;
                case ParticleSystemType.MissileTrail:
                    ps = new ParticleSystem(
                                ParticleSystemType.MissileTrail,
                                100,                    // num particles
                                10.0f,                  // emission angle (0 for omni)
                                0.5f, 1.0f,             // particle time and total time
                                15.0f, 30.0f,           // min and max size
                                1000.0f, 1500.0f,       // min and max vel
                                new Vector4(0.5f, 0.2f, 0.0f, 1.0f),    // start color
                                new Vector4(1.0f, 0.0f, 0.0f, 0.0f),    // end color
                                particleTextures[(int)type],          // texture
                                DrawMode.AdditiveAndGlow,      // draw mode
                                transform);              // transform
                    break;
                case ParticleSystemType.BlasterExplode:
                    ps = new ParticleSystem(
                                ParticleSystemType.BlasterExplode,
                                40,                      // num particles
                                2,                       // emission angle (0 for omni)
                                0.25f, 0.25f,            // particle time and total time
                                30.0f, 40.0f,            // min and max size
                                200.0f, 800.0f,          // min and max vel
                                new Vector4(1.0f, 1.0f, 1.0f, 1.5f),    // start color
                                new Vector4(1.0f, 1.0f, 1.0f, -0.2f),   // end color
                                particleTextures[(int)type],          // texture
                                DrawMode.AdditiveAndGlow,      // draw mode
                                transform);               // transform
                    break;
            }

            if (ps != null)
                particle.Add(ps);

            return ps;
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Set projectile trail parameters
 /// </summary>
 public void SetTrail(ParticleSystem trail, Matrix transform)
 {
     system = trail;
     systemTransform = transform;
 }
Ejemplo n.º 4
0
        // collision box radius
        /// <summary>
        /// Create a new player ship
        /// </summary>
        public PlayerShip(
            GameManager game,        // game manager
            int player,              // player id
            Model model,             // model for player ship
            EntityList entities,     // entity list for ship model
            float radius)
        {
            if (game == null)
            {
                throw new ArgumentNullException("game");
            }
            if (entities == null)
            {
                throw new ArgumentNullException("entities");
            }

            // save parameters
            gameManager = game;
            shipModel = model;
            shipEntities = entities;
            playerIndex = player;

            // create movement controller
            movement = new PlayerMovement();
            movement.maxVelocity = GameOptions.MovementVelocity;

            // enable collision sound
            collisionSound = true;

            // create engine particle system with infinite life time
            particleBoost = gameManager.AddParticleSystem(
                                                ParticleSystemType.ShipTrail,
                                                transform);
            particleBoost.SetTotalTime(1e10f);
            boostTransform = shipEntities.GetTransform("engine");

            // create the ship collision box
            box = new CollisionBox(-radius, radius);

            // random bobbing offset
            random = new Random(player);
            bobbingTime = (float)random.NextDouble();

            // setup 3rd person camera parameters
            camera3rdPerson = false;
            chaseCamera = new ChaseCamera();
            chaseCamera.DesiredPositionOffset = GameOptions.CameraOffset;
            chaseCamera.LookAtOffset = GameOptions.CameraTargetOffset;
            chaseCamera.Stiffness = GameOptions.CameraStiffness;
            chaseCamera.Damping = GameOptions.CameraDamping;
            chaseCamera.Mass = GameOptions.CameraMass;
        }