public override Tile AddNewNeighbour(int direction) { if (direction < 0 || direction > Utils.GetTileCornerNum(tileType) || neighbors[direction] != null) { return(null); } Coord posNew = new Coord(cPos.q + Utils.instance.cubeNeighborsRelCPos[direction].q, cPos.r + Utils.instance.cubeNeighborsRelCPos[direction].r); Vector3 auxPos = new Vector3(); switch (direction) { case 0: auxPos = new Vector3(-size, wPos.y, 0); break; case 1: auxPos = new Vector3(0, wPos.y, size); break; case 2: auxPos = new Vector3(size, wPos.y, 0); break; case 3: auxPos = new Vector3(0, wPos.y, -size); break; } Vector3 worldPos = wPos + auxPos; CubeTile temp = new CubeTile(tileType, posNew, Config.reg.tileSize, worldPos); neighbors[direction] = temp; return(temp); }
public Dictionary <CubeTile, int> GetTileFrequencies(int tileSize) { Dictionary <CubeTile, int> tileFrequencies = new Dictionary <CubeTile, int>(new CubeTileComparer()); int dimension = grid.Length; int index = 0; for (int x = 0; x < dimension; x++) { for (int y = 0; y < dimension; y++) { for (int z = 0; z < dimension; z++) { CubeTile tile = CreateTile(new Vector3(x, y, z), tileSize, index); if (tile == null) { continue; } if (tileFrequencies.ContainsKey(tile)) { tileFrequencies[tile] += 1; } else { tileFrequencies[tile] = 1; } index++; } } } return(tileFrequencies); }
private void DestroyClickedCell(CubeGridCell cell) { CubeTile tile = Cube.Current.GetTile(cell.Cubxel); if (tile) { Destroy(tile.gameObject); } else { Debug.Log("Tile not found:" + cell.Cubxel.ToString()); } }
public override IEnumerator GenerateRegularGrid(int burstSize) { Utils.instance.debugMsg.Log("GenerateRegularGrid: Start.", true); int burstCount = 0; for (int q = 0; q < worldSizeQ; q++) { for (int r = 0; r < worldSizeR; r++) { CubeTile cube = new CubeTile(TileType.SQUARE, new Coord(q, r), Config.reg.tileSize, new Vector3( q * Config.reg.tileSize, 0, r * Config.reg.tileSize)); Utils.instance.debugMsg.Log("GenerateRegularGrid: New Logic Tile: " + Utils.instance.allTiles.Count, true); burstCount++; if (burstCount >= burstSize) { burstCount = 0; yield return(new WaitForSeconds(routineTimer)); } } } // logical references to other tiles and corners Tile.ConnectAllNeighbours(); Corner.ConnectAllTouches(); // logical references to edges Edge.MakeAllEdges(); Corner.ConnectAllProtrudes(); StartCoroutine(SetupVisualGrid(100)); Debug.Log("Tiles: " + Utils.instance.allTiles.Count); Debug.Log("Corners: " + Utils.instance.allCorners.Count); Utils.instance.debugMsg.Log("GenerateRegularGrid: Finished.", false); }
void SpawnTile(Vector3 position, CubeTile cubeTile, int distanceBetweenModules) { int sideLength = cubeTile.dimension; GameObject tileObj = new GameObject(cubeTile.gridHashCode.ToString()); CubeTileComponent tileComponent = tileObj.AddComponent <CubeTileComponent>(); tileComponent.SetCubeTile(cubeTile); for (int x = 0; x < sideLength; x++) { for (int y = 0; y < sideLength; y++) { for (int z = 0; z < sideLength; z++) { WFCModule module = cubeTile.GetModule(x, y, z); if (module != null) { Vector3 spawnOffset = new Vector3(x * distanceBetweenModules, y * distanceBetweenModules, z * distanceBetweenModules); GameObject spawnedModule = GameObject.Instantiate(module.gameObject, position + spawnOffset, module.transform.rotation); spawnedModule.transform.SetParent(tileObj.transform, true); } } } } }
public CubeCorner(CubeTile pTile, int pDirection, Vector3 wPoint) : base(pTile, pDirection, wPoint) { }
public void SetCubeTile(CubeTile cubeTile) { this.cubeTile = cubeTile; }
void Awake() { tile = GetComponent<CubeTile>(); }