Exemplo n.º 1
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);
        }