Esempio n. 1
0
        public void MonsterDenBuilderResizeTest()
        {
            var setHeightMonsterDen = new MonsterDenBuilder(_testChunk)
                                      .SetRadius(10)
                                      .Build() as MonsterDen;

            Assert.AreEqual(10, setHeightMonsterDen.Radius, $"MonsterDen height was not as expected.");
        }
Esempio n. 2
0
        public void MonsterDenBuilderCutTest()
        {
            var cutRightMonsterDen = new MonsterDenBuilder(_testChunk)
                                     .SetCenterpoint(-Vector2.one)
                                     .SetRadius(5)
                                     .AddBoundary(Directions.Right, 0)
                                     .AddBoundary(Directions.Left, 0)
                                     .Build();

            foreach (var extent in cutRightMonsterDen.Extents)
            {
                Assert.AreEqual(extent.X, 0, $"Failed to cut right, as one extent is at {extent}.");
            }

            var cutUpMonsterDen = new MonsterDenBuilder(_testChunk)
                                  .SetCenterpoint(-Vector2.one)
                                  .SetRadius(5)
                                  .AddBoundary(Directions.Up, 0)
                                  .AddBoundary(Directions.Down, 0)
                                  .Build();

            foreach (var extent in cutUpMonsterDen.Extents)
            {
                Assert.AreEqual(extent.Y, 0, $"Failed to cut up, as one extent is at {extent}.");
            }

            var cutLeftMonsterDen = new MonsterDenBuilder(_testChunk)
                                    .SetCenterpoint(Vector2.one)
                                    .SetRadius(5)
                                    .AddBoundary(Directions.Left, 0)
                                    .AddBoundary(Directions.Right, 0)
                                    .Build();

            foreach (var extent in cutRightMonsterDen.Extents)
            {
                Assert.AreEqual(extent.X, 0, $"Failed to cut left, as one extent is at {extent}.");
            }

            var cutDownMonsterDen = new MonsterDenBuilder(_testChunk)
                                    .SetCenterpoint(Vector2.one)
                                    .SetRadius(5)
                                    .AddBoundary(Directions.Down, 0)
                                    .AddBoundary(Directions.Up, 0)
                                    .Build();

            foreach (var extent in cutUpMonsterDen.Extents)
            {
                Assert.AreEqual(extent.Y, 0, $"Failed to cut down, as one extent is at {extent}.");
            }
        }
Esempio n. 3
0
        public void MonsterDenGetBlockTest()
        {
            var monsterDen = new MonsterDenBuilder(_testChunk)
                             .Build() as MonsterDen;

            for (var x = monsterDen.Centerpoint.X - monsterDen.Radius; x <= monsterDen.Centerpoint.X + monsterDen.Radius; x++)
            {
                var offsetFromCenter = Mathf.Abs(x - monsterDen.Centerpoint.X);

                for (var y = monsterDen.Centerpoint.Y; y <= monsterDen.Centerpoint.Y + monsterDen.Radius - offsetFromCenter; y++)
                {
                    var block = monsterDen.GetBlockType(new IntVector2(x, y));
                    Assert.AreEqual(block, BlockTypes.None, $"Found the wrong block at [{x},{y}].");
                }
            }
        }
Esempio n. 4
0
        public void MonsterDenBuilderClampTest()
        {
            var clampLeftMonsterDen = new MonsterDenBuilder(_testChunk)
                                      .SetCenterpoint(-Vector2.one)
                                      .AddBoundary(Directions.Left, 0)
                                      .Build();

            foreach (var extent in clampLeftMonsterDen.Extents)
            {
                Assert.GreaterOrEqual(extent.X, 0, $"Failed to clamp left, as one extent is at {extent}.");
            }

            var clampDownMonsterDen = new MonsterDenBuilder(_testChunk)
                                      .SetCenterpoint(-Vector2.one)
                                      .AddBoundary(Directions.Down, 0)
                                      .Build();

            foreach (var extent in clampDownMonsterDen.Extents)
            {
                Assert.GreaterOrEqual(extent.Y, 0, $"Failed to clamp down, as one extent is at {extent}.");
            }

            var clampRightMonsterDen = new MonsterDenBuilder(_testChunk)
                                       .SetCenterpoint(Vector2.one)
                                       .AddBoundary(Directions.Right, 0)
                                       .Build();

            foreach (var extent in clampRightMonsterDen.Extents)
            {
                Assert.LessOrEqual(extent.X, 0, $"Failed to clamp right, as one extent is at {extent}.");
            }

            var clampUpMonsterDen = new MonsterDenBuilder(_testChunk)
                                    .SetCenterpoint(Vector2.one)
                                    .AddBoundary(Directions.Up, 0)
                                    .Build();

            foreach (var extent in clampUpMonsterDen.Extents)
            {
                Assert.LessOrEqual(extent.Y, 0, $"Failed to clamp up, as one extent is at {extent}.");
            }
        }
Esempio n. 5
0
        public void MonsterDenEnemyGenerationTest()
        {
            for (var repeat = 0; repeat < 50; repeat++)
            {
                var monsterDen = new MonsterDenBuilder(_testChunk)
                                 .SetCenterpoint(Vector2.zero)
                                 .SetRadius(5)
                                 .SetExtraRiskPoints(5)
                                 .Build();

                var enemySpawns = monsterDen.EnemySpawns;

                Assert.IsNotEmpty(enemySpawns, $"No enemies were spawned.");

                foreach (var enemy in enemySpawns)
                {
                    Assert.True(monsterDen.Contains(enemy.Position), $"Enemy spawned outside of monster den.");
                    Assert.AreNotEqual(EnemyTypes.None, enemy.Type, $"Enemy spawned as `none`.");
                }
            }
        }