예제 #1
0
        public void Add_Duplicates()
        {
            UnitList vList = CreateList();
            UnitItem vItem = CreateItem("duplicated", 0, true);

            vList.Add(vItem);
            vList.Add(vItem);
        }
예제 #2
0
        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);
        }
예제 #3
0
        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);
        }
예제 #4
0
        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));
        }
예제 #5
0
        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);
        }
예제 #6
0
        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));
        }
예제 #7
0
        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);
        }
예제 #8
0
        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());
        }
예제 #9
0
        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);
        }
예제 #10
0
        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);
        }
예제 #11
0
        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));
        }
예제 #12
0
        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);
        }
예제 #13
0
        public int AddUnit(string UnitName)
        {
            CreateArmy();

            UnitList.Add(CreateUnit(UnitName));

            return(Money);
        }
예제 #14
0
        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);
        }
예제 #16
0
        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);
        }
예제 #17
0
        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);
        }
예제 #18
0
 public virtual void AddUnit(Unit item)
 {
     item.StockUnit = this;
     if (UnitList == null)
     {
         UnitList = new List <Unit>();
     }
     UnitList.Add(item);
 }
예제 #19
0
        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);
        }
예제 #20
0
        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);
        }
예제 #21
0
        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);
            }
        }
예제 #22
0
        //Кнопки управления списком
        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;
        }
예제 #23
0
        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);
        }
예제 #24
0
 public void CopyItem()
 {
     if (SelectedUnit != null)
     {
         BoltUnit unit = (BoltUnit)SelectedUnit.Clone();
         unit.Number = UnitList.Count + 1;
         UnitList.Add(unit);
         SelectedUnit = unit;
     }
 }
예제 #25
0
        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);
        }
예제 #26
0
    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");
    }
예제 #27
0
        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);
        }
예제 #28
0
    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);
    }
예제 #29
0
        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);
        }
예제 #30
0
        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");
            }
        }
예제 #31
0
		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 ) ];
		}
예제 #32
0
		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;
 }