Exemplo n.º 1
0
 public void StopLoad(Transporter t)
 {
     if (transporter == t)
     {
         transporter = null;
     }
 }
Exemplo n.º 2
0
        public void Update()
        {
            while (true)
            {
                if (transporterManager.CheckRepairQueue() && transporter == null)
                {
                    transporter = transporterManager.GetToRepairWorker() as Transporter;
                    if (transporter == null)
                    {
                        continue;
                    }
                    repairUpdateTime = DateTime.UtcNow.AddMilliseconds(RepairSpeed);

                    Debug.WriteLine($"------------ Repairing BROKE repairName: {Name} transporter: {transporter.Name} Time: {DateTime.UtcNow}");
                }

                if (transporter != null)
                {
                    if (DateTime.UtcNow > repairUpdateTime)
                    {
                        transporter.Start();

                        var message = $"------------ Repairing START repairName: {Name} transporter: {transporter.Name} Time: {DateTime.UtcNow}";
                        Debug.WriteLine(message);

                        transporter      = null;
                        repairUpdateTime = DateTime.MaxValue;
                    }
                }

                Thread.Sleep(100);
            }
        }
Exemplo n.º 3
0
        public void Update()
        {
            while (true)
            {
                if (transporterManager.CheckLoadingQueue() && transporter == null)
                {
                    transporter = transporterManager.GetToLoadingWorker() as Transporter;
                    if (transporter == null)
                    {
                        continue;
                    }
                    loadUpdateTime = DateTime.UtcNow.AddMilliseconds(loadSpeed);

                    Debug.WriteLine($".......loading loaderName: {Name} transporter: {transporter.Name} Time: {DateTime.UtcNow}");
                }

                if (transporter != null)
                {
                    AddNewProduct();
                    CheckEnouthProduct();
                }

                Thread.Sleep(100);
            }
        }
Exemplo n.º 4
0
 void CheckEnouthProduct()
 {
     if (transporter.Products.Count >= maxProductCount)
     {
         transporter.Loaded();
         transporter = null;
     }
 }
Exemplo n.º 5
0
 public void InitTransporters(int count)
 {
     for (int i = 0; i < count; i++)
     {
         var pos         = new Vector2(200 + 40 * i, 300);
         var transporter = new Transporter(this, pos, i.ToString());
         Workers.Add(transporter);
         transporter.Start();
         OnDraw(transporter);
     }
 }
Exemplo n.º 6
0
        private void Progress(Transporter transporter)
        {
            Action action = () =>
            {
                for (int i = 0; i < transporter.Products.Count; i++)
                {
                    var product = transporter.Products[i];

                    var pb = Controls.OfType <PictureBox>().First(p => p == product.View);

                    pb.Location = new Point(product.pos.x, product.pos.y);
                }
            };

            Invoke(action);
        }
Exemplo n.º 7
0
 private void Draw(Transporter transporter)
 {
     graphicsContainer.DrawRectangle(new Pen(Color.DarkBlue), new Rectangle(transporter.Pos.x - 10, transporter.Pos.y - 100, 25, 110));
 }
Exemplo n.º 8
0
 public void OnDraw(Transporter transporter)
 {
     Draw?.Invoke(transporter);
 }
Exemplo n.º 9
0
 public void OnProgress(Transporter transporter)
 {
     Progress?.Invoke(transporter);
 }