示例#1
0
 public void setThrust(Camera camera)
 {
     Velocity += VelocityAdd;
     engineParticle.getParticles().Add(engineParticle.GenerateNewParticle(Position + (-0.725f * RotationMatrix.Up), Velocity * 0.5f, camera));
     if (engineInstance.State == SoundState.Stopped)
     {
         engineInstance.Volume   = 0.75f;
         engineInstance.IsLooped = true;
         engineInstance.Play();
     }
     else
     {
         engineInstance.Resume();
     }
 }
示例#2
0
        public void Update(float timeDelta, Model[] asteroidModel, Camera camera)
        {
            for (int i = 0; i < asteroidList.Count(); i++)
            {
                asteroidList[i].Update(timeDelta);
                if (asteroidList[i].IsActive() == false)
                {
                    asteroidList[i].addLife(-1);
                    if (asteroidList[i].getLife() > 0)
                    {
                        //(-Y, X)
                        //(Y, -X)
                        //adds two more asteroids when one is destroyed
                        Vector3 perpendicularVector1 = new Vector3(-asteroidList[i].getVelocity().Y, asteroidList[i].getVelocity().X, 0); //maybe we should add bullet vector?
                        Vector3 perpendicularVector2 = new Vector3(asteroidList[i].getVelocity().Y, -asteroidList[i].getVelocity().X, 0); //maybe we should add bullet vector?
                        Vector3 newVector1           = ((asteroidList[i].getVelocity() * 2) + perpendicularVector1 + bulletVector) / 4;
                        Vector3 newVector2           = ((asteroidList[i].getVelocity() * 2) + perpendicularVector2 + bulletVector) / 4;
                        AddAsteroid(
                            asteroidModel[asteroidList[i].getLife() - 1], //pass in smaller roid
                            asteroidList[i].getPosition().X,              //pass in x position of parent roid
                            asteroidList[i].getPosition().Y,              //pass in y position of parent roid

                            newVector1.X,
                            newVector1.Y,
                            asteroidList[i].getSpeed(),
                            asteroidList[i].getLife(), 10 * asteroidList[i].getLife());// adds perpendicular vector (-y, x)

                        AddAsteroid(
                            asteroidModel[asteroidList[i].getLife() - 1], //pass in smaller model
                            asteroidList[i].getPosition().X,              //pass in x position of parent roid
                            asteroidList[i].getPosition().Y,              //pass in y position of parent roid
                            newVector2.X,
                            newVector2.Y,
                            asteroidList[i].getSpeed(),
                            asteroidList[i].getLife(), 10 * asteroidList[i].getLife());// adds perpendicular vector (y, -x)
                    }
                    int total = 25;
                    for (int j = 0; j < total; j++)
                    {
                        Vector3 velocity = new Vector3(1f * (float)(random.NextDouble() * 2 - 1), 1f * (float)(random.NextDouble() * 2 - 1), 0);
                        asteroidParticle.getParticles().Add(asteroidParticle.GenerateNewParticle(asteroidList[i].getPosition(), Vector3.Multiply(velocity, 0.1f), camera));
                    }
                    asteroidList.RemoveAt(i); // removes old asteroid
                    i--;
                }
            }
            asteroidParticle.Update();
        }