/// <summary> /// 获取建筑物的世界坐标 /// </summary> /// <returns></returns> public List <Vector3> GetBuildWorldPosition() { List <Vector3> worldPositionList = new List <Vector3>(); List <Transform> buildPositionList = CptUtil.GetAllCptInChildrenByContainName <Transform>(objBuildPositionList, "Position_"); foreach (Transform itemTF in buildPositionList) { worldPositionList.Add(itemTF.position); } return(worldPositionList); }
/// <summary> /// 获取建筑位置 /// </summary> /// <returns></returns> public List <Vector3> GetBuildPosition() { List <Vector3> listPosition = new List <Vector3>(); List <Transform> buildPositionList = CptUtil.GetAllCptInChildrenByContainName <Transform>(objBuildPositionList, "Position_"); foreach (Transform itemTF in buildPositionList) { Vector3 position = transform.InverseTransformPoint(itemTF.position); listPosition.Add(position); } return(listPosition); }
/// <summary> /// 获取建筑物内部顶点坐标 /// </summary> /// <returns></returns> public Vector3 GetRandomBuildingInsidePosition(TownBuildingEnum townBuildingEnum) { if (marketInside == null) { return(Vector3.zero); } Transform tfBuilding = null; switch (townBuildingEnum) { case TownBuildingEnum.Town: tfBuilding = townInside; break; case TownBuildingEnum.Market: tfBuilding = marketInside; break; case TownBuildingEnum.Recruitment: tfBuilding = recruitmentInside; break; case TownBuildingEnum.Grocery: tfBuilding = groceryInside; break; case TownBuildingEnum.Dress: tfBuilding = dressInside; break; case TownBuildingEnum.Carpenter: tfBuilding = carpenterInside; break; case TownBuildingEnum.Guild: tfBuilding = guildInside; break; case TownBuildingEnum.Arena: tfBuilding = arenaInside; break; case TownBuildingEnum.Bank: tfBuilding = bankInside; break; case TownBuildingEnum.Pharmacy: tfBuilding = pharmacyInside; break; case TownBuildingEnum.Casino: tfBuilding = casinoInside; break; case TownBuildingEnum.Brothels: tfBuilding = brothelsInside; break; case TownBuildingEnum.BeautySalon: tfBuilding = beautySalonInside; break; } if (tfBuilding == null) { return(Vector3.zero); } List <Transform> tfList = CptUtil.GetAllCptInChildrenByContainName <Transform>(tfBuilding.gameObject, "Wall_"); if (CheckUtil.ListIsNull(tfList)) { return(Vector3.zero); } Transform tfItem = RandomUtil.GetRandomDataByList(tfList); return(GameUtil.GetTransformInsidePosition2D(tfItem));; }