Пример #1
0
            /*
             * public void BuildCell_Right(Vector2Int pos)
             * {
             *  if (Cells.ContainsKey(TriangleCells.Right))
             *      return;
             *
             *  var geoTris = new List<GeoTriangle>();
             *  geoTris.Add(Children[SubTriangles.TriRight].GeoTri);
             *  geoTris.Add(Right.Children[SubTriangles.TriLeft].GeoTri);
             *  geoTris.Add(Right.TopBot.Children[SubTriangles.TriLeft].GeoTri);
             *  geoTris.Add(Right.TopBot.Left.Children[SubTriangles.TriTopBot].GeoTri);
             *  geoTris.Add(TopBot.Right.Children[SubTriangles.TriTopBot].GeoTri);
             *  var last =  TopBot.Children[SubTriangles.TriRight].GeoTri;
             *  if(!geoTris.Contains(last))
             *      geoTris.Add(last);
             *
             *  var cell = CreateCell(pos, geoTris.ToArray());
             *  Cells.Add(TriangleCells.Right, cell);
             *  Right.AddCell(cell, TriangleCells.Left);
             *  Right.TopBot.AddCell(cell, TriangleCells.Left);
             *  Right.TopBot.Left.AddCell(cell, TriangleCells.TopBot);
             *  if(geoTris.Count > 5)
             *      TopBot.Right.AddCell(cell, TriangleCells.TopBot);
             *  TopBot.AddCell(cell, TriangleCells.Right);
             * }
             *
             * public void Build_Ring(Vector2Int pos)
             * {
             *  if (Cells.ContainsKey(TriangleCells.Hex))
             *      return;
             *
             *  BuildCell_Hex(pos);
             *  BuildCell_Right(new Vector2Int(pos.x * 2 + 1, pos.y + 1));
             *  //TopBot.BuildCell_Hex(new Vector2Int(pos.x * 2, pos.y + 1));
             *  Right.Build_Ring(new Vector2Int(pos.x + 1, pos.y));
             * }
             */
            public void Build_Column(Vector2Int pos)
            {
                if (Cells.ContainsKey(TriangleCells.Hex))
                {
                    return;
                }

                BuildCell_Hex(pos);
                Right.BuildCell_Hex(new Vector2Int(pos.x + 1, pos.y + (IsUp ? 0 : 1)));
                if (!Cells.ContainsKey(TriangleCells.Right))
                {
                    var right = Children[SubTriangles.TriRight].BuildCell_Right(new Vector2Int(pos.x + 1, pos.y + 1), IsUp == Right.IsUp);
                    Cells.Add(TriangleCells.Right, right);
                    if (!TopBot.Cells.ContainsKey(TriangleCells.Right))
                    {
                        TopBot.AddCell(right, TriangleCells.Right);
                    }
                    if (!Right.Cells.ContainsKey(TriangleCells.Left))
                    {
                        Right.AddCell(right, TriangleCells.Left);
                    }
                }

                if (!Right.Cells.ContainsKey(TriangleCells.TopBot))
                {
                    Right.AddCell(IsUp == Right.IsUp ?
                                  Cells[TriangleCells.TopBot] :
                                  Cells[TriangleCells.Right],
                                  TriangleCells.TopBot);
                }

                if (!TopBot.Cells.ContainsKey(TriangleCells.Hex))
                {
                    TopBot.Build_Column(new Vector2Int(pos.x, pos.y + 1));
                }
                else
                {
                    if (!Cells.ContainsKey(TriangleCells.TopBot))
                    {
                        var topbot = Children[SubTriangles.TriTopBot].BuildCell_Bot(new Vector2Int(pos.x, pos.y + 1));
                        Cells.Add(TriangleCells.TopBot, topbot);
                        if (!Right.Cells.ContainsKey(TriangleCells.Left))
                        {
                            Right.AddCell(Cells[TriangleCells.TopBot], TriangleCells.Left);
                        }

                        if (topbot.Tris.Count > 5)
                        {
                            Right.TopBot.Left.Build_Column(new Vector2Int(pos.x, pos.y + 2));
                        }
                    }
                }
            }