Beispiel #1
0
 public void tick(TVillage CV, int MarketSpeed)
 {
     for (int i = MarketInfo.Count - 1; i >= 0; i--)
     {
         TMInfo x = MarketInfo[i];
         if (x.FinishTime > DateTime.Now)
         {
             continue;
         }
         if (x.MType == TMType.MyBack)
         {
             MarketInfo.Remove(x);
             if (SingleCarry == 0)
             {
                 continue;
             }
             Console.WriteLine(DateTime.Now.ToLongTimeString() + " " + ActiveMerchant.ToString());
             ActiveMerchant += Convert.ToInt32(Math.Ceiling((double)(x.CarryAmount.Resources[0] + x.CarryAmount.Resources[1] + x.CarryAmount.Resources[2] + x.CarryAmount.Resources[3]) / SingleCarry));
             Console.WriteLine(DateTime.Now.ToLongTimeString() + " " + ActiveMerchant.ToString());
         }
         else if (x.MType == TMType.MyOut)
         {
             x.MType = TMType.MyBack;
             var distance = CV.Coord * x.Coord;
             var time     = distance * 3600 / MarketSpeed;
             try
             {
                 x.FinishTime = x.FinishTime.AddSeconds(time);
             }
             catch (Exception ex)
             {
                 throw new InvalidOperationException(
                           string.Format("{0}\r\nMarketSpeed:{1}\r\nMyCoord:{2}\r\nTargetCoord:{3}",
                                         ex.Message, MarketSpeed, CV.Coord, x.Coord));
             }
         }
         else
         {
             for (int j = 0; j < 4; j++)
             {
                 CV.Resource[j].Write(CV.Resource[j].CurrAmount + x.CarryAmount.Resources[j]);
             }
             MarketInfo.Remove(x);
         }
     }
 }