/********************************************************************** * * * PROPERTIES * * **********************************************************************/ /********************************************************************** * * * CONSTRUCTORS * * **********************************************************************/ public GameEngine(CommonObjects commonObjects) { this.commonObjects = commonObjects; // Load car car = new Car(1000); //carMesh = LoadMesh(Application.StartupPath + "\\Models\\Car.x", ref carMaterials, ref carTextures); carMesh = Mesh.Box(commonObjects.D3DDevice, 2, 1, 1); // Load map //mapMesh = LoadMesh(Application.StartupPath + "\\Models\\Map.x", ref mapMaterials, ref mapTextures); mapMesh = Mesh.Box(commonObjects.D3DDevice, 40, 1, 40); // Init variables elapsedTime = 0; // Set Debugtext debugText = new RickisDXLib.Text(commonObjects.D3DDevice, new System.Drawing.Font("Arial", 14), "Hi", 10, 10, Color.Blue); carDebugText = new RickisDXLib.Text(commonObjects.D3DDevice, new System.Drawing.Font("Arial", 14), "Hi", 200, 10, Color.Blue); }
public int Steps(Car car, ProgressBar pr) { Console.WriteLine("kyky"); Random rand = new Random(forRand++); int speed; int stepsCount = 0; while (car.Distance < 100) { speed = rand.Next() % 20; if (rand.Next() % 2 == 0) car.Speed = car.MaxSpeed + speed; else car.Speed = car.MaxSpeed - speed; Console.WriteLine(string.Format("{0} {1}", car.Speed.ToString(), car.MaxSpeed.ToString())); car.Distance += (double)((double)car.Speed / 120); int toPrBar = (int)car.Distance; object[] objs = new object[3]; objs[0] = pr; objs[1] = toPrBar; objs[2] = car.Speed; pr.Dispatcher.Invoke(mainWindow.myDelegate, objs); stepsCount++; Thread.Sleep(100); } car.Place = currentPlace++; pr.Dispatcher.Invoke(mainWindow.finishColorDelegate, pr); Console.WriteLine("kykyky"); return stepsCount; }