Esempio n. 1
0
 public void ShiftDOWN(Speedometer s)
 {
     if (canGearDOWN)
     {
         GearDOWN(); //change gear without delay
     }
 }
Esempio n. 2
0
 public PainterUpdater(BasicForm f, Speedometer s)
 {
     blackPen = new Pen(Color.Black, 3);
     g = f.CreateGraphics();
     this.f = f;
     this.s = s;
 }
Esempio n. 3
0
        public BasicForm(Speedometer s, GearChanger gc, Clutch c)
        {
            this.s  = s;
            this.gc = gc;
            this.c  = c;

            InitializeComponent();
        }
Esempio n. 4
0
        public void ShiftUP(Speedometer s)
        {
            float speed = s.getSpeed();

            if (canGearUP)
            {
                GearUP(speed); //change gear without delay
            }
        }
Esempio n. 5
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Speedometer s  = new Speedometer();
            GearChanger gc = new GearChanger();
            Clutch      c  = new Clutch();
            BasicForm   f  = new BasicForm(s, gc, c);

            f.MinimumSize = new System.Drawing.Size(500, 500);
            f.MaximumSize = new System.Drawing.Size(500, 500);
            f.MaximizeBox = false;
            f.MinimizeBox = false;
            Application.Run(f);
        }
Esempio n. 6
0
        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);
            }
        }
Esempio n. 7
0
        public void Press(Speedometer s, GearChanger gc)
        {
            this.pressedClutch = true;
            this.lastSpeed     = s.getSpeed();
            this.lastGear      = gc.getGear();
            //need to make this function unblocking
            if (gc.getGear() != 0)
            {
                new Thread(() =>
                {
                    Thread.CurrentThread.IsBackground = true;
                    while (this.isClutchPressed()) //while engine isn't engaged
                    {
                        System.Threading.Thread.Sleep(10);
                        s.decreaseSpeed(5f);
                    }
                }).Start();


                this.pressFinished = true;
            }
        }
Esempio n. 8
0
 public ClassicDecreaser(Speedometer s)
 {
     this.s = s;
 }