public ArmyComponent(BattleArmy army, Microsoft.Xna.Framework.Game game) : base(game) { _army = army; SetChildren(army.GetStacks().Select(stack => new UnitsStackComponent(stack, game))); UpdatePositionsAndSize(); }
public void BattleArmy_RemoveStack() { Unit angel = new UnitAngel(); Unit skeleton = new UnitSkeleton(); UnitsStack stack1 = new UnitsStack(angel, 10); UnitsStack stack2 = new UnitsStack(skeleton, 42); List <UnitsStack> stacks = new List <UnitsStack> { stack1, stack2 }; Army baseArmy = new Army(stacks); BattleArmy army = new BattleArmy(baseArmy, null); BattleUnitsStack stack = army.GetStack(0); Assert.AreEqual(2, army.GetStacks().Count); Assert.IsTrue(army.RemoveStack(stack)); Assert.AreEqual(1, army.GetStacks().Count); Assert.IsFalse(army.RemoveStack(stack)); }
public void BattleArmy_AddStack() { Unit angel = new UnitAngel(); Unit skeleton = new UnitSkeleton(); UnitsStack stack1 = new UnitsStack(angel, 10); UnitsStack stack2 = new UnitsStack(angel, 5); List <UnitsStack> stacks = new List <UnitsStack> { stack1, stack2 }; Army baseArmy = new Army(stacks); BattleArmy army = new BattleArmy(baseArmy, null); BattleUnitsStack stack3 = new BattleUnitsStack(new UnitsStack(skeleton, 42), army); BattleUnitsStack stack4 = new BattleUnitsStack(new UnitsStack(skeleton, 42), army); BattleUnitsStack stack5 = new BattleUnitsStack(new UnitsStack(skeleton, 42), army); BattleUnitsStack stack6 = new BattleUnitsStack(new UnitsStack(skeleton, 42), army); BattleUnitsStack stack7 = new BattleUnitsStack(new UnitsStack(skeleton, 42), army); BattleUnitsStack stack8 = new BattleUnitsStack(new UnitsStack(skeleton, 42), army); BattleUnitsStack stack9 = new BattleUnitsStack(new UnitsStack(skeleton, 42), army); BattleUnitsStack stack10 = new BattleUnitsStack(new UnitsStack(skeleton, 42), army); Assert.AreEqual(2, army.GetStacks().Count); army.AddStack(stack3); Assert.AreEqual(3, army.GetStacks().Count); Assert.AreEqual(stack3, army.GetStack(2)); army.AddStack(stack4); army.AddStack(stack5); army.AddStack(stack6); army.AddStack(stack7); army.AddStack(stack8); army.AddStack(stack9); Assert.AreEqual(9, army.GetStacks().Count); Assert.Throws <ArgumentOutOfRangeException>(() => army.AddStack(stack10)); }