protected virtual void handleUpgradeButtonClicked(Sleek2ImageButton button) { int size = (int)Level.size; int num = size / Landscape.TILE_SIZE_INT; for (int i = -num; i < num; i++) { for (int j = -num; j < num; j++) { LandscapeCoord coord = new LandscapeCoord(i, j); LandscapeTile orAddTile = Landscape.getOrAddTile(coord); orAddTile.convertLegacyHeightmap(); orAddTile.convertLegacySplatmap(); for (int k = 0; k < Landscape.SPLATMAP_LAYERS; k++) { orAddTile.materials[k] = this.materials[k]; } orAddTile.updatePrototypes(); } } FoliageVolume foliageVolume = new GameObject { transform = { position = Vector3.zero, rotation = Quaternion.identity, localScale = new Vector3((float)size,Landscape.TILE_HEIGHT, (float)size) } }.AddComponent <FoliageVolume>(); foliageVolume.mode = FoliageVolume.EFoliageVolumeMode.ADDITIVE; foliageVolume.devkitHierarchySpawn(); }
protected virtual void handleSelectedTileChanged(LandscapeTile oldSelectedTile, LandscapeTile newSelectedTile) { this.updateMode(); }
public static void AddTile(LandscapeTile centerTile, LandscapeTilePositionAnchor anchor) { LandscapeTile tile = null; Transform neighborTile = null; switch (anchor) { case LandscapeTilePositionAnchor.TopLeft: tile = CreateTile (centerTile.transform.parent, centerTile.X - 1, centerTile.Y + 1); break; case LandscapeTilePositionAnchor.Top: tile = CreateTile (centerTile.transform.parent, centerTile.X, centerTile.Y + 1); break; case LandscapeTilePositionAnchor.TopRight: tile = CreateTile (centerTile.transform.parent, centerTile.X + 1, centerTile.Y + 1); break; case LandscapeTilePositionAnchor.Left: tile = CreateTile (centerTile.transform.parent, centerTile.X - 1, centerTile.Y); break; case LandscapeTilePositionAnchor.Right: tile = CreateTile (centerTile.transform.parent, centerTile.X + 1, centerTile.Y); break; case LandscapeTilePositionAnchor.BottomLeft: tile = CreateTile (centerTile.transform.parent, centerTile.X - 1, centerTile.Y - 1); break; case LandscapeTilePositionAnchor.Bottom: tile = CreateTile (centerTile.transform.parent, centerTile.X, centerTile.Y - 1); break; case LandscapeTilePositionAnchor.BottomRight: tile = CreateTile (centerTile.transform.parent, centerTile.X + 1, centerTile.Y - 1); break; } neighborTile = centerTile.transform.parent.Find ("LandscapeTile_" + (tile.X - 1) + "_" + (tile.Y + 1)); // TopLeft if (neighborTile != null) { tile.TopLeftTile = neighborTile.GetComponent<LandscapeTile> (); neighborTile.GetComponent<LandscapeTile> ().BottomRightTile = tile; tile.TopLeftElevation = neighborTile.GetComponent<LandscapeTile> ().BottomRightElevation; } neighborTile = centerTile.transform.parent.Find ("LandscapeTile_" + (tile.X) + "_" + (tile.Y + 1)); // Top if (neighborTile != null) { tile.TopTile = neighborTile.GetComponent<LandscapeTile> (); neighborTile.GetComponent<LandscapeTile> ().BottomTile = tile; tile.TopLeftElevation = neighborTile.GetComponent<LandscapeTile> ().BottomLeftElevation; tile.TopRightElevation = neighborTile.GetComponent<LandscapeTile> ().BottomRightElevation; tile.TopModifier = neighborTile.GetComponent<LandscapeTile> ().BottomModifier; } neighborTile = centerTile.transform.parent.Find ("LandscapeTile_" + (tile.X + 1) + "_" + (tile.Y + 1)); // TopRight if (neighborTile != null) { tile.TopRightTile = neighborTile.GetComponent<LandscapeTile> (); neighborTile.GetComponent<LandscapeTile> ().BottomLeftTile = tile; tile.TopRightElevation = neighborTile.GetComponent<LandscapeTile> ().BottomLeftElevation; } neighborTile = centerTile.transform.parent.Find ("LandscapeTile_" + (tile.X - 1) + "_" + (tile.Y)); // Left if (neighborTile != null) { tile.LeftTile = neighborTile.GetComponent<LandscapeTile> (); neighborTile.GetComponent<LandscapeTile> ().RightTile = tile; tile.TopLeftElevation = neighborTile.GetComponent<LandscapeTile> ().TopRightElevation; tile.BottomLeftElevation = neighborTile.GetComponent<LandscapeTile> ().BottomRightElevation; tile.LeftModifier = neighborTile.GetComponent<LandscapeTile> ().RightModifier; } neighborTile = centerTile.transform.parent.Find ("LandscapeTile_" + (tile.X + 1) + "_" + (tile.Y)); // Right if (neighborTile != null) { tile.RightTile = neighborTile.GetComponent<LandscapeTile> (); neighborTile.GetComponent<LandscapeTile> ().LeftTile = tile; tile.TopRightElevation = neighborTile.GetComponent<LandscapeTile> ().TopLeftElevation; tile.BottomRightElevation = neighborTile.GetComponent<LandscapeTile> ().BottomLeftElevation; tile.RightModifier = neighborTile.GetComponent<LandscapeTile> ().LeftModifier; } neighborTile = centerTile.transform.parent.Find ("LandscapeTile_" + (tile.X - 1) + "_" + (tile.Y - 1)); // BottomLeft if (neighborTile != null) { tile.BottomLeftTile = neighborTile.GetComponent<LandscapeTile> (); neighborTile.GetComponent<LandscapeTile> ().TopRightTile = tile; tile.BottomLeftElevation = neighborTile.GetComponent<LandscapeTile> ().TopRightElevation; } neighborTile = centerTile.transform.parent.Find ("LandscapeTile_" + (tile.X) + "_" + (tile.Y - 1)); // Bottom if (neighborTile != null) { tile.BottomTile = neighborTile.GetComponent<LandscapeTile> (); neighborTile.GetComponent<LandscapeTile> ().TopTile = tile; tile.BottomLeftElevation = neighborTile.GetComponent<LandscapeTile> ().TopLeftElevation; tile.BottomRightElevation = neighborTile.GetComponent<LandscapeTile> ().TopRightElevation; tile.BottomModifier = neighborTile.GetComponent<LandscapeTile> ().TopModifier; } neighborTile = centerTile.transform.parent.Find ("LandscapeTile_" + (tile.X + 1) + "_" + (tile.Y - 1)); // BottomRight if (neighborTile != null) { tile.BottomRightTile = neighborTile.GetComponent<LandscapeTile> (); neighborTile.GetComponent<LandscapeTile> ().TopLeftTile = tile; tile.BottomRightElevation = neighborTile.GetComponent<LandscapeTile> ().TopLeftElevation; } tile.renderer.materials = centerTile.renderer.sharedMaterials; tile.RefreshTileMesh (); }
public static void SetTopRightElevation(LandscapeTile tile, int elevation, bool recurse = true) { if (tile != null) { tile.TopRightElevation = elevation; tile.RefreshTileMesh (); if (recurse) { SetBottomRightElevation (tile.TopTile, elevation, false); SetBottomLeftElevation (tile.TopRightTile, elevation, false); SetTopLeftElevation (tile.RightTile, elevation, false); } } }
public static void SetTopModifier(LandscapeTile tile, LandscapeTileModifierType modifier, bool recurse = true) { if (tile != null) { tile.TopModifier = modifier; tile.RefreshTileMesh (); if (recurse) SetBottomModifier (tile.TopTile, modifier, false); } }
public static void SetRightModifier(LandscapeTile tile, LandscapeTileModifierType modifier, bool recurse = true) { if (tile != null) { tile.RightModifier = modifier; tile.RefreshTileMesh (); if (recurse) SetLeftModifier (tile.RightTile, modifier, false); } }
private void Reset() { if (tile == null) { tile = (LandscapeTile) target; } if (tile.GetComponent<MeshCollider> () == null) { tile.gameObject.AddComponent (typeof (MeshCollider)); } // if (tile.rigidbody == null) { // Rigidbody b = tile.gameObject.AddComponent (typeof (Rigidbody)) as Rigidbody; // b.useGravity = false; // } tile.SetModifiers (); tile.RefreshTileMesh (); }