Exemple #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="creator"></param>
        /// <param name="productable"></param>
        /// <param name="callBack"></param>
        public void AddToProductionQueue(IProductable productable, Action <IProductable> callBack)
        {
            if (_creator == null)
            {
                throw new ArgumentNullException("AddToProductionQueue: Creator is null");
            }

            if (_creator.ProductionQueue == null)
            {
                throw new ArgumentNullException("AddToProductionQueue: Creator production queue is null");
            }

            if (productable == null)
            {
                throw new ArgumentNullException("AddToProductionQueue: Productable is null");
            }


            bool taskStarted = _creator.ProductionQueue.Count > 0;

            _creator.ProductionQueue.Enqueue(productable);

            if (taskStarted == false)
            {
                ProductQueueLauncher(_creator.ProductionQueue, callBack);
            }
        }
Exemple #2
0
 public void LaunchProduction(IProductable productable, Action <IProductable> callBack)
 {
     if (productable == null)
     {
         throw new ArgumentNullException("LaunchProduction: productable is null");
     }
     IsWorking = true;
     _generator.CreateEntity(productable, callBack);
 }
Exemple #3
0
        public static void AddProduct(IProductable product)
        {
            List <SPParam> parameters = new List <SPParam>
            {
                new SPParam("name", product.Name),
                new SPParam("categoryId", product.CategoryId),
                new SPParam("price", product.Price),
                new SPParam("description", product.Description),
                new SPParam("pictureUri", product.PictureUri ?? "Not Specified"),
            };

            ExecuteSpNonQuery("AddProduct", parameters);
        }
Exemple #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="creator"></param>
        /// <param name="productable"></param>
        /// <param name="callBack"></param>
        /// <returns></returns>
        public bool CreateEntity(IProductable productable, Action <IProductable> callBack)
        {
            if (productable == null)
            {
                throw new ArgumentNullException("CreateEntity: productable is null");
            }

            // Récupérer les ressources necessaires à la production
            var productionResources = productable.Cost;

            //Todo : Calculer la somme totale des ressources.

            // Si OK => Créer l'entité
            AddToProductionQueue(productable, callBack);

            // Ajouter au fil de production
            return(true);
        }
Exemple #5
0
 public void LaunchProduction(IProductable productable, Action <IProductable> callBack)
 {
     _generator.CreateEntity(productable, callBack);
 }
 /// <summary>
 ///
 /// </summary>
 /// <param name="Worker"></param>
 public void ValidateWorkerCreation(IProductable worker)
 {
     //(worker as Worker).Id = GetNewUnitId();
     AddWorkerToList(worker as Worker);
 }
Exemple #7
0
        public void AddBonusCount(int triggerValue, int executeTimes, int frequencyTimes, IProductable productableObject, double bonusCount, string displayText, bool display = true)
        {
            BuildingAction bonus = new BuildingAction(triggerValue, executeTimes, frequencyTimes);
            BuildingInfo   b1    = BuildingInfos.Find(BuildingInfo => BuildingInfo.Key == productableObject.Key);

            if (display)
            {
                //if (b1 != null)
                //{
                //    b1.Value = (Convert.ToDouble(b1.Value) + bonusCount).ToString();
                //}
                if (b1 == null)
                {
                    b1 = new BuildingInfo()
                    {
                        Key   = productableObject.Key,
                        Value = 0.ToString(),
                        Label = displayText
                    };
                    BuildingInfos.Add(b1);
                }
                bonus.Actions += () =>
                {
                    productableObject.AddIncreaseCount(bonusCount);
                    b1.Value = (Convert.ToDouble(b1.Value) + bonusCount).ToString();
                };
            }
            else
            {
                bonus.Actions += () =>
                {
                    productableObject.AddIncreaseCount(bonusCount);
                };
            }

            AddBonus(bonus);
        }
 /// <summary>
 ///
 /// </summary>
 /// <param name="farm"></param>
 private void ValidateFarmCreation(IProductable farm)
 {
     IncreasePopulationLimit(farm as Farm);
 }