Exemple #1
0
        private int GetPriority(OldBuildElement be)
        {
            if (be.Gatherers)
            {
                return(-1);
            }

            var prior = 0;

            if (be.Research == true && be.Technology.ResourceImproved == Resource.Stone)
            {
                prior = 20;
            }

            if (be.Research == true && be.Technology.ResourceImproved == Resource.Gold)
            {
                prior = 30;
            }

            if (be.Research == true && be.Technology.ResourceImproved == Resource.Food)
            {
                prior = 40;
            }

            if (be.Research == true && be.Technology.ResourceImproved == Resource.Wood)
            {
                prior = 50;
            }

            if (be.Research == false && be.Unit == Civilization.GetDropSite(Resource.Stone))
            {
                prior = 60;
            }

            if (be.Research == false && be.Unit == Civilization.GetDropSite(Resource.Gold))
            {
                prior = 70;
            }

            if (be.Research == false && be.Unit == Civilization.GetDropSite(Resource.Food))
            {
                prior = 80;
            }

            if (be.Research == false && be.Unit == Civilization.GetDropSite(Resource.Wood))
            {
                prior = 90;
            }

            if (be.Research == true && (be.Technology == Civilization.Age1Tech || be.Technology == Civilization.Age2Tech ||
                                        be.Technology == Civilization.Age3Tech || be.Technology == Civilization.Age4Tech))
            {
                prior = 100;
            }

            if (be.Research == true && be.Technology.Effect.Commands.Count(c => c is AttributeModifierCommand) > 0)
            {
                prior = 120;
            }

            if (be.Research == false && be.Unit == Unit.TrainLocation)
            {
                prior = 150;
            }

            if (be.Research == true && be.Technology.Effect.Commands.Count(c =>
            {
                if (c is EnableDisableUnitCommand ec)
                {
                    if (ec.Enable == true && ec.UnitId == Unit.Id)
                    {
                        return(true);
                    }
                }

                return(false);
            }) > 0)
            {
                prior = 150;
            }

            if (be.Research == true && be.Technology.Effect.Commands.Count(c => c is UpgradeUnitCommand) > 0)
            {
                prior = 200;
            }

            if (be.Research == false && be.Unit == Unit)
            {
                prior = 300;
            }

            return(prior);
        }
Exemple #2
0
        public void InsertGatherers()
        {
            var cost = new Cost();

            var start = 0;

            for (int i = 0; i < Elements.Count; i++)
            {
                var current = Elements[i];
                if (!current.Gatherers)
                {
                    Cost ccost;
                    if (current.Research)
                    {
                        ccost = current.Technology.GetCost(Civilization);
                    }
                    else
                    {
                        ccost = current.Unit.GetCost(Civilization);
                    }

                    if (current.Research == false && current.Unit == Unit)
                    {
                        ccost *= 20;

                        if (Unit.TrainLocation != null)
                        {
                            ccost += Unit.TrainLocation.GetCost(Civilization) * 3;
                        }
                    }

                    cost += ccost;
                }

                bool age = false;
                if (current.Research)
                {
                    if (Civilization.Age1Tech == current.Technology)
                    {
                        age = true;
                    }
                    if (Civilization.Age2Tech == current.Technology)
                    {
                        age = true;
                    }
                    if (Civilization.Age3Tech == current.Technology)
                    {
                        age = true;
                    }
                    if (Civilization.Age4Tech == current.Technology)
                    {
                        age = true;
                    }
                }

                if (i == Elements.Count - 1)
                {
                    age = true;
                }

                if (age)
                {
                    var sum       = cost.Total;
                    var gatherers = new OldBuildElement(100 * cost.Food / sum, 100 * cost.Wood / sum, 100 * cost.Gold / sum, 100 * cost.Stone / sum);
                    Elements.Insert(start, gatherers);

                    cost = new Cost();

                    start = i + 2;
                    i     = start - 1;
                }
            }

            var ucost = Unit.GetCost(Civilization);
            var s     = ucost.Total;
            var gath  = new OldBuildElement(100 * ucost.Food / s, 100 * ucost.Wood / s, 100 * ucost.Gold / s, 100 * ucost.Stone / s);

            Elements.Add(gath);
        }