Esempio n. 1
0
        public List <IUnit> GetOutsideTargets(Army inside, Army outside, ISpecialAction unit)
        {
            var targets = new List <IUnit>();
            int row     = (inside.Count() - inside.IndexOf((IUnit)unit) - 1) % rowSize;
            int line    = (inside.Count() - inside.IndexOf((IUnit)unit) - 1) / rowSize;

            if (line >= unit.Range)
            {
                return(targets);
            }
            for (int i = outside.Count() - 1 - row, targetsCount = unit.Range - line; i >= 0 && targetsCount > 0; i -= rowSize, targetsCount--)
            {
                targets.Add(outside[i]);
            }
            return(targets);
        }
Esempio n. 2
0
        public int GetRow(Army army, IUnit unit)
        {
            int i = (army.Count() - army.IndexOf(unit)) % rowSize;

            if (i == 0)
            {
                return(i);
            }
            return(rowSize - i);
        }
Esempio n. 3
0
        public List <IUnit> GetInsideTargets(Army first, ISpecialAction unit)
        {
            var victims = new List <IUnit>();
            int index   = first.IndexOf((IUnit)unit);

            int row = GetRow(first, (IUnit)unit);

            if (row == 0)
            {
                victims.Add(first[index + 1]);
                victims.Add(first[index + rowSize]);
                victims.Add(first[index + rowSize + 1]);
                if (index >= rowSize - 1)
                {
                    victims.Add(first[index - rowSize + 1]);
                }
                if (index >= rowSize)
                {
                    victims.Add(first[index - rowSize]);
                }
            }

            if (row == 1)
            {
                for (int i = 0; i < 4; i++)
                {
                    victims.Add(first[index + 1 + i]);
                    int j = index - 1 - i;
                    if (j >= 0)
                    {
                        victims.Add(first[j]);
                    }
                }
            }

            if (row == 2)
            {
                victims.Add(first[index + rowSize]);
                victims.Add(first[index + rowSize - 1]);
                if (index > rowSize)
                {
                    victims.Add(first[index - rowSize - 1]);
                }
                if (index > rowSize - 1)
                {
                    victims.Add(first[index - rowSize]);
                }
                if (index > 0)
                {
                    victims.Add(first[index - 1]);
                }
            }

            return(victims);
        }
Esempio n. 4
0
        public List <IUnit> GetInsideTargets(Army inside, ISpecialAction unit)
        {
            var targets = new List <IUnit>();
            int index   = inside.IndexOf((IUnit)unit);
            int from    = (index - unit.Range > 0) ? index - unit.Range : 0;
            int to      = ((index + unit.Range + 1) > inside.Count()) ? inside.Count() : index + unit.Range + 1;

            for (int i = from; i < to; i++)
            {
                targets.Add(inside[i]);
            }
            return(targets);
        }
Esempio n. 5
0
        public List <IUnit> GetOutsideTargets(Army first, Army second, ISpecialAction unit)
        {
            var targets   = new List <IUnit>();
            int indexUnit = first.IndexOf((IUnit)unit);

            if (indexUnit >= first.Count() - unit.Range)
            {
                int targetsCount = unit.Range - (first.Count() - 1 - indexUnit);
                for (int i = 0; i < ((targetsCount > second.Count())?second.Count():targetsCount); i++)
                {
                    targets.Add(second[second.Count() - 1 - i]);
                }
            }
            return(targets);
        }
Esempio n. 6
0
        public List <IUnit> GetInsideTargets(Army inside, ISpecialAction unit)
        {
            var targets = new List <IUnit>();
            int index   = inside.IndexOf((IUnit)unit);

            int row  = (inside.Count() - index - 1) % rowSize;
            int line = (inside.Count() - index - 1) / rowSize;

            for (int i = 0; i < inside.Count(); i++)
            {
                int r = (inside.Count() - i - 1) % rowSize;
                int l = (inside.Count() - i - 1) / rowSize;
                if (Math.Sqrt((r - row) * (r - row) + (l - line) * (l - line)) <= unit.Range)
                {
                    targets.Add(inside[i]);
                }
            }
            return(targets);
        }
Esempio n. 7
0
 public int GetLine(Army army, IUnit unit)
 {
     return((army.Count() - army.IndexOf(unit) - 1) / rowSize);
 }