Ejemplo n.º 1
0
        internal static void RouteCar(MoveablePictureBox car)
        {
            if (!car.IsGoesFilling)
            {
                return;
            }

            CarView       carView       = null;
            CollectorView collectorView = null;

            if (car is CarPictureBox)
            {
                carView = car.Tag as CarView;
            }

            if (car is CollectorPictureBox)
            {
                collectorView = car.Tag as CollectorView;
            }

            var isOnStation = car.IsOnStation;
            var isFilled    = car.IsFilled;

            // New car
            if (!isOnStation && !isFilled && !car.HasDestPoints())
            {
                GoToEnter(car);
            }

            // Just entered the station
            if (car is CarPictureBox carPictureBox)
            {
                if (isOnStation && !carView.IsFuelDispenserChosen)
                {
                    ChooseFuelDispenser(carPictureBox);
                }
            }

            if (car is CollectorPictureBox collector)
            {
                if (isOnStation && !collectorView.IsGoesToCashCounter)
                {
                    GoToCashCounter(collector);
                }
            }

            // After filling
            if (isOnStation && isFilled)
            {
                GoToExit(car);
                car.IsOnStation = false;
            }
        }
Ejemplo n.º 2
0
        public CollectorPictureBox(ModelingForm modelingForm, CollectorView collectorView)
        {
            Tag      = collectorView;
            Image    = Properties.Resources.collector_35x17_;
            Location = DestinationPointsDefiner.SpawnPoint;
            SizeMode = PictureBoxSizeMode.AutoSize;

            IsGoesFilling = true;

            MouseClick += ClickEventProvider.CashCollectorPictureBox_Click;

            modelingForm.PlaygroundPanel.Controls.Add(this);
            BringToFront();
        }
 internal static CollectorPictureBox CreateCollectorPictureBox(CollectorView collectorView)
 {
     return(new CollectorPictureBox(_modelingForm, collectorView));
 }
Ejemplo n.º 4
0
        internal static void MoveCarToDestination(MoveablePictureBox car)
        {
            CarView       carView       = null;
            CollectorView collectorView = null;

            if (car is CarPictureBox)
            {
                carView = car.Tag as CarView;
            }

            if (car is CollectorPictureBox)
            {
                collectorView = car.Tag as CollectorView;
            }

            if (car.IsFilling)
            {
                if (car is CarPictureBox carPictureBox)
                {
                    var chosenFuelDispenser = (FuelDispenserView)carView.ChosenFuelDispenser.Tag;

                    ModelingProcessor.FillCar(carPictureBox, chosenFuelDispenser);

                    return;
                }

                if (car is CollectorPictureBox collector)
                {
                    var cashCounter = collectorView.CashCounter.Tag as CashCounterView;

                    ModelingProcessor.CollectCash(collector, cashCounter);

                    return;
                }
            }

            var        destPoint = car.GetDestinationPoint();
            PictureBox destSpot  = car.DestinationSpot;

            var carSpeed = car.IsGoesFilling ? _carSpeedFilling : _carSpeedNoFilling;

            #region MotionLogic

            destPoint = MoveCar(car, destPoint, carSpeed);

            #endregion /MotionLogic


            if (car.DestinationSpot == null)
            {
                destSpot = car.CreateDestinationSpot(destPoint);
                _modelingForm.PlaygroundPanel.Controls.Add(destSpot);
            }

            if (car.Bounds.IntersectsWith(destSpot.Bounds))
            {
                car.RemoveDestinationPoint(_modelingForm);

                car.IsBypassingObject = false;
                //_isGoHorizontal = false;
                //_isGoVertical = false;

                if (destPoint.Equals(DestinationPointsDefiner.EnterPoint3))
                {
                    car.IsOnStation = true;
                }

                if (car.IsGoesHorizontal && destPoint.Equals(car.FromLeftBypassingPoint))
                {
                    car.IsGoesHorizontal = false;
                    //var x = 1;
                }

                if (car is CarPictureBox carPictureBox)
                {
                    foreach (var fuelDispensersDestPoint in DestinationPointsDefiner.FuelDispensersDestPoints.Values)
                    {
                        if (destPoint.Equals(fuelDispensersDestPoint))
                        {
                            ModelingProcessor.StartFilling(carPictureBox, carView.ChosenFuelDispenser);
                            //test
                            //carView.IsFilled = true;
                        }
                    }
                }

                if (car is CollectorPictureBox collector)
                {
                    if (destPoint.Equals(DestinationPointsDefiner.CashCounter))
                    {
                        ModelingProcessor.StartCollectingCash(collector, collectorView.CashCounter.Tag as CashCounterView);
                        return;
                    }
                }

                if (destPoint.Equals(DestinationPointsDefiner.ExitPoint1))
                {
                    car.IsOnStation = false;
                }

                if (destPoint.Equals(DestinationPointsDefiner.LeavePointNoFilling) || destPoint.Equals(DestinationPointsDefiner.LeavePointFilled))
                {
                    _modelingForm.PlaygroundPanel.Controls.Remove(car);
                    car.Dispose();
                }
            }
        }
Ejemplo n.º 5
0
 private static extern void collect(IntPtr collector, IntPtr world, CollectorView view);