/// <summary> /// Ctor of magasin /// </summary> public Magasin() { rdm = new Random(); ClosedCaisses = new List <Caisse>(); OpenedCaisses = new List <Caisse>(); Clients = new List <Client> { new Client(rdm) }; counterControle = 0; //Timer Refresh timerRefresh = new Timer(); timerRefresh.Interval = 1000 / 60; //60 fps timerRefresh.Enabled = true; timerRefresh.Tick += new EventHandler(OnTick); //Timer Spawn Client timerSpawnClient = new Timer(); timerSpawnClient.Interval = 1000; // each second timerSpawnClient.Enabled = true; timerSpawnClient.Tick += new EventHandler(CreateClient); //Timer Controle Caisse timerControl = new Timer(); timerControl.Interval = 100; // 10 times per second timerControl.Enabled = true; timerControl.Tick += new EventHandler(Controle); DoubleBuffered = true; //Display all clients foreach (Client client in Clients) { Paint += client.Paint; } //Create and display the Caisses for (int i = 0; i < NUMBER_OF_CAISSES; i++) { Caisse c = new Caisse(i); ClosedCaisses.Add(c); Paint += c.Paint; } //Open the first caisse OpenCaisse(); }
/// <summary> /// When the Client finished his shopping /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void CourseFinished(object sender, EventArgs e) { CaisseAttributed = null; State = WAITING; Shopping.Stop(); //Call the event OnCaisseAttribution(EventArgs.Empty); //If the event goes wrong, then don't die if (CaisseAttributed == null) { Console.WriteLine("Pas de caisse"); GoTo(new PointF(100, 100)); } else { GoTo(CaisseAttributed.Position); } }