Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private GameObject WallBuilder(int x, int z, Transform parent)
- {
- // Debug.Log(x + " " + z);
- GameObject wall;
- float angle = 0f;
- bool corner = false;
- if (x == 0 && z == 0) // Bottom Left
- {
- corner = true;
- angle = 90;
- }
- else if (x == 0 && z == townSize - 1) // Top Left
- {
- corner = true;
- angle = 180;
- }
- else if (x == townSize - 1 && z == 0) // Bottom Right
- {
- corner = true;
- angle = 0;
- }
- else if (x == townSize - 1 && z == townSize - 1) // Top Right
- {
- corner = true;
- angle = 270;
- }
- else if (x == 0 && z > 0) // Walls Left
- {
- corner = false;
- angle = 180;
- }
- else if (x == townSize -1 && z > townSize -1) // Walls Right
- {
- corner = false;
- angle = 180;
- }
- else if (x > 0 && z == townSize -1) // Walls North
- {
- corner = false;
- angle = 270;
- }
- else if (x > 0 && z == 0) // Walls South
- {
- corner = false;
- angle = 90;
- }
- // it's a corner
- if (corner)
- {
- wall = Instantiate(wallCorner[Random.Range(0, wallCorner.Length - 1)], parent);
- wall.transform.position = gridNodes[x, z];
- wall.transform.rotation = Quaternion.Euler(0, angle, 0);
- }
- else
- {
- wall = Instantiate(walls[Random.Range(0, walls.Length - 1)], parent);
- wall.transform.position = gridNodes[x, z];
- wall.transform.rotation = Quaternion.Euler(0, angle, 0);
- wall.name = wall.name + ":" + x +","+ z;
- }
- return wall;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement