예제 #1
0
        public override IUnit Clone()
        {
            ICanBeDublacate dubl = Unit as ICanBeDublacate;
            ArmorUnitHelmet AUS  = new ArmorUnitHelmet(dubl.Clone());

            return(AUS);
        }
예제 #2
0
        public string DoAbility(List <IUnit> Allies, List <IUnit> Enemies, int position)
        {
            string AbilityResult     = "Infantry Unit на позиции " + position;
            int    ArmorUnitPosition = 0;
            Random r = new Random();

            if (position + 1 < Allies.Count)
            {
                if (Allies[position + 1] is ArmorUnit || Allies[position + 1] is ArmorUnitAdapter)
                {
                    ArmorUnitPosition = position + 1;
                }
            }

            if (position - 1 >= 0)
            {
                if (Allies[position - 1] is ArmorUnit || Allies[position - 1] is ArmorUnitAdapter)
                {
                    ArmorUnitPosition = position - 1;
                }
            }

            if (ArmorUnitPosition != 0 && r.Next(1, 21) == 20)
            {
                AbilityResult += string.Format(" экипирует Armor Unit на позиции {0}", ArmorUnitPosition);
                if (!(Allies[ArmorUnitPosition] is ArmorUnitAdapter))
                {
                    Allies[ArmorUnitPosition] = new ArmorUnitShield(Allies[ArmorUnitPosition]);
                    return(AbilityResult + " Щитом");
                }

                if (Allies[ArmorUnitPosition] is ArmorUnitShield)
                {
                    Allies[ArmorUnitPosition] = new ArmorUnitHelmet(Allies[ArmorUnitPosition]);
                    return(AbilityResult + " Шлемом");
                }

                if (Allies[ArmorUnitPosition] is ArmorUnitHelmet)
                {
                    Allies[ArmorUnitPosition] = new ArmorUnitHorse(Allies[ArmorUnitPosition]);
                    return(AbilityResult + " Лошадью");
                }

                if (Allies[ArmorUnitPosition] is ArmorUnitHorse)
                {
                    Allies[ArmorUnitPosition] = new ArmorUnitSpear(Allies[ArmorUnitPosition]);
                    return(AbilityResult + " Копьем");
                }
            }

            return(AbilityResult + string.Format(" не может экипировать"));
        }