Esempio n. 1
0
        public void DoSpecialAbility(Armies.IArmy friendlyArmy, Armies.IArmy enemiesArmy)
        {
            List <IUnit> availableRange = friendlyArmy.FightStrategy.getSpecialAbilityTargets(friendlyArmy, enemiesArmy, this);

            if (availableRange.Count <= 0)
            {
                return;
            }

            List <IUnit> allies = new List <IUnit>();

            foreach (var unit in availableRange)
            {
                if (friendlyArmy.Units.Contains(unit) && unit is IDressable)
                {
                    allies.Add(unit);
                }
            }

            if (allies.Count > 0)
            {
                int        dressIndex    = GameEngine.Instance.Random.Next(0, allies.Count);
                IDressable dressableUnit = allies[dressIndex] as IDressable;

                UnitDecorator dress = UnitDecoratorFactory.getRandomDecorator();

                if (dressableUnit.Wear(dress))
                {
                    GameLogger.Instance.Log(
                        String.Format("[{0}] усиливает [{1}], добавляя {2} к его снаряжению",
                                      this.ToString(), dressableUnit.ToString(), dress.ToString()),
                        GameLogger.LOG_LEVEL__SPECIAL_ABILITY
                        );
                }
            }
        }
Esempio n. 2
0
 public IUnit GetTarget(Armies.IArmy fromArmy)
 {
     return(heavyUnit.GetTarget(fromArmy));
 }