每日自动提交 2026-03-31 18:30

This commit is contained in:
2026-03-31 18:30:49 +08:00
parent 5c178e1efb
commit 10ef09b0bf
6 changed files with 401 additions and 1759 deletions
@@ -146,6 +146,13 @@ MonoBehaviour:
m_ReadOnly: 0
m_SerializedLabels: []
FlaggedDuringContentUpdateRestriction: 0
- m_GUID: 9cb87a61eb7629349887ef196c9eeaf7
m_Address: Assets/MyGame/aa/Game/HHWK/Boss/YiLong/Game177_yilong.prefab
m_ReadOnly: 0
m_SerializedLabels:
- FishPrefab
- HHWK
FlaggedDuringContentUpdateRestriction: 0
- m_GUID: 9f5ad7a1381056946a3a0eceb700adbc
m_Address: Assets/MyGame/aa/UI/Home/Sub/AnnouncementPanel.prefab
m_ReadOnly: 0
@@ -164,6 +164,13 @@ MonoBehaviour:
- FishPrefab
- HHWK
FlaggedDuringContentUpdateRestriction: 0
- m_GUID: 584a277c3b4521c408f5dd65b17826a4
m_Address: "Assets/MyGame/aa/Game/HHWK/GameMoveLne/\u9ED1\u795E\u8BDD\u609F\u7A7ABOSS.txt"
m_ReadOnly: 0
m_SerializedLabels:
- HHWK
- MoveLine
FlaggedDuringContentUpdateRestriction: 0
- m_GUID: 5a583fd179bb19e4693bdbb25c336cc0
m_Address: Assets/game_download/games/game177/prefab/fish/Game177_tieshangongzhu.prefab
m_ReadOnly: 0
@@ -241,13 +248,6 @@ MonoBehaviour:
- FishPrefab
- HHWK
FlaggedDuringContentUpdateRestriction: 0
- m_GUID: 7c45496dc34e95e48a133e52513cdc90
m_Address: Assets/game_download/games/game177/prefab/fish/Game177_yilong.prefab
m_ReadOnly: 0
m_SerializedLabels:
- FishPrefab
- HHWK
FlaggedDuringContentUpdateRestriction: 0
- m_GUID: 7f14846161382ce4f9a025f37c02bd8d
m_Address: Assets/game_download/games/game177/prefab/fish/Game177_yilong_sj_hd.prefab
m_ReadOnly: 0
@@ -1,4 +1,5 @@
using System.Collections;
#region zijixie
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Device;
@@ -107,3 +108,4 @@ public static class CoordinateTransformation
}
}
#endregion
File diff suppressed because it is too large Load Diff
@@ -1,4 +1,9 @@
using Assets.MyGame.Scripts.Net.API.GameConfig_SubClass;
#region AI优化
#endregion
#region zijixie
using Assets.MyGame.Scripts.Net.API.GameConfig_SubClass;
using Assets.MyGame.Scripts.Net.APIResponses.Enum;
using Spine;
using Spine.Unity;
@@ -194,7 +199,9 @@ public class MonsterContral : MonoBehaviour
case "710":
moveTime += Time.deltaTime;
{
Vector2 v2 = monsterData.moveLine.GetBezierPoint(moveTime);
//Vector2 v2 = monsterData.moveLine.GetBezierPoint(moveTime);
Vector2 v2 = monsterData.moveLine.GetBezierPointJob(moveTime);
if ((FishTypeEnum)monsterData.fishTypeConfig.fishType != FishTypeEnum.Boss鱼)
{
switch (forwordXYZ)
@@ -238,8 +245,8 @@ public class MonsterContral : MonoBehaviour
{
moveTime += Time.deltaTime;
Vector2 v2 = monsterData.moveLine.GetBezierPointJob(moveTime);
Vector2 v2 = monsterData.moveLine.GetBezierPoint(moveTime);
if ((FishTypeEnum)monsterData.fishTypeConfig.fishType != FishTypeEnum.Boss鱼)
{
if (forwordXYZ == "" || forwordXYZ == null)
@@ -347,3 +354,4 @@ public class MonsterContral : MonoBehaviour
}
#endregion
@@ -1,15 +1,20 @@
using System.Collections;
#region AI优化
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.ResourceManagement.AsyncOperations;
using Unity.Collections;
using Unity.Jobs;
using Unity.Burst;
public class MonsterMoveLine
{
public static Dictionary<string, BezierCurveData> dic_BezierCurveDatas=new Dictionary<string, BezierCurveData>();
public static Dictionary<string, BezierCurveData> dic_BezierCurveDatas = new Dictionary<string, BezierCurveData>();
public static List<BezierCurveData> curves = new List<BezierCurveData>();
public class BezierCurveData
{
public string name;
@@ -22,112 +27,77 @@ public class MonsterMoveLine
{
await LoadBezierTxtAsync("MoveLine");
}
/// <summary>
/// 读取曲线数据 读取单个
/// </summary>
/// <param name="path"></param>
/// <returns></returns>
public static async Task LoadSingleBezierTxtAsync(string path)
{
AsyncOperationHandle<TextAsset> handle = Addressables.LoadAssetAsync<TextAsset>(path);
await handle.Task;
var lines = handle.Result.text.Split('\n');
foreach (var line in lines)
{
if (string.IsNullOrWhiteSpace(line)) continue;
var parts = line.Split(';');
BezierCurveData curve = new BezierCurveData();
// 第一个是曲线名
curve.name = parts[0];
// 后面所有都是点
List<Vector2> points = new List<Vector2>();
for (int i = 1; i < parts.Length; i++)
{
points.Add(ParseVector(parts[i]));
}
// 第一个点是 start
curve.start = points[0];
if (points.Count > 1)
{
// 最后一个点是 end
curve.end = points[points.Count - 1];
}
// 中间的都是 controlPoints
for (int i = 1; i < points.Count - 1; i++)
{
curve.controlPoints.Add(points[i]);
}
curves.Add(curve);
dic_BezierCurveDatas.Add(curve.name, curve);
}
}
/// <summary>
/// 读取曲线数据 游戏开始时在awake调用aa包
/// </summary>
/// <param name="path"></param>
/// <returns></returns>
public static async Task LoadBezierTxtAsync(string path)
{
List<string> keys=new List<string>();
List<string> keys = new List<string>();
keys.Add(path);
keys.Add(GameManager.Instance.gameData.currGameType.ToString());
AsyncOperationHandle<IList<TextAsset>> handles = Addressables.LoadAssetsAsync<TextAsset>(keys, null,Addressables.MergeMode.Intersection);
AsyncOperationHandle<IList<TextAsset>> handles = Addressables.LoadAssetsAsync<TextAsset>(keys, null, Addressables.MergeMode.Intersection);
await handles.Task;
foreach (var text in handles.Result)
{
var lines = text.text.Split('\n');
var lines = text.text.Split('\n');
foreach (var line in lines)
{
if (string.IsNullOrWhiteSpace(line)) continue;
var parts = line.Split(';');
BezierCurveData curve = new BezierCurveData();
// 第一个是曲线名
curve.name = parts[0];
// 后面所有都是点
List<Vector2> points = new List<Vector2>();
for (int i = 1; i < parts.Length; i++)
{
points.Add(ParseVector(parts[i]));
}
// 第一个点是 start
curve.start = points[0];
if (points.Count > 1)
{
// 最后一个点是 end
curve.end = points[points.Count - 1];
}
// 中间的都是 controlPoints
for (int i = 1; i < points.Count - 1; i++)
{
curve.controlPoints.Add(points[i]);
}
curves.Add(curve);
dic_BezierCurveDatas.Add(curve.name, curve);
}
}
Debug.Log("曲线读取完成共" + dic_BezierCurveDatas.Count + "条");
Debug.Log("曲线读取完成共" + dic_BezierCurveDatas.Count + "条");
}
private static Vector2 ParseVector(string s)
@@ -136,7 +106,6 @@ public class MonsterMoveLine
return new Vector2(float.Parse(xy[0]), float.Parse(xy[1]));
}
public BezierCurveData bezierCurveData;
public float moveTime;
public float moveSpeed;
@@ -147,86 +116,303 @@ public class MonsterMoveLine
this.moveTime = Time;
Debug.Log($"初始化曲线 {this.bezierCurveData.name} ,移动时间 {moveTime}");
}
/// <summary>
/// 获取曲线上的点
/// 使用 Job 计算 B样条点
/// </summary>
/// <param name="t"></param>
/// <returns></returns>
public Vector2 GetBezierPoint(float t)
public Vector2 GetBezierPointJob(float t)
{
t = t / moveTime;
BezierCurveData curve=bezierCurveData;
List<Vector2> points = new List<Vector2>();
points.Add(curve.start);
points.AddRange(curve.controlPoints);
points.Add(curve.end);
List<Vector2> pts = new List<Vector2>();
pts.Add(bezierCurveData.start);
pts.AddRange(bezierCurveData.controlPoints);
pts.Add(bezierCurveData.end);
return DeCasteljau_BY(points, t%1);
}
/// <summary>
/// 贝塞尔
/// </summary>
/// <param name="points"></param>
/// <param name="t"></param>
/// <returns></returns>
private Vector2 DeCasteljau_BSE(List<Vector2> points, float t)
{
while (points.Count > 1)
var controlPoints = new NativeArray<Vector2>(pts.ToArray(), Allocator.TempJob);
var result = new NativeArray<Vector2>(1, Allocator.TempJob);
var job = new BSplineJob
{
List<Vector2> next = new List<Vector2>();
for (int i = 0; i < points.Count - 1; i++)
controlPoints = controlPoints,
t = t % 1,
result = result
};
JobHandle handle = job.Schedule();
handle.Complete();
Vector2 worldPos = CoordinateTransformation.CanvasToWorld(result[0],
UIManager.Instance.uiRoot.GetComponent<RectTransform>(), Camera.main);
controlPoints.Dispose();
result.Dispose();
return worldPos;
}
// Job 结构体
[BurstCompile]
public struct BSplineJob : IJob
{
[ReadOnly] public NativeArray<Vector2> controlPoints;
public float t;
public NativeArray<Vector2> result;
public void Execute()
{
var temp = new NativeArray<Vector2>(controlPoints.Length, Allocator.Temp);
controlPoints.CopyTo(temp);
int count = temp.Length;
while (count > 1)
{
next.Add(Vector2.Lerp(points[i], points[i + 1], t));
for (int i = 0; i < count - 1; i++)
{
temp[i] = Vector2.Lerp(temp[i], temp[i + 1], t);
}
count--;
}
points = next;
result[0] = temp[0];
temp.Dispose();
}
return CoordinateTransformation.CanvasToWorld( points[0],UIManager.Instance.uiRoot.GetComponent<RectTransform>(),Camera.main);
}
/// <summary>
/// B样
/// </summary>
/// <param name="points"></param>
/// <param name="t"></param>
/// <returns></returns>
private Vector2 DeCasteljau_BY(List<Vector2> points, float t)
{
// 方法A:保持德卡斯特里奥算法(推荐,数值更稳定)
while (points.Count > 1)
{
List<Vector2> next = new List<Vector2>();
for (int i = 0; i < points.Count - 1; i++)
{
next.Add(Vector2.Lerp(points[i], points[i + 1], t));
}
points = next;
}
return CoordinateTransformation.CanvasToWorld(points[0],
UIManager.Instance.uiRoot.GetComponent<RectTransform>(), Camera.main);
/* 方法B:伯恩斯坦多项式形式(标准贝塞尔公式)- 如果要用这个替换上面的循环
int n = points.Count - 1;
Vector2 result = Vector2.zero;
for (int i = 0; i <= n; i++)
{
float bernstein = BinomialCoefficient(n, i) * Mathf.Pow(t, i) * Mathf.Pow(1 - t, n - i);
result += points[i] * bernstein;
}
return CoordinateTransformation.CanvasToWorld(result,
UIManager.Instance.uiRoot.GetComponent<RectTransform>(), Camera.main);
*/
}
// 计算二项式系数
private float BinomialCoefficient(int n, int k)
{
float result = 1f;
for (int i = 1; i <= k; i++)
{
result *= (float)(n - k + i) / i;
}
return result;
}
}
#endregion
#region zijixie
//using System.Collections;
//using System.Collections.Generic;
//using System.IO;
//using System.Threading.Tasks;
//using UnityEngine;
//using UnityEngine.AddressableAssets;
//using UnityEngine.ResourceManagement.AsyncOperations;
//public class MonsterMoveLine
//{
// public static Dictionary<string, BezierCurveData> dic_BezierCurveDatas = new Dictionary<string, BezierCurveData>();
// public static List<BezierCurveData> curves = new List<BezierCurveData>();
// public class BezierCurveData
// {
// public string name;
// public Vector2 start;
// public List<Vector2> controlPoints = new List<Vector2>();
// public Vector2 end;
// }
// public static async void LoadBezier()
// {
// await LoadBezierTxtAsync("MoveLine");
// }
// /// <summary>
// /// 读取曲线数据 读取单个
// /// </summary>
// /// <param name="path"></param>
// /// <returns></returns>
// public static async Task LoadSingleBezierTxtAsync(string path)
// {
// AsyncOperationHandle<TextAsset> handle = Addressables.LoadAssetAsync<TextAsset>(path);
// await handle.Task;
// var lines = handle.Result.text.Split('\n');
// foreach (var line in lines)
// {
// if (string.IsNullOrWhiteSpace(line)) continue;
// var parts = line.Split(';');
// BezierCurveData curve = new BezierCurveData();
// // 第一个是曲线名
// curve.name = parts[0];
// // 后面所有都是点
// List<Vector2> points = new List<Vector2>();
// for (int i = 1; i < parts.Length; i++)
// {
// points.Add(ParseVector(parts[i]));
// }
// // 第一个点是 start
// curve.start = points[0];
// if (points.Count > 1)
// {
// // 最后一个点是 end
// curve.end = points[points.Count - 1];
// }
// // 中间的都是 controlPoints
// for (int i = 1; i < points.Count - 1; i++)
// {
// curve.controlPoints.Add(points[i]);
// }
// curves.Add(curve);
// dic_BezierCurveDatas.Add(curve.name, curve);
// }
// }
// /// <summary>
// /// 读取曲线数据 游戏开始时在awake调用aa包
// /// </summary>
// /// <param name="path"></param>
// /// <returns></returns>
// public static async Task LoadBezierTxtAsync(string path)
// {
// List<string> keys = new List<string>();
// keys.Add(path);
// keys.Add(GameManager.Instance.gameData.currGameType.ToString());
// AsyncOperationHandle<IList<TextAsset>> handles = Addressables.LoadAssetsAsync<TextAsset>(keys, null, Addressables.MergeMode.Intersection);
// await handles.Task;
// foreach (var text in handles.Result)
// {
// var lines = text.text.Split('\n');
// foreach (var line in lines)
// {
// if (string.IsNullOrWhiteSpace(line)) continue;
// var parts = line.Split(';');
// BezierCurveData curve = new BezierCurveData();
// // 第一个是曲线名
// curve.name = parts[0];
// // 后面所有都是点
// List<Vector2> points = new List<Vector2>();
// for (int i = 1; i < parts.Length; i++)
// {
// points.Add(ParseVector(parts[i]));
// }
// // 第一个点是 start
// curve.start = points[0];
// if (points.Count > 1)
// {
// // 最后一个点是 end
// curve.end = points[points.Count - 1];
// }
// // 中间的都是 controlPoints
// for (int i = 1; i < points.Count - 1; i++)
// {
// curve.controlPoints.Add(points[i]);
// }
// curves.Add(curve);
// dic_BezierCurveDatas.Add(curve.name, curve);
// }
// }
// Debug.Log("曲线读取完成共" + dic_BezierCurveDatas.Count + "条");
// }
// private static Vector2 ParseVector(string s)
// {
// var xy = s.Split(',');
// return new Vector2(float.Parse(xy[0]), float.Parse(xy[1]));
// }
// public BezierCurveData bezierCurveData;
// public float moveTime;
// public float moveSpeed;
// public void Init(BezierCurveData bezierCurveData, float Time)
// {
// this.bezierCurveData = bezierCurveData;
// this.moveTime = time;
// Debug.Log($"初始化曲线 {this.bezierCurveData.name} ,移动时间 {moveTime}");
// }
// /// <summary>
// /// 获取曲线上的点
// /// </summary>
// /// <param name="t"></param>
// /// <returns></returns>
// public Vector2 GetBezierPoint(float t)
// {
// t = t / moveTime;
// BezierCurveData curve = bezierCurveData;
// List<Vector2> points = new List<Vector2>();
// points.Add(curve.start);
// points.AddRange(curve.controlPoints);
// points.Add(curve.end);
// return DeCasteljau_BY(points, t % 1);
// }
// /// <summary>
// /// 贝塞尔
// /// </summary>
// /// <param name="points"></param>
// /// <param name="t"></param>
// /// <returns></returns>
// private Vector2 DeCasteljau_BSE(List<Vector2> points, float t)
// {
// while (points.Count > 1)
// {
// List<Vector2> next = new List<Vector2>();
// for (int i = 0; i < points.Count - 1; i++)
// {
// next.Add(Vector2.Lerp(points[i], points[i + 1], t));
// }
// points = next;
// }
// return CoordinateTransformation.CanvasToWorld(points[0], UIManager.Instance.uiRoot.GetComponent<RectTransform>(), Camera.main);
// }
// /// <summary>
// /// B样
// /// </summary>
// /// <param name="points"></param>
// /// <param name="t"></param>
// /// <returns></returns>
// private Vector2 DeCasteljau_BY(List<Vector2> points, float t)
// {
// // 方法A:保持德卡斯特里奥算法(推荐,数值更稳定)
// while (points.Count > 1)
// {
// List<Vector2> next = new List<Vector2>();
// for (int i = 0; i < points.Count - 1; i++)
// {
// next.Add(Vector2.Lerp(points[i], points[i + 1], t));
// }
// points = next;
// }
// return CoordinateTransformation.CanvasToWorld(points[0],
// UIManager.Instance.uiRoot.GetComponent<RectTransform>(), Camera.main);
// /* 方法B:伯恩斯坦多项式形式(标准贝塞尔公式)- 如果要用这个替换上面的循环
// int n = points.Count - 1;
// Vector2 result = Vector2.zero;
// for (int i = 0; i <= n; i++)
// {
// float bernstein = BinomialCoefficient(n, i) * Mathf.Pow(t, i) * Mathf.Pow(1 - t, n - i);
// result += points[i] * bernstein;
// }
// return CoordinateTransformation.CanvasToWorld(result,
// UIManager.Instance.uiRoot.GetComponent<RectTransform>(), Camera.main);
// */
// }
// // 计算二项式系数
// private float BinomialCoefficient(int n, int k)
// {
// float result = 1f;
// for (int i = 1; i <= k; i++)
// {
// result *= (float)(n - k + i) / i;
// }
// return result;
// }
//}
#endregion