private Mesh GenerateTile(SnowTile snowTile, int config) { var mesh = new Mesh(); mesh.name = "SnowTile " + config; int quadsPerSide = SnowTile.Width - 1; var vertices = new Vector3[(quadsPerSide + 1) * (quadsPerSide + 1)]; var triangles = new int[quadsPerSide * quadsPerSide * 6]; float step = 1.0f / (quadsPerSide); for (int z = 0, i = 0; z <= quadsPerSide; z++) { for (int x = 0; x <= quadsPerSide; x++, i++) { vertices[i] = new Vector3( gridSize.x * x * step, snowTile[i] * snowDepth, gridSize.z * z * step); } } for (int z = 0, vert = 0, tris = 0; z < quadsPerSide; z++, vert++) { for (int x = 0; x < quadsPerSide; x++, vert++, tris += 6) { triangles[tris + 0] = vert + 0; triangles[tris + 1] = vert + quadsPerSide + 1; triangles[tris + 2] = vert + 1; triangles[tris + 3] = vert + 1; triangles[tris + 4] = vert + quadsPerSide + 1; triangles[tris + 5] = vert + quadsPerSide + 2; } } mesh.vertices = vertices; mesh.triangles = triangles; mesh.RecalculateBounds(); mesh.RecalculateNormals(); return(mesh); }
[SerializeField] private SnowTile fullSnowTile = default; // 15 private void GenerateTiles() { snowMeshes[0] = GenerateTile(emptySnowTile, 0); snowMeshes[15] = GenerateTile(fullSnowTile, 15); //@NOTE: Cycling these rather than doing data entry again. SnowTile config1 = cornerSnowTile; SnowTile config2 = config1.Rotated(); SnowTile config4 = config2.Rotated(); SnowTile config8 = config4.Rotated(); snowMeshes[1] = GenerateTile(config1, 1); snowMeshes[2] = GenerateTile(config2, 2); snowMeshes[4] = GenerateTile(config4, 4); snowMeshes[8] = GenerateTile(config8, 8); snowMeshes[14] = GenerateTile(threeCornerSnowTile, 14); SnowTile config13 = threeCornerSnowTile.Rotated(); snowMeshes[13] = GenerateTile(config13, 13); SnowTile config11 = config13.Rotated(); snowMeshes[11] = GenerateTile(config11, 11); SnowTile config7 = config11.Rotated(); snowMeshes[7] = GenerateTile(config7, 7); snowMeshes[3] = GenerateTile(halfSnowTile, 3); SnowTile config6 = halfSnowTile.Rotated(); snowMeshes[6] = GenerateTile(config6, 6); SnowTile config12 = config6.Rotated(); snowMeshes[12] = GenerateTile(config12, 12); SnowTile config9 = config12.Rotated(); snowMeshes[9] = GenerateTile(config9, 9); snowMeshes[10] = GenerateTile(oppositeCornerSnowTile, 10); SnowTile config5 = oppositeCornerSnowTile.Rotated(); snowMeshes[5] = GenerateTile(config5, 5); }
protected void ActionOnSnowWinDestroyCondition(SnowTile sender) { destroyTiles[0].current++; CheckWin(); }
// public override bool Check() // { // return base.Check() && SnowDestroyed(); // } // // protected bool SnowDestroyed() // { // return nrOfSnowTiles == 0 ? true : false; // } protected void ActionOnSnowTileInit(SnowTile sender) { destroyTiles[0].number += sender.numberOfSnowLayers; }
public void OnSnowTileLayerDestroyedSndEvent(SnowTile snowTile) { sndSnowTileLayerDestroy.PlayQueued(); }