示例#1
0
        public void InteractOrdre(List <Vehicule> allVehicule, List <int> ordreVehicule, int rayonRoute)
        {
            int margeSecurite = this.rayon + 5;
            int i             = ordreVehicule.IndexOf(this.id);

            if (i > 0)
            {
                Vehicule vehicu_devant = allVehicule.Find(a => a.id == ordreVehicule[i - 1]);

                // Cas des rajouts de voitures en retard: on les remet au même niveau (id en dernière position)
                if (vehicu_devant.angleCumu > 360 && this.angleCumu < 360 && this.id == ordreVehicule.Count())
                {
                    this.angleCumu = vehicu_devant.angleCumu - 10 - margeSecurite;
                }

                int nextPos = (this.angleCumu + this.angleMvt);

                if (nextPos + margeSecurite > vehicu_devant.angleCumu)
                {
                    this.Freine();
                }
                else
                {
                    this.Accelere();
                }
            }

            this.Avance(rayonRoute);
        }
示例#2
0
        private void AddNewVehicule()
        {
            int    vitesse   = 0;
            Random r         = new Random();
            int    id        = this.allVehicule.Count() + 1; // id unique
            int    rayon     = r.Next(10) + 3;
            int    epaisseur = r.Next(3) + 1;

            vitesse = r.Next(30) + 5;

            Vehicule v = new Vehicule(id, this.vehiculeStartX, this.vehiculeStartY, rayon, this.epaisseurVehicule, vitesse);

            this.allVehicule.Add(v);
            this.ordreVehicule.Add(id);
        }
示例#3
0
        public void Init()
        {
            InitializeComponent();
            this.routeX     = (int)this.MainCanvas.Width / 2;
            this.routeY     = (int)this.MainCanvas.Height / 2;
            this.routeRayon = (int)this.MainCanvas.Height / 2 - 30;

            this.vehiculeStartX = this.routeX;
            this.vehiculeStartY = this.routeY;
            this.route          = new Route(this.routeX, this.routeY, this.routeRayon, this.epaisseurRoute);
            this.allVehicule    = new List <Vehicule>();
            this.ordreVehicule  = new List <int>();

            this.premierVehicule = new Vehicule(0, this.vehiculeStartX, this.vehiculeStartY, this.vehiculeRayon, this.epaisseurVehicule, 10);
            this.allVehicule.Add(premierVehicule);
            this.ordreVehicule.Add(0);
        }