public void Release(Speedometer s, GearChanger gc) { this.pressedClutch = false; int currentGear = gc.getGear(); new Thread(() => { Thread.CurrentThread.IsBackground = true; //must wait a time gap till pedal is released fully w = new Waiter(10); w.RunThread(); }).Start(); if (currentGear > this.lastGear) { if (this.lastSpeed > 60f) { s.setSpeed(this.lastSpeed - 25f); } else if (this.lastSpeed < 20f) { s.KillEngine(); Console.WriteLine("engine stopped " + this.lastSpeed.ToString()); } } else if (currentGear < this.lastGear) { if (currentGear != 0) { if (this.lastSpeed < 120f && this.lastSpeed > 20f) { s.setSpeed(this.lastSpeed + 25f); } else if (this.lastSpeed < 20f) { s.KillEngine(); Console.WriteLine("engine stopped "); } } } else if (currentGear == this.lastGear && currentGear != 0) { s.setSpeed(this.lastSpeed); } }
public void BasicForm_KeyDown(object sender, KeyEventArgs e) { if (e.KeyValue == 81 && !c.isClutchPressed()) //if press clutch (q) and haven't before { Action action = () => c.Press(s, gc); this.Invoke(action); } else if (e.KeyValue == 80 && c.isClutchPressed() && !Waiter.getStop()) //if press shift_up(p) and clutch is pressed { gc.ShiftUP(s); } else if (e.KeyValue == 76 && c.isClutchPressed() && !Waiter.getStop()) { gc.ShiftDOWN(s); } else if (e.KeyValue == 87 && !Waiter.getStop() && !c.isClutchPressed()) { s.setwPressed(true); switch (gc.getGear()) { case 0: s.increaseSpeed(8f); break; case 1: s.increaseSpeed(2f); break; case 2: s.increaseSpeed(1.5f); break; case 3: s.increaseSpeed(1f); break; case 4: s.increaseSpeed(0.9f); break; case 5: s.increaseSpeed(0.7f); break; case 6: s.increaseSpeed(0.5f); break; } } else if (e.KeyValue == 81 && s.getwPressed()) { s.setwPressed(false); Action action = () => c.Press(s, gc); this.Invoke(action); } else if (e.KeyValue == 87 && c.isClutchPressed() && gc.getGear() == 1) { s.Ignition(); c.setLastSpeed(30f); s.setSpeed(30f); } }