// Use this for initialization void Start() { for (int i = 0; i < 3; i++) { for (int j = 0; j < 20; j++) { weights [i, j] = (UnityEngine.Random.value - 0.5f) * (float)Math.Sqrt(j / 2.0); offsets [i, j] = (UnityEngine.Random.value * j / 2.0f); } } map = new HexMap <GameObject> (20, (x, y, z) => { TilePosition p = new TilePosition(x, y, z); Vector2 cartesian = p.cartesian(); GameObject o = byHeight(p); o.transform.position = new Vector3(cartesian.x, 0, cartesian.y); return(o); }); // TilePosition p1 = new TilePosition (0, 0, 0); // TilePosition p2 = new TilePosition (0, 1, -1); // TilePosition p3 = new TilePosition (1, 0, -1); // // GameObject o1 = Instantiate (water); // o1.transform.position = new Vector3 (p1.cartesian ().x, 0, p1.cartesian ().y); // GameObject o2 = Instantiate (water); // o2.transform.position = new Vector3 (p2.cartesian ().x, 0, p2.cartesian ().y); // GameObject o3 = Instantiate (water); // o3.transform.position = new Vector3 (p3.cartesian ().x, 0, p3.cartesian ().y); // // for (int i = 0; i < 20; i++) { // for (int j = 0; j < 20; j++) { // //(+, -, +-) // TilePosition p = new TilePosition (x: i, y: -j); // Vector2 cartesian = p.cartesian (); // GameObject o = byHeight (p);//isLand(i, -j, j - i) ? Instantiate (ground) : Instantiate (water); // o.transform.position = new Vector3 (cartesian.x, 0, cartesian.y); // map [p] = o; // //(+-, +, -) // TilePosition p2 = new TilePosition (y: i, z: -j); // Vector2 cartesian2 = p2.cartesian (); // GameObject o2 = byHeight (p2);//isLand(j - i, i, -j) ? Instantiate (ground) : Instantiate (water); // o2.transform.position = new Vector3 (cartesian2.x, 0, cartesian2.y); // map [p2] = o2; // //(-, +- +) // TilePosition p3 = new TilePosition (x: -j, z: i); // Vector2 cartesian3 = p3.cartesian (); // GameObject o3 = byHeight (p3);//isLand(-j, j - i, i) ? Instantiate (ground) : Instantiate (water); // o3.transform.position = new Vector3 (cartesian3.x, 0, cartesian3.y); // map [p3] = o3; // } // } // float time = 1.0f; // foreach(GameObject obj in map){ // Destroy(obj, time); // time += 1.0f; // } // int size = 20; // for (int i = 0; i < size; i++) { // for (int j = 0; j < size - i; j++) { // TilePosition[] p = new TilePosition[6]; // p [0] = new TilePosition (i, j, -i - j); // p [1] = new TilePosition (i, -i - j, j); // p [2] = new TilePosition (-i - j, i, j); // p [3] = new TilePosition (-i, -j, i + j); // p [4] = new TilePosition (-i, i + j, -j); // p [5] = new TilePosition (i + j, -i, -j); // for (int k = 0; k < 6; k++) { // Vector2 cartesian = p [k].cartesian (); // GameObject o = isLand (p [k]) ? Instantiate (ground) : Instantiate (water); // o.transform.position = new Vector3 (cartesian.x, 0, cartesian.y); // } // } // } // // print(water.transform.lossyScale.x); // // for (int i = 0; i < map.Length; i++) { // map [i] = new int[map_width]; // } // // print (map); // // for (int i = 0; i < map.Length; i++) { // for (int j = 0; j < map [i].Length; i++) { // double d = Mathf.PerlinNoise (i, j); // if (d < 0.5) { // map [i][j] = 0; // } else { // map [i][j] = 1; // } // } // } // // for (int i = 0; i < map.Length; i++) { // for (int j = 0; j < map [i].Length; i++) { // GameObject g = Instantiate (water); // Vector3 scale = new Vector3 (tile_width, 160, tile_width); // g.transform.localScale = scale; // // g.transform.position = new Vector3 (tile_width, 0, tile_width); // } // } // }