using System.Collections; using System.Collections.Generic; using UnityEngine; using static XunJianDataManager; public class CreateWalls : MonoBehaviour { public GameObject Wall; public List listWall; private void Start() { this.listWall = getWallData(); CreateWall(listWall); } List getWallData() { List listWall = new List(); for (int i = 0; i < 6; i++) { switch (i) { case 0: Wall wall = new Wall(); wall.listPoint.Add(new Vector3(-5, 0, 0.25f)); wall.listPoint.Add(new Vector3(5, 0, 0.25f)); wall.listPoint.Add(new Vector3(5, 0, -0.25f)); wall.listPoint.Add(new Vector3(-5, 0, -0.25f)); listWall.Add(wall); break; case 1: Wall wall1 = new Wall(); wall1.listPoint.Add(new Vector3(-5, 0, -4.75f)); wall1.listPoint.Add(new Vector3(5, 0, -4.75f)); wall1.listPoint.Add(new Vector3(5, 0, -5.25f)); wall1.listPoint.Add(new Vector3(-5, 0, -5.25f)); listWall.Add(wall1); break; case 2: Wall wall2 = new Wall(); wall2.listPoint.Add(new Vector3(-5.25f, 0, 0)); wall2.listPoint.Add(new Vector3(-4.75f, 0, 0)); wall2.listPoint.Add(new Vector3(-4.75f, 0, -5)); wall2.listPoint.Add(new Vector3(-5.25f, 0, -5)); listWall.Add(wall2); break; case 3: Wall wall3 = new Wall(); wall3.listPoint.Add(new Vector3(4.75f, 0, 0)); wall3.listPoint.Add(new Vector3(5.25f, 0, 0)); wall3.listPoint.Add(new Vector3(5.25f, 0, -5)); wall3.listPoint.Add(new Vector3(4.75f, 0, -5)); listWall.Add(wall3); break; case 4: Wall wall4 = new Wall(); wall4.listPoint.Add(new Vector3(-2.75f, 0, -1f)); wall4.listPoint.Add(new Vector3(-2.25f, 0, -1f)); wall4.listPoint.Add(new Vector3(-2.25f, 0, -3f)); wall4.listPoint.Add(new Vector3(-2.75f, 0, -3f)); listWall.Add(wall4); break; case 5: Wall wall5 = new Wall(); wall5.listPoint.Add(new Vector3(2.25f, 0, -2)); wall5.listPoint.Add(new Vector3(2.75f, 0, -2)); wall5.listPoint.Add(new Vector3(2.75f, 0, -4)); wall5.listPoint.Add(new Vector3(2.25f, 0, -4)); listWall.Add(wall5); break; default: break; } } return listWall; } public void CreateWall( List listWall) { for (int i = 0; i < listWall.Count; i++) { Transform wallObj = GameObject.Instantiate(Wall).transform; wallObj.position = listWall[i].listPoint[0]; float x = Vector3.Distance(listWall[i].listPoint[0], listWall[i].listPoint[1]); float y = Vector3.Distance(listWall[i].listPoint[0], listWall[i].listPoint[3]); wallObj.localScale = new Vector3(x, 3, y); } } }