Example #1
0
 // Start is called before the first frame update
 void Start()
 {
     instance     = this;
     cellsHolder  = new Cell[numTiles, numTiles];
     placeHolders = new PlaceholderIndex[numTiles, numTiles];
     for (int i = 0; i < numTiles; i++)
     {
         for (int j = 0; j < numTiles; j++)
         {
             Vector3 currentPos = new Vector3(j * offset, 0, i * offset);
             cell              = new Cell();
             cell.position     = currentPos;
             cell.myIndex      = new Vector2Int(i, j);
             cellsHolder[i, j] = cell;
             PlaceholderIndex placeholder = Instantiate(tilePlaceHolder, currentPos, Quaternion.identity);
             placeholder.myIndex = new Vector2Int(i, j);
             placeHolders[i, j]  = placeholder;
         }
     }
     foreach (Cell c in cellsHolder)
     {
         c.FindNeighbours();
     }
     waveFunctionCollapse.InitializeWaveFunctionCollapse();
 }
Example #2
0
    private void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            mousePos = mainCam.ScreenToWorldPoint(Input.mousePosition);

            hit = Physics2D.Raycast(mousePos, -Vector3.up, 11);
            if (hit)
            {
                PlaceholderIndex p  = hit.collider.GetComponent <PlaceholderIndex>();
                Cell             c  = CellCreator.instance.cellsHolder[p.myIndex.x, p.myIndex.y];
                StringBuilder    sb = new StringBuilder();
                foreach (int i in c.possibleTileList)
                {
                    sb.Append(i).Append(",");
                }
                string s = sb.ToString();
                listText.text = "{ " + s + " }";
            }
        }
    }