/// <summary> /// 封鎖の壁を作る /// </summary> /// <param name="postion">壁生成の位置</param> /// <param name="needDirection">壁の方向</param> void CreateWall(Vector3 postion, OutDirection needDirection) { AreaPrefabManager areaManager; makingAreaType = UnitType.Wall; if (makingAreaType == UnitType.Road) { areaManager = WallPrefab[0].GetComponent<AreaPrefabManager>(); CreateArea(WallPrefab[0], areaManager, new Vector2(postion.x, postion.z), areaManager.AreaAngle0.areaOut[0].direction.getAngleFromTargetDirection(needDirection)); } else { areaManager = WallPrefab[1].GetComponent<AreaPrefabManager>(); CreateArea(WallPrefab[1], areaManager, new Vector2(postion.x, postion.z), areaManager.AreaAngle0.areaOut[0].direction.getAngleFromTargetDirection(needDirection)); } //todo }
/// <summary> /// 次のエリアを生成する 生成下一个地区 /// </summary> /// <param name="entryPoint">生成するエリアの入口の座標 生成的入口点</param> /// <param name="needDirection">必要な入口の方向 入口点的方向</param> /// <param name="upFloorNumber">生成するエリアの上のエリアの深度</param> void MakeNormalArea(Vector3 entryPoint, OutDirection needDirection, int upFloorNumber) { int thisFloorNumber = upFloorNumber + 1; GameObject areaPrefab = null; GameObject[] randomNormalPrefabList = null; //GameObject changedPrefab; AreaPrefabManager areaManager = null; AreaPrefabOut[] areaOutList = null; Vector3 areaPostion = Vector3.zero; int entryIndex = 0; int areaTypeIndex = 0; AngleFix angle = AngleFix.none; bool checkRes = false; normalTypeArray = nowWeightPoint.GetWeightRandomTypeOrder(normalTypeArray); for (areaTypeIndex = 0; areaTypeIndex < normalTypeArray.Length && !checkRes; areaTypeIndex++) { switch (normalTypeArray[areaTypeIndex]) { case UnitType.Road: { randomNormalPrefabList = RoadPrefab.getRandomArray(); break; } case UnitType.Room: { randomNormalPrefabList = RoomPrefab.getRandomArray(); break; } case UnitType.End: { //每当生成终节点时,如果尚未生成向下场景,则生成向下场景/传送阵场景 if (!isDownSet) { randomNormalPrefabList = DownPrefab.getRandomArray(); } else if (!isPorSet) { randomNormalPrefabList = PortalPrefab.getRandomArray(); } else { randomNormalPrefabList = EndPrefab.getRandomArray(); } break; } case UnitType.Corner: { randomNormalPrefabList = CornerPrefab.getRandomArray(); break; } case UnitType.Wall: { randomNormalPrefabList = null; CreateWall(entryPoint, needDirection); return; } } for (int i = 0; i < randomNormalPrefabList.Length && !checkRes; i++) { areaPrefab = randomNormalPrefabList[i]; //Debug.Log(areaPrefab.name); areaManager = areaPrefab.GetComponent<AreaPrefabManager>(); areaOutList = areaManager.AreaAngle0.areaOut.getRandomArray(); for (entryIndex = 0; entryIndex < areaOutList.Length; entryIndex++) { angle = areaOutList[entryIndex].direction.getAngleFromTargetDirection(needDirection); areaPostion = entryPoint - areaOutList[entryIndex].Rot(angle).position; checkRes = checkInMap(areaPostion, areaManager, angle); #region 超出地图范围的情况下,允许生成传送阵和出口 if (!checkRes && (!isDownSet || !isPorSet)) { if (!isDownSet) { areaPrefab = DownPrefab.getRandomOne(); normalTypeArray[areaTypeIndex] = UnitType.Down; } else { areaPrefab = PortalPrefab.getRandomOne(); normalTypeArray[areaTypeIndex] = UnitType.Portal; } areaManager = areaPrefab.GetComponent<AreaPrefabManager>(); areaOutList = areaManager.AreaAngle0.areaOut.getRandomArray(); angle = areaOutList[0].direction.getAngleFromTargetDirection(needDirection); areaPostion = entryPoint - areaOutList[0].Rot(angle).position; } #endregion if (mode == MakeMode.MakeSceneMode) { checkRes = checkRes && CheckAreaPhysics(areaPostion, areaManager, angle); } else { checkRes = checkRes && CheckAreaOverlay(areaPostion, areaManager, angle); } if (checkRes) { if (areaManager.type == UnitType.Portal) { isPorSet = true; } else if (areaManager.type == UnitType.Down) { isDownSet = true; } break; } } } if (checkRes) { break; } } //全てのエリアのマッチングが出来ない場合、入口を封鎖する 所有地区生成不能的情况下,封堵 if (!checkRes) { CreateWall(entryPoint, needDirection); return; } //ウェイトを調整 调整权重 TrimWeightPoint(areaManager, thisFloorNumber); //エリアを生成する 生成区域 makingAreaType = normalTypeArray[areaTypeIndex]; CreateArea(areaPrefab, areaManager, new Vector2(areaPostion.x, areaPostion.z), angle); for (int i = 0; i < areaOutList.Length; i++) { if (i != entryIndex) { MakeNormalArea(areaOutList[i].Rot(angle).position + areaPostion, areaOutList[i].Rot(angle).direction.TureBack(), thisFloorNumber); TrimWeightPoint(areaManager, thisFloorNumber); } } //TODO:生成方法 }