Beispiel #1
0
        private void UpdateWorld()
        {
            foreach (LogicControl LC in logicControls)
            {
                LC.HandleCollision();

                foreach (RoadUser roadUser in LC.Intersection.RoadUsers)
                {
                    roadUser.Move();
                    roadUser.Speed = roadUser.MaxSpeed;
                }

                LC.MakeTurn();
                LC.TransferCarsBetweenIntersections();
                LC.RemoveOutsideScreenRoadUser();
                LC.HandleTrafficLight();

                if (enableMessageServer)
                {
                    try
                    {
                        LC.CheckSpeed();
                        LC.CheckRedLight();
                    }
                    catch (EndpointNotFoundException)
                    {
                        messageServerToggle(null, null);
                        DialogResult result = MessageBox.Show("Kon geen verbinding maken met de berichten server.", "Geen verbinding", MessageBoxButtons.RetryCancel, MessageBoxIcon.Exclamation);
                        if (result == System.Windows.Forms.DialogResult.Retry)
                        {
                            messageServerToggle(null, null);
                        }
                    }
                }

                LC.Intersection.Invalidate();
                toolStripStatusLabelTotal.Text = "Tot: " + totalRoadUsers();
            }
        }