public void Add_Duplicates() { UnitList vList = CreateList(); UnitItem vItem = CreateItem("duplicated", 0, true); vList.Add(vItem); vList.Add(vItem); }
public void UnitListCountGreaterThanZero() { IocContainer.Setup(); UnitList units = new UnitList(new BattleCalculator(new DieRoller()), new TerrainMap(new ShortestPath())); units.Add(2, 2, 0, NATIONALITY.Germany); units.Add(3, 3, 0, NATIONALITY.Germany); units.Add(4, 4, 0, NATIONALITY.Germany); Assert.Equal(3, units.Count); }
public void TotalGermanUnitsNone() { IocContainer.Setup(); UnitList units = new UnitList(new BattleCalculator(new DieRoller()), new TerrainMap(new ShortestPath())); units.Add(2, 2, 0, NATIONALITY.USA); units.Add(3, 3, 0, NATIONALITY.USA); units.Add(4, 4, 0, NATIONALITY.USA); Assert.Equal(0, units.TotalGermanUnits); }
public void IsTurnCompleteAlliedNotMoved() { IocContainer.Setup(); UnitList units = new UnitList(new BattleCalculator(new DieRoller()), new TerrainMap(new ShortestPath())); units.Add(2, 2, 0, NATIONALITY.Germany); units.Add(3, 3, 0, NATIONALITY.USA); units.Add(4, 4, 0, NATIONALITY.Germany); Assert.False(units.IsTurnComplete(NATIONALITY.USA)); }
public void IsAUnitSelectedNo() { IocContainer.Setup(); UnitList units = new UnitList(new BattleCalculator(new DieRoller()), new TerrainMap(new ShortestPath())); units.Add(2, 2, 0, NATIONALITY.USA); units.Add(3, 3, 0, NATIONALITY.USA); units.Add(4, 4, 0, NATIONALITY.USA); Assert.False(units.IsAUnitSelected); }
public void IsMapOccupiedOffset() { IocContainer.Setup(); UnitList units = new UnitList(new BattleCalculator(new DieRoller()), new TerrainMap(new ShortestPath())); units.Add(2, 2, 0, NATIONALITY.Germany); units.Add(3, 3, 0, NATIONALITY.USA); units.Add(4, 4, 0, NATIONALITY.Germany); Assert.True(units.IsMapOccupied(2, 2)); Assert.False(units.IsMapOccupied(1, 1)); }
public void FindClosestGermanUnitOffsetNoGermanUnits() { IocContainer.Setup(); UnitList units = new UnitList(new BattleCalculator(new DieRoller()), new TerrainMap(new ShortestPath())); units.Add(2, 2, 0, NATIONALITY.USA); units.Add(3, 3, 0, NATIONALITY.USA); units.Add(4, 4, 0, NATIONALITY.USA); int closestUnit = units.FindClosestUnit(1, 1, NATIONALITY.Germany); Assert.Equal(-1, closestUnit); }
public void FindSelectedUnit() { IocContainer.Setup(); var units = new UnitList(new BattleCalculator(new DieRoller()), new TerrainMap(new ShortestPath())); units.Add(2, 2, 0, NATIONALITY.USA); units.Add(3, 3, 0, NATIONALITY.USA); units.Add(4, 4, 0, NATIONALITY.USA); units[1].Selected = true; Assert.Equal(units[1], units.FindSelectedUnit()); }
public void FindNextUnitWithPreviousUnit() { IocContainer.Setup(); var units = new UnitList(new BattleCalculator(new DieRoller()), new TerrainMap(new ShortestPath())); units.Add(2, 2, 0, NATIONALITY.Germany); units.Add(3, 3, 0, NATIONALITY.USA); units.Add(4, 4, 0, NATIONALITY.Germany); var unit = units.FindNextUnit(units[0], NATIONALITY.Germany); Assert.Equal(units[2].UnitNumber, unit.UnitNumber); }
public void FindNextUnitNoUnitFound() { IocContainer.Setup(); UnitList units = new UnitList(new BattleCalculator(new DieRoller()), new TerrainMap(new ShortestPath())); units.Add(2, 2, 0, NATIONALITY.Germany); units.Add(3, 3, 0, NATIONALITY.Germany); units.Add(4, 4, 0, NATIONALITY.Germany); var unit = units.FindNextUnit(units[0], NATIONALITY.USA); Assert.Null(unit); }
public void IsTurnCompleteAlliedYes() { IocContainer.Setup(); UnitList units = new UnitList(new BattleCalculator(new DieRoller()), new TerrainMap(new ShortestPath())); units.Add(2, 2, 0, NATIONALITY.Germany); units.Add(3, 3, 0, NATIONALITY.USA); units.Add(4, 4, 0, NATIONALITY.Germany); units[1].Movement = 0; units[1].UnitHasAttackedThisTurn = true; Assert.True(units.IsTurnComplete(NATIONALITY.USA)); }
public void FindUnit() { IocContainer.Setup(); UnitList units = new UnitList(new BattleCalculator(new DieRoller()), new TerrainMap(new ShortestPath())); units.Add(2, 2, 0, NATIONALITY.Germany); units.Add(3, 3, 0, NATIONALITY.USA); units.Add(4, 4, 0, NATIONALITY.Germany); var unit = units.FindUnit(3, 3); Assert.Equal(NATIONALITY.USA, unit.Nationality); }
public int AddUnit(string UnitName) { CreateArmy(); UnitList.Add(CreateUnit(UnitName)); return(Money); }
public void FindNextUnitSkipSleepingUnit() { IocContainer.Setup(); UnitList units = new UnitList(new BattleCalculator(new DieRoller()), new TerrainMap(new ShortestPath())); units.Add(2, 2, 0, NATIONALITY.USA); units.Add(3, 3, 0, NATIONALITY.USA); units.Add(4, 4, 0, NATIONALITY.USA); units[0].Sleep = true; units[1].Sleep = true; var unit = units.FindNextUnit(units[0], NATIONALITY.USA); Assert.Equal(units[2], unit); }
public void TotalAlliedUnitsAlive() { IocContainer.Setup(); var terrainMap = new TerrainMap(new ShortestPath()); terrainMap.InitializeBoard(8, 8); var unitList = new UnitList(new BattleCalculator(new DieRoller()), terrainMap); unitList.Add(6, 7, 1, NATIONALITY.USA); unitList.Add(3, 2, 1, NATIONALITY.USA); unitList.Add(3, 3, 1, NATIONALITY.Germany); var calc = new VictoryCalculator(terrainMap, unitList); Assert.Equal(2, calc.TotalAlliedUnitsAlive); }
public void UnitIsNotInAttackRange() { IocContainer.Setup(); var alliedEnemyMatrix = new AlliedEnemyMatrix(true); var terrainMap = new TerrainMap(new ShortestPath()); terrainMap.InitializeBoard(8, 8); var unitList = new UnitList(new BattleCalculator(new DieRoller()), terrainMap); unitList.Add(0, 0, 0, NATIONALITY.GreatBritian); unitList.Add(5, 5, 2, NATIONALITY.Germany); var result = unitList.IsUnitWithinAttackRange(unitList[1], alliedEnemyMatrix); Assert.False(result); }
public void FindAllAdjacentUnitsCorner() { IocContainer.Setup(); var terrainMap = new TerrainMap(new ShortestPath()); terrainMap.InitializeBoard(8, 8); var unitList = new UnitList(new BattleCalculator(new DieRoller()), terrainMap); unitList.Add(2, 1, 1, NATIONALITY.GreatBritian); unitList.Add(1, 2, 1, NATIONALITY.France); unitList.Add(2, 2, 1, NATIONALITY.France); var result = unitList.FindAllAdjacentUnits(1, 1); Assert.Equal(3, result.Count); }
public virtual void AddUnit(Unit item) { item.StockUnit = this; if (UnitList == null) { UnitList = new List <Unit>(); } UnitList.Add(item); }
public void FindNextUnitSkipUnitWithZeroMoves() { IocContainer.Setup(); UnitList units = new UnitList(new BattleCalculator(new DieRoller()), new TerrainMap(new ShortestPath())); units.Add(2, 2, 0, NATIONALITY.Germany); units.Add(3, 3, 0, NATIONALITY.USA); units.Add(4, 4, 0, NATIONALITY.Germany); units.Add(4, 5, 0, NATIONALITY.Germany); units[2].Movement = 0; units[2].UnitHasAttackedThisTurn = true; var unit = units.FindNextUnit(units[0], NATIONALITY.Germany); Assert.Equal(units[3].UnitNumber, unit.UnitNumber); }
public void SetAlliedTurn() { IocContainer.Setup(); var units = new UnitList(new BattleCalculator(new DieRoller()), new TerrainMap(new ShortestPath())); units.Add(2, 2, 0, NATIONALITY.Germany); units.Add(3, 3, 0, NATIONALITY.USA); units.Add(4, 4, 0, NATIONALITY.Germany); units[0].Movement = 0; units[1].Movement = 0; units[2].Movement = 0; units.SetTurn(NATIONALITY.USA); Assert.Equal(0, units[0].Movement); Assert.Equal(1, units[1].Movement); Assert.Equal(0, units[2].Movement); }
public void UnselectUnits() { IocContainer.Setup(); UnitList units = new UnitList(new BattleCalculator(new DieRoller()), new TerrainMap(new ShortestPath())); units.Add(2, 2, 0, NATIONALITY.USA); units.Add(3, 3, 0, NATIONALITY.USA); units.Add(4, 4, 0, NATIONALITY.USA); units[1].Selected = true; units.UnselectUnits(); for (int i = 0; i < 3; i++) { Assert.False(units[i].Selected); } }
//Кнопки управления списком public void AddItem() { BoltUnit unit = new BoltUnit(BaseSet); unit.Number = UnitList.Count + 1; unit.ConnectionTypes = ConnectionTypes; unit.SelectedItemGammaC = ListGammaC[0]; UnitList.Add(unit); SelectedUnit = unit; }
public void ShouldNotFind() { var unitList = new UnitList(); var player = new Player() { CurrentLocation = new Location(1, 0, 0) }; var monsterTwo = new Monster() { CurrentLocation = new Location(3, 0, 0) }; unitList.Add(player); unitList.Add(monsterTwo); var foundUnit = unitList.FindUnit(new Location(2, 2, 2)); Assert.Null(foundUnit); }
public void CopyItem() { if (SelectedUnit != null) { BoltUnit unit = (BoltUnit)SelectedUnit.Clone(); unit.Number = UnitList.Count + 1; UnitList.Add(unit); SelectedUnit = unit; } }
public void ShouldNotGetPlayerOne() { var unitList = new UnitList(); var playerOne = new Player() { Name = "One", CurrentLocation = new Location(1, 1, 1) }; var playerTwo = new Player() { Name = "Two", CurrentLocation = new Location(2, 2, 2) }; unitList.Add(playerTwo); unitList.Add(playerOne); var foundPlayer = unitList.GetPlayer(); Assert.NotEqual(playerOne, foundPlayer); }
private void CreateNewUnit() { UnitInfo u = new UnitInfo(100, 5, 10, 1, "The first unit's name"); u.name = "Hunter"; UnitList ul = new UnitList("main"); ul.Add(u); XMLDataSerializer.SaveUnits(ul, "Assets/Data/Units.xml"); }
public void ShouldFindMonster() { var unitList = new UnitList(); var player = new Player() { CurrentLocation = new Location(1, 0, 0) }; var monsterTwo = new Monster() { CurrentLocation = new Location(3, 0, 0) }; unitList.Add(player); unitList.Add(monsterTwo); var foundUnit = unitList.FindUnit(new Location(3, 0, 0)); Assert.True(foundUnit is Monster); }
void SpawnUnit() { UnitBasic unit = (UnitBasic)unitPool.GetOneObject(); unit.transform.position = transform.position + new Vector3(Random.Range(-5.0f, 5.0f), Random.Range(-5.0f, 5.0f), Random.Range(-5.0f, 5.0f)); unit.transform.SetParent(activeObjectsRoot); unit.InitUnit(); theUnitList.Add(unit); }
public void DestroyUnit() { IocContainer.Setup(); var units = new UnitList(new BattleCalculator(new DieRoller()), new TerrainMap(new ShortestPath())); units.Add(2, 2, 0, NATIONALITY.Germany); units.Add(3, 3, 0, NATIONALITY.USA); units.Add(4, 4, 0, NATIONALITY.Germany); Unit unit = units[1]; units.DestroyUnit(unit); Assert.Equal(2, units.Count); Assert.Equal(2, units[0].Col); Assert.Equal(2, units[0].Row); Assert.Equal(4, units[1].Col); Assert.Equal(4, units[1].Row); }
public void Add() { UnitList vList = CreateList(); for (int vItemIdx = 0; vItemIdx < 10; vItemIdx++) { UnitItem vExpected = CreateItem("unit ", vItemIdx, true); vList.Add(vExpected); Assert.AreEqual(vItemIdx + 1, vList.Count, "Unit item wasn't added to the list"); Assert.AreEqual(vExpected, vList[vItemIdx], "Unit item wasn't set properly"); } }
public virtual Unit GetRandomTarget( Vector2 Distance, int Range ) { UnitList randUnits = new UnitList(); for( int i = 0; i < mUnits.Count; i++ ) { if( mUnits[ i ].Dead || mUnits[ i ].GetDistance( Distance ) > Range ) continue; randUnits.Add( mUnits[ i ] ); } if( randUnits.Count == 0 ) return null; return randUnits[ mRand.Next( randUnits.Count ) ]; }
public virtual UnitList GetTargets( Vector2 Distance, int Range ) { UnitList units = new UnitList(); for( int i = 0; i < mUnits.Count; i++ ) { if( mUnits[ i ].Dead || mUnits[ i ].GetDistance( Distance ) > Range ) continue; units.Add( mUnits[ i ] ); } return units; }
protected static UnitList SplitUnits(string iText) { UnitList vList = new UnitList(); MatchCollection vMatches = ExecuteExpression(iText, cUnitLines); foreach (Match vMatch in vMatches) { string vUnitLine = GetMatchResult(1, vMatch); if (vUnitLine == "") continue; UnitItem vUnit = SplitUnitInfo(vUnitLine); if (vUnit != null) vList.Add(vUnit); } return vList; }
protected UnitList GetDefaultUnits(int iCount, bool iWithPaths, bool iRelative, bool iWithConditions) { UnitList vResult = new UnitList(); for (int vUnitIdx = 0; vUnitIdx < iCount; vUnitIdx++) { string vUnitName = "Unit" + vUnitIdx.ToString(); string vUnitPath = ""; if (iWithPaths) if (iRelative) vUnitPath = "..\\.." + "DefaultPath" + vUnitIdx.ToString(); else vUnitPath = @"c:\windows\temp\DefaultPath" + vUnitIdx.ToString() + "\\" + vUnitName + ".pas"; UnitItem vUnit = new UnitItem(vUnitName, vUnitPath, iWithPaths, ""); if (iWithConditions) { vUnit.StartingConditions = "{$IFDEF TestCondition}"; vUnit.EndingConditions = "{$ENDIF}"; } vResult.Add(vUnit); } return vResult; }
protected override bool ProcessUnit(UnitList aUnits, UnitItem aUnit) { aUnits.Add(aUnit); return true; }