备份数据加
This commit is contained in:
parent
afd3bee6b7
commit
c7001ae3d0
@ -1,24 +0,0 @@
|
|||||||
diff a/Blacksmith/Assets/Script/Battle/BattleManager.cs b/Blacksmith/Assets/Script/Battle/BattleManager.cs (rejected hunks)
|
|
||||||
@@ -295,15 +295,15 @@
|
|
||||||
var index = i;
|
|
||||||
if (BattleEquipments[i].EquipmentLock)
|
|
||||||
{
|
|
||||||
- PrefabPool.ins.LoadObj("Prefab/player/player", (GameObject obj) =>
|
|
||||||
+ PrefabPool.ins.LoadObj("Prefab/player/player",index, (GameObject obj,int idex) =>
|
|
||||||
{
|
|
||||||
- obj.transform.parent = playerParent[index];
|
|
||||||
+ obj.transform.parent = playerParent[idex];
|
|
||||||
obj.transform.localPosition=Vector3.zero;
|
|
||||||
- playerItems[index] = new PlayerRunState();
|
|
||||||
- playerItems[index].player = obj.GetComponent<PlayerItem>();
|
|
||||||
- playerItems[index].equipent = BattleEquipments[index];
|
|
||||||
- playerItems[index].RestState();
|
|
||||||
-
|
|
||||||
+ playerItems[idex] = new PlayerRunState();
|
|
||||||
+ playerItems[idex].player = obj.GetComponent<PlayerItem>();
|
|
||||||
+ playerItems[idex].equipent = BattleEquipments[idex];
|
|
||||||
+ playerItems[idex].RestState();
|
|
||||||
+ playerItems[idex].player.SetModel(idex+1);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,7 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 97b74a549b99c204480a3dffcd22dc98
|
|
||||||
DefaultImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
65
Blacksmith/Assets/Script/VoxelizationTool.cs
Normal file
65
Blacksmith/Assets/Script/VoxelizationTool.cs
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
using UnityEngine;
|
||||||
|
using UnityEditor;
|
||||||
|
|
||||||
|
[ExecuteInEditMode]
|
||||||
|
public class VoxelizationTool : MonoBehaviour
|
||||||
|
{
|
||||||
|
public Vector3 gridSize = new Vector3(10, 10, 10); // 体素化区域的尺寸
|
||||||
|
public float voxelSize = 1.0f; // 每个体素的大小
|
||||||
|
public Color gridColor = Color.cyan; // 网格颜色
|
||||||
|
public bool showGrid = true; // 是否显示网格
|
||||||
|
public bool onlyShowMeshVoxels = true; // 是否仅显示包含 Mesh 的体素
|
||||||
|
|
||||||
|
private Bounds gridBounds; // 网格的总体包围盒
|
||||||
|
|
||||||
|
private void OnDrawGizmos()
|
||||||
|
{
|
||||||
|
if (!showGrid) return;
|
||||||
|
|
||||||
|
Gizmos.color = gridColor;
|
||||||
|
|
||||||
|
// 定义整个体素网格的包围盒
|
||||||
|
gridBounds = new Bounds(transform.position + gridSize * voxelSize / 2, gridSize * voxelSize);
|
||||||
|
|
||||||
|
// 获取场景中的所有 MeshFilter
|
||||||
|
MeshFilter[] meshFilters = FindObjectsOfType<MeshFilter>();
|
||||||
|
|
||||||
|
foreach (MeshFilter meshFilter in meshFilters)
|
||||||
|
{
|
||||||
|
Bounds meshBounds = meshFilter.sharedMesh.bounds;
|
||||||
|
meshBounds = TransformBounds(meshBounds, meshFilter.transform);
|
||||||
|
|
||||||
|
// 遍历体素,检查是否与当前 Mesh 的 Bounds 相交
|
||||||
|
for (int x = 0; x < gridSize.x; x++)
|
||||||
|
{
|
||||||
|
for (int y = 0; y < gridSize.y; y++)
|
||||||
|
{
|
||||||
|
for (int z = 0; z < gridSize.z; z++)
|
||||||
|
{
|
||||||
|
Vector3 voxelCenter = transform.position + new Vector3(x, y, z) * voxelSize + Vector3.one * voxelSize / 2;
|
||||||
|
|
||||||
|
// 跳过不在包围盒内的体素
|
||||||
|
if (!gridBounds.Contains(voxelCenter)) continue;
|
||||||
|
|
||||||
|
// 检查体素是否与 Mesh 的 Bounds 相交
|
||||||
|
Bounds voxelBounds = new Bounds(voxelCenter, Vector3.one * voxelSize);
|
||||||
|
if (meshBounds.Intersects(voxelBounds))
|
||||||
|
{
|
||||||
|
Gizmos.DrawWireCube(voxelCenter, Vector3.one * voxelSize);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 将本地 Bounds 转换为世界空间的 Bounds
|
||||||
|
/// </summary>
|
||||||
|
private Bounds TransformBounds(Bounds localBounds, Transform transform)
|
||||||
|
{
|
||||||
|
Vector3 worldCenter = transform.TransformPoint(localBounds.center);
|
||||||
|
Vector3 worldExtents = Vector3.Scale(localBounds.extents, transform.lossyScale);
|
||||||
|
return new Bounds(worldCenter, worldExtents * 2);
|
||||||
|
}
|
||||||
|
}
|
11
Blacksmith/Assets/Script/VoxelizationTool.cs.meta
Normal file
11
Blacksmith/Assets/Script/VoxelizationTool.cs.meta
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 7ed37701935d86d418ebb34d139e67d8
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
@ -81,14 +81,18 @@ func main() {
|
|||||||
|
|
||||||
// 检查是否缺少必要参数
|
// 检查是否缺少必要参数
|
||||||
if mpID == "" || dateHour == "" {
|
if mpID == "" || dateHour == "" {
|
||||||
http.Error(w, "缺少必要的参数 mp_id 或 date_hour", http.StatusBadRequest)
|
errorMessage := "缺少必要的参数 mp_id 或 date_hour"
|
||||||
|
fmt.Println(errorMessage)
|
||||||
|
http.Error(w, errorMessage, http.StatusBadRequest)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取动态的 access_token
|
// 获取动态的 access_token
|
||||||
accessToken, err := GetAccessToken()
|
accessToken, err := GetAccessToken()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
http.Error(w, fmt.Sprintf("获取 access_token 失败: %v", err), http.StatusInternalServerError)
|
errorMessage := fmt.Sprintf("获取 access_token 失败: %v", err)
|
||||||
|
fmt.Println(errorMessage)
|
||||||
|
http.Error(w, errorMessage, http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -107,7 +111,9 @@ func main() {
|
|||||||
// 调用抖音 API
|
// 调用抖音 API
|
||||||
resp, err := http.Get(fullURL)
|
resp, err := http.Get(fullURL)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
http.Error(w, "调用抖音 API 失败", http.StatusInternalServerError)
|
errorMessage := "调用抖音 API 失败"
|
||||||
|
fmt.Println(errorMessage, err)
|
||||||
|
http.Error(w, errorMessage, http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
@ -115,7 +121,9 @@ func main() {
|
|||||||
// 读取抖音 API 响应数据
|
// 读取抖音 API 响应数据
|
||||||
responseBody, err := ioutil.ReadAll(resp.Body)
|
responseBody, err := ioutil.ReadAll(resp.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
http.Error(w, "读取抖音 API 响应失败", http.StatusInternalServerError)
|
errorMessage := "读取抖音 API 响应失败"
|
||||||
|
fmt.Println(errorMessage, err)
|
||||||
|
http.Error(w, errorMessage, http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -123,13 +131,17 @@ func main() {
|
|||||||
var apiResponse APIResponse
|
var apiResponse APIResponse
|
||||||
err = json.Unmarshal(responseBody, &apiResponse)
|
err = json.Unmarshal(responseBody, &apiResponse)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
http.Error(w, "解析 API 响应数据失败", http.StatusInternalServerError)
|
errorMessage := "解析 API 响应数据失败"
|
||||||
|
fmt.Println(errorMessage, err)
|
||||||
|
http.Error(w, errorMessage, http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检查 API 是否返回错误
|
// 检查 API 是否返回错误
|
||||||
if apiResponse.ErrNo != 0 {
|
if apiResponse.ErrNo != 0 {
|
||||||
http.Error(w, fmt.Sprintf("抖音 API 返回错误: %s (错误码: %d)", apiResponse.ErrMsg, apiResponse.ErrNo), http.StatusInternalServerError)
|
errorMessage := fmt.Sprintf("抖音 API 返回错误: %s (错误码: %d)", apiResponse.ErrMsg, apiResponse.ErrNo)
|
||||||
|
fmt.Println(errorMessage)
|
||||||
|
http.Error(w, errorMessage, http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -143,28 +155,29 @@ func main() {
|
|||||||
|
|
||||||
// 如果没有记录,则返回错误
|
// 如果没有记录,则返回错误
|
||||||
if totalRecords == 0 {
|
if totalRecords == 0 {
|
||||||
http.Error(w, "未找到记录,无法计算 ECPM", http.StatusOK)
|
errorMessage := "未找到记录,无法计算 ECPM"
|
||||||
|
fmt.Println(errorMessage)
|
||||||
|
http.Error(w, errorMessage, http.StatusOK)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
ecpm := float64(totalCost) / 100000 * 1000 / float64(totalRecords)
|
ecpm := float64(totalCost) / 100000 * 1000 / float64(totalRecords)
|
||||||
|
|
||||||
// 构造返回的 JSON 数据
|
// 根据 ECPM 值判断并返回 "true" 或 "false"
|
||||||
result := map[string]interface{}{
|
var result string
|
||||||
"total_cost": float64(totalCost) / 100000,
|
if ecpm > 300 && totalRecords > 2 {
|
||||||
"total_records": totalRecords,
|
result = "true"
|
||||||
"ecpm": ecpm,
|
} else {
|
||||||
}
|
result = "false"
|
||||||
resultJSON, err := json.Marshal(result)
|
|
||||||
if err != nil {
|
|
||||||
http.Error(w, "生成返回 JSON 数据失败", http.StatusInternalServerError)
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 返回 JSON 格式的 ECPM 数据
|
// 打印日志
|
||||||
|
fmt.Printf("ECPM: %.2f, Result: %s\n", ecpm, result)
|
||||||
|
|
||||||
|
// 返回结果
|
||||||
w.Header().Set("Content-Type", "application/json")
|
w.Header().Set("Content-Type", "application/json")
|
||||||
w.WriteHeader(http.StatusOK)
|
w.WriteHeader(http.StatusOK)
|
||||||
w.Write(resultJSON)
|
w.Write([]byte(result))
|
||||||
})
|
})
|
||||||
|
|
||||||
// 启动 HTTP 服务器
|
// 启动 HTTP 服务器
|
||||||
|
Loading…
x
Reference in New Issue
Block a user