private void GenerateTileGridArray() { tileGrid = new string[rows, columns]; resourceGrid = new string[rows, columns]; for (int i = 0; i < rows; i++) { for (int j = 0; j < columns; j++) { } } GenerateMountainTiles.SetMountains(tileGrid, rows, columns); GenerateWaterTiles.SetWater(tileGrid, rows, columns); GenerateGrassTiles.SetGrass(tileGrid, rows, columns); GenerateTrees.SetTrees(resourceGrid, tileGrid, rows, columns); GenerateWheat.SetWheat(resourceGrid, tileGrid, rows, columns); GenerateGoldOre.SetGoldOre(resourceGrid, tileGrid, rows, columns); GenerateTilePrefabs(); }
// Use this for initialization void Start() { ground = GameObject.Find("Ground"); player = GameObject.Find("Player"); WalkingGeneration.setValues(); if (map == null) { // Put the correct data in the map map = new Hashtable(); Random.seed = seed; Vector3 position = new Vector3(); // This is the starting position previousYPosR = 10; previousYPosL = 10; // Create map from -1000 to 1000 for (float i = minX; i < maxX; i += widthOfGroundPiece) { // Pick whether the block goes up or down previousYPosR += selectDirection(); for (float j = -20; j < previousYPosR; j += widthOfGroundPiece) { position = new Vector3(i, j, WALL_LAYER); map.Add(position, "Wall"); position.z = STANDARD_LAYER; map.Add(position, "Rock"); } Vector3 position1 = position; Vector3 position2 = position; Vector3 position3 = position; Vector3 position4 = position; position1.y = position.y - 1; position2.y = position.y - 2; position3.y = position.y - 3; position4.y = position.y - 4; // Put grassy block on top map.Remove(position); map.Remove(position1); map.Remove(position2); map.Remove(position3); map.Remove(position4); map.Add(position1, "Dirt"); map.Add(position2, "Dirt"); map.Add(position3, "Dirt"); map.Add(position4, "Dirt"); map.Add(position, "DirtWGrass"); position.z = WALL_LAYER; position1.z = WALL_LAYER; position2.z = WALL_LAYER; position3.z = WALL_LAYER; position4.z = WALL_LAYER; map.Remove(position); map.Remove(position1); map.Remove(position2); map.Remove(position3); map.Remove(position4); // Set minimum and maximum y value if (previousYPosR > maxY) { maxY = previousYPosR; } if (previousYPosR < minY) { minY = previousYPosR; } } } else { Debug.Log("Loaded map"); maxY = 100; } // Generate Caves for (int i = 0; i < 10; i++) { GenerateCaves.generateCave(); } GenerateTrees.treeLocation((int)maxY, 1.95f); player.transform.position = new Vector3(10, 26); // Creating the objects for around you when you spawn int loadingRight = Mathf.RoundToInt(player.transform.position.x + distToDestroyBox); int loadingLeft = Mathf.RoundToInt(player.transform.position.x - distanceBetweenLoads); int bottomLoad = Mathf.RoundToInt(player.transform.position.y - distToDestroyBox); int topLoad = Mathf.RoundToInt(player.transform.position.y + distToDestroyBox); for (float i = loadingLeft; i < loadingRight; i += widthOfGroundPiece) { for (float j = bottomLoad; j < topLoad; j += widthOfGroundPiece) { WalkingGeneration.loadPeice(i, j, STANDARD_LAYER); WalkingGeneration.loadPeice(i, j, WALL_LAYER); WalkingGeneration.loadPeice(i, j, GRASS_LAYER); } } }