Ejemplo n.º 1
0
        public void TestDeleteFromMap()
        {
            var tankEngine = new TankEngine();
            var map        = new MapBase();

            map.GameMap = new int[100, 100];
            map.Borders = new List <int> {
                0, 0, 100, 100
            };
            int tankInitX = 5, tankInitY = 10;
            var tank = new List <TankFragment>();

            tankEngine.TankInit(out tank, tankInitX, tankInitY, MoveDirection.Right, map.GameMap);
            tankEngine.TankDeleteFromMap(tank, map);
            Assert.IsTrue(map.GameMap[tank[0].Y, tank[0].X] == 0 &&
                          map.GameMap[tank[1].Y, tank[1].X] == 0 &&
                          map.GameMap[tank[2].Y, tank[2].X] == 0 &&
                          map.GameMap[tank[3].Y, tank[3].X] == 0 &&
                          map.GameMap[tank[4].Y, tank[4].X] == 0 &&
                          map.GameMap[tank[5].Y, tank[5].X] == 0 &&
                          map.GameMap[tank[6].Y, tank[6].X] == 0 &&
                          map.GameMap[tank[7].Y, tank[7].X] == 0 &&
                          map.GameMap[tank[8].Y, tank[8].X] == 0);
        }
Ejemplo n.º 2
0
        public void TestTurnUpLeft()
        {
            var tankEngine = new TankEngine();
            var map        = new MapBase();

            map.GameMap = new int[100, 100];
            map.Borders = new List <int> {
                0, 0, 100, 100
            };
            int tankInitX = 1, tankInitY = 10;
            var tank = new List <TankFragment>();

            tankEngine.TankInit(out tank, tankInitX, tankInitY, MoveDirection.Left, map.GameMap);
            var testList = new List <TankFragment>(tank.Count);

            testList.AddRange(tank.Select(t => new TankFragment(t.X, t.Y)));
            tankEngine.TankTurn(tank, MoveDirection.Left, MoveDirection.Up);
            Assert.IsTrue(tank[0].X == testList[6].X &&
                          tank[0].Y == testList[6].Y &&
                          tank[1].X == testList[6].X &&
                          tank[1].Y == testList[6].Y - 1 &&
                          tank[2].X == testList[6].X &&
                          tank[2].Y == testList[6].Y - 2 &&
                          tank[3].X == testList[6].X + 1 &&
                          tank[3].Y == testList[6].Y &&
                          tank[4].X == testList[6].X + 1 &&
                          tank[4].Y == testList[6].Y - 1 &&
                          tank[5].X == testList[6].X + 1 &&
                          tank[5].Y == testList[6].Y - 2 &&
                          tank[6].X == testList[6].X + 2 &&
                          tank[6].Y == testList[6].Y &&
                          tank[7].X == testList[6].X + 2 &&
                          tank[7].Y == testList[6].Y - 1 &&
                          tank[8].X == testList[6].X + 2 &&
                          tank[8].Y == testList[6].Y - 2);
        }
Ejemplo n.º 3
0
        public void TestShootEnable()
        {
            var tank = new TankEngine();

            Assert.IsTrue(tank.ShootEnable);
        }