123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using static XunJianDataManager;
- public class CreateWalls : MonoBehaviour
- {
- public GameObject Wall;
- public List<Wall> listWall;
- private void Start()
- {
- this.listWall = getWallData();
- CreateWall(listWall);
- }
- List<Wall> getWallData()
- {
- List<Wall> listWall = new List<Wall>();
- 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<Wall> 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);
- }
- }
- }
|