Exemplo n.º 1
0
        public void CreateMap_FixedMap_EdgesAreCorrect()
        {
            // ARRANGE
            var map = CreateFakeMap();

            var mapGenerator = new GridMapGenerator(7);


            // ACT
            mapGenerator.CreateMap(map);



            // ASSERT
            AssertEdge(map, 0, 0, 1, 0);
            AssertEdge(map, 3, 1, 4, 2);

            // полный набор соседей
            AssertEdge(map, 1, 1, 0, 1);
            AssertEdge(map, 1, 1, 1, 0);
            AssertEdge(map, 1, 1, 2, 0);
            AssertEdge(map, 1, 1, 2, 1);
            AssertEdge(map, 1, 1, 2, 2);
            AssertEdge(map, 1, 1, 1, 2);

            // полный набор соседей для углового
            AssertEdge(map, 6, 6, 5, 6);
            AssertEdge(map, 6, 6, 5, 5);
            AssertEdge(map, 6, 6, 6, 5);
        }
Exemplo n.º 2
0
        public TestGridGenWallMap()
        {
            var gridGenerator = new GridMapGenerator(10);

            gridGenerator.CreateMap(this);

            RemoveEdge(3, 3, 3, 4);
            RemoveEdge(3, 3, 2, 3);
        }
Exemplo n.º 3
0
    public override void OnInspectorGUI()
    {
        base.OnInspectorGUI();

        if (GUILayout.Button("Regenerate"))
        {
            GridMapGenerator gridMap = (GridMapGenerator)target;
            gridMap.BuildMesh();
        }
    }
Exemplo n.º 4
0
        public void CreateMap_HexMapType_NoExceptions()
        {
            // ARRANGE

            var map = new HexMap();

            var mapGenerator = new GridMapGenerator(7);


            // ACT
            Action act = () => { mapGenerator.CreateMap(map); };



            // ASSERT
            act.Should().NotThrow();
        }
Exemplo n.º 5
0
        /// <summary>
        /// Создаёт открытую карту без препятствий.
        /// </summary>
        /// <returns></returns>
        private static IMap CreateGridOpenMap()
        {
            var nodes = new List <IMapNode>();
            var edges = new List <IEdge>();

            var mapMock = new Mock <IMap>();

            mapMock.SetupGet(x => x.Nodes).Returns(nodes);
            mapMock.SetupGet(x => x.Edges).Returns(edges);
            mapMock.Setup(x => x.IsPositionAvailableFor(It.IsAny <IMapNode>(), It.IsAny <IActor>()))
            .Returns(true);

            var map = mapMock.Object;

            var genertor = new GridMapGenerator();

            genertor.CreateMap(map);
            return(map);
        }
Exemplo n.º 6
0
        public GridMap Build(int width, int height)
        {
            var structure = StructureGenerator.Generate(width, height);

            return(GridMapGenerator.Generate(structure));
        }
Exemplo n.º 7
0
 void Start()
 {
     gridMap = GetComponent <GridMapGenerator>();
 }
Exemplo n.º 8
0
        public TestGridGenMap(int size)
        {
            var gridGenerator = new GridMapGenerator(size);

            gridGenerator.CreateMap(this);
        }