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(); }
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(); }
public void Add(string carName, Car car) { cars[carName] = car; }
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 } }