private void GenerateIslands() { switch (Width) { case 72: DifferentSizeIslands.GenerateTinyIslands(GenerationMap, GetCurrentBiomeTileSet().GroundTiles[0]); break; case 96: DifferentSizeIslands.GenerateSmallIslands(GenerationMap, GetCurrentBiomeTileSet().GroundTiles[0]); break; case 120: DifferentSizeIslands.GenerateMediumIslands(GenerationMap, GetCurrentBiomeTileSet().GroundTiles[0]); break; case 144: DifferentSizeIslands.GenerateLargeIslands(GenerationMap, GetCurrentBiomeTileSet().GroundTiles[0]); break; case 200: DifferentSizeIslands.GenerateHugeIslands(GenerationMap, GetCurrentBiomeTileSet().GroundTiles[0]); break; //case 255: // DifferentSizeIslands.GenerateGiganticIslands(GenerationMap, tilePool.GetTileSetFromBiomeType(SelectedMapBiome)[0]); // break; default: break; } ForestGenerator.GenerateTreesForForest(GenerationMap); GenerationMap.FillEmptySpaceWithTile(GetCurrentBiomeTileSet().Water); }
public void AlgorithmB_1() { ICollection <Forest> result = ForestGenerator.AlgorithmB(1); Assert.IsTrue(result.Count == 1); Assert.IsTrue(result.Contains(new Parentheses("()"))); }
// Use this for initialization void Awake() { if (instance == null) { instance = this; tilePool = GameObject.FindGameObjectWithTag("EventSystem").GetComponent <TilePool>(); GenerationMap = this.gameObject.AddComponent <GameMap>(); GenerationMap.AttachMapGameObject(); forestGenerator = this.gameObject.GetComponent <ForestGenerator>(); GenerationMap.AttachForestGenerator(forestGenerator); GenerationMap.AttachTiles(); CreatePaths.AttachMap(GenerationMap); CreatePaths.AttachTiles(GetCurrentBiomeTileSet().Road, GetCurrentBiomeTileSet().Shallows, GetCurrentBiomeTileSet().Water); displaySelected = canvas.GetComponent <DisplaySelected>(); } else { instance.tilePool = this.gameObject.GetComponent <TilePool>(); instance.canvas = GameObject.FindGameObjectWithTag("Canvas").GetComponent <Canvas>(); Destroy(this); } gamePlayCam = cam1.GetComponent <Camera>(); gamePlayCam.enabled = true; topDownCam = cam2.GetComponent <Camera>(); topDownCam.enabled = false; testingPhaseCanvas.enabled = false; }
public void AlgorithmB_4() { ICollection <Forest> result = ForestGenerator.AlgorithmB(4); Assert.IsTrue(result.Count == all4.Count()); Assert.IsTrue(all4.All <Forest> (e => result.Contains(e))); }
private void btnLoadForest_Click(object sender, EventArgs e) { var path = GetFilePath(); if (string.IsNullOrEmpty(path)) { return; } try { forest = ForestGenerator.ReadForestFromFile(path, "^", ','); } catch (Exception ex) { MessageBox.Show(ex.Message); return; } foreach (var tree in forest) { PreorderIndexBuilder.BuildPreorderIndex(tree); } ShowForest(); }
private void btnGenerateForest_Click(object sender, EventArgs e) { var fs = GetForestSpecification(); if (fs == null) { return; } forest = ForestGenerator.Generate(fs, "^"); var sfd = new SaveFileDialog { Filter = "txt files (*.txt)|*.txt", FileName = "forest.txt" }; if (sfd.ShowDialog() != DialogResult.OK) { return; } if (string.IsNullOrEmpty(sfd.FileName)) { return; } ForestGenerator.SaveForestToFile(forest, sfd.FileName, false); }
void OnHeightMapReceived(object heightMapObject) { _heightMap = (HeightMap)heightMapObject; _heightMapReceived = true; Update(); _treeKeys = ForestGenerator.AddTrees(_forest, _forestSettings, _meshSettings, _sampleCentre, _heightMap, _meshObject.transform.parent); }
public override void OnInspectorGUI() { terrainMapGenerator = (TerrainMapGenerator)target; heightMapGenerator = terrainMapGenerator.GetComponent <HeightMapGenerator>(); hydraulicErosion = terrainMapGenerator.GetComponent <HydraulicErosion>(); forestGenerator = terrainMapGenerator.GetComponent <ForestGenerator>(); DrawDefaultInspector(); // Buttons EditorGUILayout.LabelField("", GUI.skin.horizontalSlider); if (GUILayout.Button("Randomize")) { Randomize(); terrainMapGenerator.Clear(); terrainMapGenerator.Generate(loadAllObjects: true); } EditorGUILayout.LabelField("", GUI.skin.horizontalSlider); if (GUILayout.Button("Generate")) { terrainMapGenerator.Generate(loadAllObjects: true); } if (GUILayout.Button("Clear")) { terrainMapGenerator.Clear(); } GUILayout.Label("Save Level"); EditorGUILayout.BeginHorizontal(); levelNameSave = EditorGUILayout.TextField(levelNameSave); if (GUILayout.Button("Save")) { SaveTerrainData(levelNameSave); } EditorGUILayout.EndHorizontal(); string[] saveFiles = GetSaveFiles(); if (saveFiles.Length > 0) { GUILayout.Label("Load Level"); EditorGUILayout.BeginHorizontal(); levelNameIndex = EditorGUILayout.Popup(levelNameIndex, saveFiles); levelNameLoad = saveFiles[levelNameIndex]; if (GUILayout.Button("Load")) { LoadTerrainData(levelNameLoad); terrainMapGenerator.Generate(loadAllObjects: true); } EditorGUILayout.EndHorizontal(); } }
// Use this for initialization void Awake() { player = GameObject.FindGameObjectWithTag(TagsLayer.Player).transform; waypoints = transform.Find("waypoints").GetComponent <WayPointsGizmos>(); startPos = this.transform.position.z - 3000; endPos = this.transform.position.z; targetWayPointIndex = waypoints.wayPoints.Length - 2; forestDenerator = Camera.main.GetComponent <ForestGenerator>(); }
// Use this for initialization void Start() { treeRef = transform.FindChild("FTree").gameObject; fireRef = treeRef.transform.FindChild("FFire").gameObject; forestGenerator = GameObject.Find("Forest").gameObject.GetComponent <ForestGenerator>(); setMesh(); treeRef.GetComponent <Renderer>().material.color = Color.cyan; setColor(); treeRef.transform.localScale = new Vector3(0.3f, 0.3f, 0.3f) * fuel; }
private void GenerateMap() { if (mapType == MapType.Forest) { ForestGenerator forestGen = new ForestGenerator(mapData); } if (mapType == MapType.Cave) { CaveGenerator caveGen = new CaveGenerator(mapData); } }
protected override void LoadContent() { _spriteBatch = new SpriteBatch(GraphicsDevice); _assets.Add(new Asset( new Vector2(0, 0), Content.Load <Texture2D>("Characters/Testingno") )); var forest = new ForestGenerator(TextureHelper.GetForestTextures(Content)) .Generate(new Vector2(-1000, -1000), new Vector2(1000, 1000)); _assets.AddRange(forest); _effects.Add(Content.Load <Effect>("Effects/TestShader")); _player = new Player(new Vector2(0, 0), TextureHelper.GetPlayerAnimations(Content)); }
// Use this for initialization void Start() { // referece to forestGen script forestGen = forestMnger.GetComponent <ForestGenerator>(); rescueScript = animal.GetComponent <RescueAnimal>(); // reset the icons to false so that they don't show up as rescued at the start fox1.enabled = false; fox2.enabled = false; fox3.enabled = false; GameInfo.instance.FoxCount = 0; // instantiate the list animalSpawns = new List <IntVector2>(); }
private void GenerateCostal() { NoiseRiver.AttachMap(GenerationMap, GetCurrentBiomeTileSet().Water); NoiseGroundTiles.GenerateGroundTiles(GenerationMap, GetCurrentBiomeTileSet().GroundTiles); ForestGenerator.GenerateTreesForForest(GenerationMap); int coastLineSide = CoastLineGenerator.GenerateCoastline(GenerationMap, GetCurrentBiomeTileSet().Water); //X 0 X //1 X 3 //X 2 X if (HasRivers) { int riverStartPoint = Mathf.FloorToInt(Width * UnityEngine.Random.Range(0.1F, 0.9F)); switch (coastLineSide) { case 0: NoiseRiver.BuildRiverFromMapEdge(GenerationMap, new MapPoint(riverStartPoint, 0), GetCurrentBiomeTileSet().Water); break; case 1: NoiseRiver.BuildRiverFromMapEdge(GenerationMap, new MapPoint(0, riverStartPoint), GetCurrentBiomeTileSet().Water); break; case 2: NoiseRiver.BuildRiverFromMapEdge(GenerationMap, new MapPoint(riverStartPoint, Height), GetCurrentBiomeTileSet().Water); break; case 3: NoiseRiver.BuildRiverFromMapEdge(GenerationMap, new MapPoint(Width, riverStartPoint), GetCurrentBiomeTileSet().Water); break; default: NoiseRiver.BuildRiverFromMapEdge(GenerationMap, new MapPoint(riverStartPoint, 0), GetCurrentBiomeTileSet().Water); break; } } if (HasPaths) { GeneratePaths(); } }
public override void OnInspectorGUI() { serializedObject.Update(); ForestGenerator gen = (ForestGenerator)target; EditorGUILayout.PropertyField(treePrefab_Prop, new GUIContent("Tree Billboard Prefab")); EditorGUILayout.PropertyField(sprites_Prop, new GUIContent("Tree Materials")); EditorGUILayout.PropertyField(rowSpacing_Prop, new GUIContent("Row Spacing")); EditorGUILayout.PropertyField(rows_Prop, new GUIContent("Rows")); if (GUILayout.Button("Generate")) { gen.GenerateForest(); } serializedObject.ApplyModifiedProperties(); }
public void Awake() { Random.InitState(12080511); INSTANCE = this; existingChunks = new List <ForestGenerator>(); ForestGenerator instance = GameObject.Instantiate(chunkPrefab) as ForestGenerator; instance.transform.position = Vector3.right * 0f; instance.transform.parent = transform; maxChunk = instance; chunkCount++; instance.InitChunk(true, 0, 0, 30); existingChunks.Add(instance); /* * GenerateNext(); */ }
public void GenerateNext() { /* * front.transform.localPosition = Vector3.zero; * back1.transform.localPosition = Vector3.zero; * back2.transform.localPosition = Vector3.zero; * back3.transform.localPosition = Vector3.zero; */ waveNr++; //delete the existing ones foreach (ForestGenerator chunk in existingChunks) { if (maxChunk != chunk) { chunk.UnLoad(); } } existingChunks.Clear(); existingChunks.Add(maxChunk); //TODO make this a level formula ... int amount = 3; //CREATE A NEW CHUNK WITH A NEW maxChunk.LockLeft(); maxChunk.UnlockRight(); for (int i = 0; i < amount; i++) { totalAmount += 1; ForestGenerator instance = GameObject.Instantiate(chunkPrefab) as ForestGenerator; instance.transform.position = maxChunk.transform.position + Vector3.right * 50f; instance.transform.parent = transform; maxChunk = instance; chunkCount++; instance.InitChunk(i == (amount - 1), totalAmount, waveNr, amount * 30); existingChunks.Add(instance); } maxChunk.UnlockLeft(); maxChunk.LockRight(); }
void OnValidate() { // Get components if (heightMapGenerator == null) { heightMapGenerator = GetComponent <HeightMapGenerator>(); } if (forestGenerator == null) { forestGenerator = GetComponent <ForestGenerator>(); } if (hydraulicErosion == null) { hydraulicErosion = GetComponent <HydraulicErosion>(); } // Round chunk grid width to nearest odd number >= 1 if (chunkGridWidth % 2 == 0) { chunkGridWidth = (int)Mathf.Round(chunkGridWidth / 2) * 2 + 1; } // Update component settings heightMapGenerator.averageMapDepth = averageMapDepth; heightMapGenerator.heightMapSettingsList = heightMapSettingsList; forestGenerator.settings = forestGeneratorSettings; hydraulicErosion.settings = hydraulicErosionSettings; if (hydraulicErosion.settings.useHydraulicErosion && chunkGridWidth > 1) { Debug.LogWarning("Can only use Hydraulic Erosion for single chunks"); hydraulicErosion.settings.useHydraulicErosion = false; } }
private void RunButtonClick(object sender, RoutedEventArgs e) { int n; bool validN = Int32.TryParse(nTextBox.Text, out n); if (validN && n > 0) { List <Forest> result; if (rbAlgorithmN.IsChecked == true) { result = new List <Forest> (); } else if (rbAlgorithmP.IsChecked == true) { result = ForestGenerator.AlgorithmP(n); } else { return; } fillTable(result); } }
/// <summary> /// Retrieves all the neighbors of this cell and adds them to the neighbors list /// </summary> private void GetNeighbors() { //The coordinates of this cell IntVector2 position = gameObject.GetComponent <ForestCell>().coordinates; //The forest this cell is in ForestGenerator forest = gameObject.GetComponentInParent <ForestGenerator>(); //Check every direction for (int i = 0; i < 4; i++) { //Calculate the coordinates of each direction IntVector2 cellToGet = position + ForestDirections.ToIntVector2((Direction)i); //If the coordinates calculated are part of the forest, retrieve that cell and add it to the list if (forest.ContainsCoordinates(cellToGet)) { ForestCell temp = forest.GetCell(cellToGet); neighbors.Add(temp); } } neighborsRetrieved = true; }
void Start() { forestGen = FindObjectOfType <ForestGenerator>(); BuildSectionList(); }
public void AttachForestGenerator(ForestGenerator _fg) { forestGenerator = _fg; }
// Use this for initialization void Start() { forestGenerator = Camera.main.GetComponent <ForestGenerator>(); playerAnimation = GetComponent <PlayerAnimation>(); prisoner = transform.Find("Prisoner"); }
public void GenerateMap() { treesOnTheScene.Clear(); treesOnFire.Clear(); foreach (Transform child in TreesParent.transform) { DestroyImmediate(child.gameObject); } MapDisplay display = FindObjectOfType <MapDisplay>(); float[,] heightMap = DecodeFloatTexture(terrainMap); float[,] roadMask = DecodeFloatTexture(roadMap); display.DrawMesh(MeshGenerator.GenerateTerrainMesh(heightMap, roadMask, passes, level), terrainMap); List <Temp> result = ForestGenerator.GenerateTreeLocations(percentage, heightMap, trees.Length); GameObject[] temps = new GameObject[trees.Length]; for (int i = 0; i < trees.Length; i++) { temps[i] = Instantiate(trees[i], Vector3.zero, Quaternion.identity, TreesParent.transform); } for (int i = 0; i < result.Count; i++) { Temp temp = result[i]; if (roadMask[(int)temp.pos.x, (int)temp.pos.z] > .5f) { continue; } GameObject parent = Instantiate(emptyGameObjectPrefab, temp.pos, Quaternion.identity, TreesParent.transform); bool next = false; MeshData meshData = MeshGenerator.CombineMeshData( temps[temp.type].GetComponent <MeshFilter>().mesh, trees[temp.type].GetComponent <MeshFilter>().sharedMesh, temp.pos, trees[temp.type].transform.localScale, out next ); temps[temp.type].GetComponent <MeshFilter>().mesh = meshData.CreateMesh(); meshData = null; if (next) { Debug.Log("Next"); temps[temp.type] = Instantiate(trees[temp.type], Vector3.zero, Quaternion.identity, TreesParent.transform); } GameObject burntIcon = Instantiate(burntIconPrefab.gameObject, parent.transform); GameObject fire = Instantiate(firePrefab.gameObject, parent.transform); ForestTree forestTree = new ForestTree(burntIcon, fire, BurnTime, SpreadSpeed); treesOnTheScene.Add(forestTree); } foreach (ForestTree forestTree in treesOnTheScene) { foreach (ForestTree otherForestTree in treesOnTheScene) { if (forestTree == otherForestTree) { continue; } float dist = Vector3.Distance(otherForestTree.burntIcon.transform.position, forestTree.burntIcon.gameObject.transform.position); if (dist < MaxDistanceToSpreadFire) { forestTree.closestTrees.Add(otherForestTree); } } } }
public void AlgorithmB_0() { Assert.IsTrue(ForestGenerator.AlgorithmB(0).Count == 0); }
private void GeneratePlains() { NoiseGroundTiles.GenerateGroundTiles(GenerationMap, GetCurrentBiomeTileSet().GroundTiles); ForestGenerator.GenerateTreesForForest(GenerationMap); //Creating Rivers if (HasRivers) { int numRivers = 0; //numRivers = UnityEngine.Random.Range(0, 4); switch (Width) { case 72: numRivers = 1; break; case 96: numRivers = 1; break; case 120: numRivers = UnityEngine.Random.Range(1, 3); break; case 144: numRivers = UnityEngine.Random.Range(1, 3); break; case 200: numRivers = UnityEngine.Random.Range(2, 4); break; //case 255: // DifferentSizeIslands.GenerateGiganticIslands(GenerationMap, tilePool.GetTileSetFromBiomeType(SelectedMapBiome)[0]); // break; default: break; } int r = 0; while (r < numRivers) { int riverStartPoint = Mathf.FloorToInt(Width * UnityEngine.Random.Range(0.1F, 0.9F)); int startAxis = UnityEngine.Random.Range(0, 4); switch (startAxis) { //X 2 X //1 X 3 //X 4 X case 0: NoiseRiver.BuildRiverFromMapEdge(GenerationMap, new MapPoint(0, riverStartPoint), GetCurrentBiomeTileSet().Water); break; case 1: NoiseRiver.BuildRiverFromMapEdge(GenerationMap, new MapPoint(riverStartPoint, Height), GetCurrentBiomeTileSet().Water); break; case 2: NoiseRiver.BuildRiverFromMapEdge(GenerationMap, new MapPoint(Width, riverStartPoint), GetCurrentBiomeTileSet().Water); break; case 3: NoiseRiver.BuildRiverFromMapEdge(GenerationMap, new MapPoint(riverStartPoint, Height), GetCurrentBiomeTileSet().Water); break; default: NoiseRiver.BuildRiverFromMapEdge(GenerationMap, new MapPoint(0, riverStartPoint), GetCurrentBiomeTileSet().Water); break; } r++; } } if (HasPaths) { GeneratePaths(); } }