private void InitBody() { //** 調整組合亭中的柱子列表,再創造出柱子位置 List <List <Vector3> > allEaveColList = new List <List <Vector3> >(); for (int i = 0; i < BuildingsList.Count; i++) { List <Vector3> newPosList = BuildingsList[i].bodyController.GetColumnStructBottomPosList(BuildingsList[i].bodyController.eaveCornerColumnList); allEaveColList.Add(newPosList); } List <List <Vector3> > allGoldColList = new List <List <Vector3> >(); for (int i = 0; i < BuildingsList.Count; i++) { List <Vector3> newPosList = BuildingsList[i].bodyController.GetColumnStructBottomPosList(BuildingsList[i].bodyController.goldCornerColumnList); allGoldColList.Add(newPosList); } List <List <Vector3> > newColLists = new List <List <Vector3> >(); newColLists = AdjustColPos(BuildingsList, allEaveColList, allGoldColList); body = new GameObject("body"); body.transform.parent = this.transform; if (!bodyController) { bodyController = this.gameObject.AddComponent <BodyController4CT>(); } bodyController.InitFunction(this, newColLists[0], newColLists[1], (bodyController.eaveColumnHeight == 0) ? BuildingsList[0].bodyController.eaveColumnHeight : bodyController.eaveColumnHeight); sides = BuildingsList[0].sides; //** 摧毀亭的body for (int j = 0; j < BuildingsList.Count; j++) { Destroy(BuildingsList[j].body.gameObject); } }
/** * 初始化 */ public void InitFunction(GameObject building, Vector3 position, MainController.FormFactorSideType sides, float platLength, float platWidth, float platHeight, float eaveColumnHeight, float goldColumnHeight, float mainRidgeHeightOffset, float allJijaHeight, List <Vector3> topFloorBorderList, int roofType, bool isStair, float rotateAngle = 0) { this.building = building; this.building.transform.parent = building.transform; this.rotateAngle = rotateAngle; this.sides = sides; platformCenter = position; platform = new GameObject("platform"); platform.transform.parent = this.building.transform; platform.transform.position = platformCenter; bodyCenter = platformCenter + (platHeight / 2.0f + eaveColumnHeight / 2.0f) * Vector3.up; body = new GameObject("body"); body.transform.parent = this.building.transform; roof = new GameObject("roof"); roof.transform.parent = this.building.transform; platformController = building.AddComponent <PlatformController>(); bodyController = building.AddComponent <BodyController>(); roofController = building.AddComponent <RoofController>(); //入口位置 //entraneIndexList.SetEntranceIndex(0); platformController.InitFunction(this, platWidth, platLength, platHeight, isStair, rotateAngle); bodyController.InitFunction(this, eaveColumnHeight, goldColumnHeight); roofController.InitFunction(this, bodyController.GetColumnStructTopPosList(bodyController.eaveCornerColumnList), topFloorBorderList, platWidth, eaveColumnHeight, mainRidgeHeightOffset, allJijaHeight, roofType); buildingHeight = Vector3.Distance(roofTopCenter, platformCenter) + platformController.platHeight / 2.0f; }