Example #1
0
 public void CreateAll()
 {
     Entity = new TestEntity(0, 0);
     Entity.SetAttack(new Attack(new[] { new Size(1, 0) }, AttackType.Fire, 10, 1, true));
     Level = LevelCreator.OfSize(null, new Size(3, 3));
     Level.PlaceObject(Entity);
 }
Example #2
0
        public void Test_EntityExist(int x, int y, int sizeX, int sizeY)
        {
            var level  = LevelCreator.OfSize(null, new Size(sizeX, sizeY));
            var entity = new TestEntity(x, y);

            level.PlaceObject(entity);
            Assert.IsTrue(level.InBounds(x, y) && level[x, y].GameObjects.Contains(entity));
        }
Example #3
0
 public void CreateAll()
 {
     Level   = LevelCreator.OfSize(null, new Size(2, 1));
     Entity  = new TestEntity(0, 0);
     Entity1 = new TestEntity(1, 0);
     Level.PlaceObject(Entity);
     Level.PlaceObject(Entity1);
     Entity.Rotate(Direction.Right);
 }
Example #4
0
        public void Test_EntityCantMoveOutOfBounds(Direction direction)
        {
            var level  = LevelCreator.OfSize(null, new Size(1, 1));
            var entity = new TestEntity(0, 0);

            level.PlaceObject(entity);
            entity.Move(direction);
            Assert.IsTrue(CheckForEntity(new Point(0, 0), entity, level));
        }
Example #5
0
        public void Test_EntityCantGoOverRigidObject()
        {
            var level  = LevelCreator.OfSize(null, new Size(1, 2));
            var entity = new TestEntity(0, 0);
            var obj    = new TestObject(0, 1);

            level.PlaceObject(entity);
            level.PlaceObject(obj);
            entity.Move(Direction.Down);
            Assert.IsTrue(CheckForEntity(new Point(0, 0), entity, level));
        }
Example #6
0
 private void GetLevels()
 {
     Levels = new List <Model>()
     {
         LevelCreator.CreateLevelFromStringPattern(LevelCreator.MapPattern1),
         LevelCreator.CreateLevelFromStringPattern(LevelCreator.MapPattern2),
         LevelCreator.CreateLevelFromStringPattern(LevelCreator.MapPattern3),
         LevelCreator.CreateLevelFromStringPattern(LevelCreator.MapPattern4),
     };
     Level       = Levels.First();
     Model.Score = 0;
 }
Example #7
0
        public void Test_EntityCanMove(Direction direction)
        {
            var level  = LevelCreator.OfSize(null, new Size(10, 10));
            var entity = new TestEntity(5, 5);

            level.PlaceObject(entity);
            Assert.IsTrue(level.InBounds(5, 5) && level[5, 5].GameObjects.Contains(entity));
            entity.Move(direction);
            var position = new Point(5, 5) + direction.GetOffsetFromDirection();

            Assert.IsTrue(CheckForEntity(position, entity, level));
        }
Example #8
0
        public void Test_LevelCorrectObjectPlacement(int x, int y)
        {
            var level = (string[])TestLevel1.Clone();
            var line  = new StringBuilder();

            for (var i = 0; i < level[0].Split(';').Length; i++)
            {
                if (i == x)
                {
                    line.Append("S;");
                }
                else
                {
                    line.Append(" ;");
                }
            }
            line.Remove(line.Length - 1, 1);
            level[y] = line.ToString();
            var l = LevelCreator.FromLines(null, level, out var enemies, out Snake snake);

            Assert.IsTrue(l.InBounds(x, y) && l[x, y].GameObjects.Length > 0);
        }