Пример #1
0
 public virtual void CopyCat(Car car)
 {
     TexturePath = car.TexturePath;
     AcceleratingSpeed = car.AcceleratingSpeed;
     SteerSpeed = car.SteerSpeed;
     MaxSpeed = car.MaxSpeed;
     MinSpeed = car.MinSpeed;
     MaxSpeed_Copy = MaxSpeed;
     MinSpeed_Copy = MinSpeed;
     Init();
 }
Пример #2
0
 public virtual void CopyCat(Car car)
 {
     TexturePath = car.TexturePath;
     AcceleratingSpeed = car.AcceleratingSpeed;
     SteerSpeed = car.SteerSpeed;
     MaxSpeed = car.MaxSpeed;
     MinSpeed = car.MinSpeed;
     MaxSpeed_Copy = MaxSpeed;
     MinSpeed_Copy = MinSpeed;
     if (TexturePath != null)
     {
         ContentManager content = Game1.Singleton.Content;
         texture = content.Load<Texture2D>(TexturePath);
         TexturePath = null;
     }
     Init();
 }
Пример #3
0
 public void Add(string carName, Car car)
 {
     cars[carName] = car;
 }
Пример #4
0
 private void ParseCarsCollisionCheck(Car carA, Car carB, float deltaTime)
 {
     Random random = Game1.Singleton.Random;
     if (carA.Rect.Intersects(carB.Rect))
     {
         #region Steering-Related
         if (carB.X + carB.Width / 2 <= carA.X + carA.Width / 2)
         {
             //오른쪽 충돌
             if (carB.Weight > carA.Weight)
             {
                 //carB가 carA보다 무거움
                 carB.Steer(-10 * deltaTime);
                 carA.Steer(10 * deltaTime);
             }
             else if (carB.Weight < carA.Weight)
             {
                 //carA가 carB보다 무거움
                 carB.Steer(10 * deltaTime);
                 carA.Steer(-10 * deltaTime);
             }
             else
             {
                 //무게가 같음
                 carB.Steer(-10 * deltaTime);
                 carA.Steer(10 * deltaTime);
             }
         }
         else
         {
             //왼쪽 충돌
             if (carB.Weight > carA.Weight)
             {
                 //carB가 carA보다 무거움
                 carB.Steer(10 * deltaTime);
                 carA.Steer(-10 * deltaTime);
                 carB.Accelerate(-20 * deltaTime);
             }
             else if (carB.Weight < carA.Weight)
             {
                 //carA가 carB보다 무거움
                 carB.Steer(-10 * deltaTime);
                 carA.Steer(10 * deltaTime);
                 carA.Accelerate(-20 * deltaTime);
             }
             else
             {
                 //무게가 같음
                 carB.Steer(10 * deltaTime);
                 carA.Steer(-10 * deltaTime);
                 carA.Accelerate(-100 * deltaTime);
                 carB.Accelerate(-100 * deltaTime);
             }
         }
         #endregion
     }
 }