public void BreakDownBuilding(Building building) { building.state = Building.BuildingState.Destroyed; Crafting.EditorRecipe recipe = building.info.recipe; Vector2 anchorPos = TerrainManager.PosToV2(building.gameObject.transform.position) - building.info.anchorOffset; for (int y = 0; y < recipe.rows.Count; y++) { for (int x = 0; x < recipe.rows[y].columns.Count; x++) { ResourceInfo resourceInfo = ResourceInfo.GetInfoFromType(recipe.rows [y].columns [x].resourceType); for (int i = 0; i < recipe.rows [y].columns [x].count; i++) { TerrainManager.instance.SpawnResource(new Vector3(anchorPos.x + x, 0, anchorPos.y + y), resourceInfo, building.island); } } } buildings.Remove(building); Destroy(building.gameObject); SavedGame.UpdateBuildings(); }
public virtual void Init(BuildingInfo info, Island island) { anim = gameObject.GetComponentInChildren <Animator> (); this.info = info; this.island = island; Crafting.EditorRecipe recipe = info.recipe; Vector2 anchorPos = TerrainManager.PosToV2(transform.position) - info.anchorOffset; for (int y = 0; y < recipe.rows.Count; y++) { for (int x = 0; x < recipe.rows[y].columns.Count; x++) { coveredTiles.Add(anchorPos + new Vector2(x, y)); } } }