public void InstantiateTile (GPoint gp) { int index = 0; switch (gp.GetPType ()) { case GPoint.PType.DEBUG: index = 0; break; case GPoint.PType.TILE_TEST: index = 1; break; case GPoint.PType.TILE_GRASS: index = 2; break; case GPoint.PType.TILE_SAND: index = 3; break; case GPoint.PType.TILE_ROADI: index = 4; break; case GPoint.PType.TILE_ROADH: index = 5; break; case GPoint.PType.TILE_ROADV: index = 6; break; case GPoint.PType.TILE_TREE: index = 7; break; case GPoint.PType.TILE_BUILDING: index = 8; break; case GPoint.PType.TILE_HOUSE: index = 9; break; default: index = -1; break; } if (index >= 0) { float scale = 1; GameObject newTile = null; //Destroy (newTile); if (index < 8) { newTile = (GameObject)Instantiate (tilePrefabs [index], gp.GetWorldPosition (), Quaternion.identity); if (index == 7) { scale = Random.Range (0.75f, 1.25f); } } else if (index == 8) { int addup = Random.Range (0, buildingPrefabs.Count ()); scale = Random.Range (0.75f, 1.25f); newTile = (GameObject)Instantiate (buildingPrefabs [addup], gp.GetWorldPosition (), Quaternion.identity); } else if (index == 9) { int addup = Random.Range (0, housePrefabs.Count ()); newTile = (GameObject)Instantiate (housePrefabs [addup], gp.GetWorldPosition (), Quaternion.identity); } newTile.name = "/x:" + gp.GetPosition ().x + "$/y:" + gp.GetPosition ().y + "$/t:" + gp.GetPType () + "$"; newTile.transform.parent = tilePool.transform; newTile.transform.localScale = new Vector3 (1, scale, 1); if (gp.GetPType () == GPoint.PType.TILE_BUILDING || gp.GetPType () == GPoint.PType.TILE_HOUSE) { switch (gp.GetDirection ()) { case GPoint.Direction.NORTH: //Debug.Log ("tile turned north"); newTile.transform.LookAt (newTile.transform.position + Vector3.back); //newTile.transform.Translate (Vector3.up * 1); break; case GPoint.Direction.SOUTH: //Debug.Log ("tile turned south"); newTile.transform.LookAt (newTile.transform.position + Vector3.forward); //newTile.transform.Translate (Vector3.up * 2); break; case GPoint.Direction.EAST: //Debug.Log ("tile turned east"); newTile.transform.LookAt (newTile.transform.position + Vector3.left); //newTile.transform.Translate (Vector3.up * 3); break; case GPoint.Direction.WEST: //Debug.Log ("tile turned west"); newTile.transform.LookAt (newTile.transform.position + Vector3.right); //newTile.transform.Translate (Vector3.up * 4); break; default: break; } ; } } }