|
@@ -1,76 +1,183 @@
|
|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
+using Core.Utility;
|
|
|
using Fort23.Core;
|
|
|
using GameLogic.CombatScenesTool;
|
|
|
-
|
|
|
using UnityEngine;
|
|
|
+using Random = UnityEngine.Random;
|
|
|
|
|
|
namespace GameLogic.Combat.CombatTool
|
|
|
{
|
|
|
- public class CombatSenceController: IDisposable
|
|
|
+ public class CombatSenceController : IDisposable
|
|
|
{
|
|
|
private AssetHandle scenesHandle;
|
|
|
- private AssetHandle scenesHandle2;
|
|
|
- private AssetHandle scenesHandle3;
|
|
|
+
|
|
|
public GameObject scenes1;
|
|
|
-
|
|
|
|
|
|
- private float zoff;
|
|
|
|
|
|
- private int index = 0;
|
|
|
- private List<CombatScenesConfig> _allCombatScenesConfigs = new List<CombatScenesConfig>();
|
|
|
+ public CombatSencePath currBesselPath;
|
|
|
+
|
|
|
+ public CombatSencePath NextBesselPath;
|
|
|
|
|
|
- public CombatScenesConfig _currConfig;
|
|
|
+ private float moveTime;
|
|
|
+ private Vector3 lasetPos;
|
|
|
+ private float maxD = 100;
|
|
|
+ private Vector3 lasetDir;
|
|
|
|
|
|
- private int nextConfigIndex;
|
|
|
+ public float currTime;
|
|
|
+ public Transform moveRoot;
|
|
|
|
|
|
public async CTask InitScenes()
|
|
|
{
|
|
|
+ GameObject gameObject = new GameObject("mvoeRoot");
|
|
|
+
|
|
|
+ moveRoot = gameObject.transform;
|
|
|
CTaskAwaitBuffer cTaskAwaitBuffer = new CTaskAwaitBuffer();
|
|
|
- cTaskAwaitBuffer.AddTask(AssetBundleLoadManager.Instance.LoadAssetAsyncTask<GameObject>("LevelBattle1.prefab",
|
|
|
+ cTaskAwaitBuffer.AddTask(AssetBundleLoadManager.Instance.LoadAssetAsyncTask<GameObject>(
|
|
|
+ "shan1.prefab",
|
|
|
delegate(AssetHandle handle)
|
|
|
{
|
|
|
scenesHandle = handle;
|
|
|
scenes1 = scenesHandle.AssetObject<GameObject>();
|
|
|
- scenes1.SetActive(true);
|
|
|
- CombatScenesConfig combatScenesConfig = scenes1.GetComponent<CombatScenesConfig>();
|
|
|
- _allCombatScenesConfigs.Add(combatScenesConfig);
|
|
|
+ scenes1.SetActive(false);
|
|
|
}));
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+ lasetDir = Vector3.forward;
|
|
|
+
|
|
|
await cTaskAwaitBuffer.WaitAll();
|
|
|
- MoveToNextConfig();
|
|
|
+ currBesselPath = InitBesselPath(lasetPos);
|
|
|
}
|
|
|
|
|
|
|
|
|
- public CombatScenesConfig MoveToNextConfig()
|
|
|
+ private CombatSencePath InitBesselPath(Vector3 satrtPos)
|
|
|
+ {
|
|
|
+ CombatSencePath besselPath = new CombatSencePath();
|
|
|
+
|
|
|
+ Vector3 target = satrtPos + lasetDir.normalized * maxD;
|
|
|
+ // if (offx == 0)
|
|
|
+ {
|
|
|
+ besselPath.SetPos(satrtPos, target);
|
|
|
+ }
|
|
|
+ Vector3 p = besselPath.GetValue(0.99f);
|
|
|
+ lasetDir = (target - p).normalized;
|
|
|
+ GameObject gameObject = new GameObject("path");
|
|
|
+ gameObject.transform.position = satrtPos;
|
|
|
+ CombatPathMono combatPathMono = gameObject.AddComponent<CombatPathMono>();
|
|
|
+ combatPathMono.BesselPath = besselPath;
|
|
|
+ InitZhuangSHi(besselPath);
|
|
|
+ return besselPath;
|
|
|
+ }
|
|
|
+
|
|
|
+ private CombatSencePath InitBesselPath(Vector3 satrtPos, float offx)
|
|
|
{
|
|
|
- nextConfigIndex++;
|
|
|
- nextConfigIndex %= _allCombatScenesConfigs.Count;
|
|
|
- return _currConfig=_allCombatScenesConfigs[nextConfigIndex];
|
|
|
+ CombatSencePath besselPath = new CombatSencePath();
|
|
|
+ Vector3 dir = Quaternion.LookRotation(lasetDir) * new Vector3(offx, 0, 1);
|
|
|
+ Vector3 target = satrtPos + dir.normalized * maxD;
|
|
|
+ Vector3 dir2 = Quaternion.LookRotation(lasetDir) * new Vector3(offx*-1, 0, 1);
|
|
|
+ Vector3 centre = satrtPos + dir2.normalized * maxD;
|
|
|
+ // if (offx == 0)
|
|
|
+ {
|
|
|
+ besselPath.SetPos(satrtPos, centre, target);
|
|
|
+ }
|
|
|
+ Vector3 p = besselPath.GetValue(0.99f);
|
|
|
+ lasetDir = (target - p).normalized;
|
|
|
+ GameObject gameObject = new GameObject("path");
|
|
|
+ gameObject.transform.position = satrtPos;
|
|
|
+ CombatPathMono combatPathMono = gameObject.AddComponent<CombatPathMono>();
|
|
|
+ combatPathMono.BesselPath = besselPath;
|
|
|
+ InitZhuangSHi(besselPath);
|
|
|
+ return besselPath;
|
|
|
}
|
|
|
|
|
|
- public void NextScenesShow()
|
|
|
+ private void InitZhuangSHi(CombatSencePath besselPath)
|
|
|
{
|
|
|
- index++;
|
|
|
- index %= _allCombatScenesConfigs.Count;
|
|
|
- zoff -= 97;
|
|
|
- _allCombatScenesConfigs[index].transform.position = new Vector3(0, 0, zoff);
|
|
|
+ int count = Random.Range(30, 40);
|
|
|
+ for (int i = 0; i < count; i++)
|
|
|
+ {
|
|
|
+ float md = Random.Range(0.1f, 0.9f);
|
|
|
+ Vector3 p = besselPath.GetValue(md);
|
|
|
+ Vector3 p2 = besselPath.GetValue(md - 0.01f);
|
|
|
+ Vector3 dir = (p - p2);
|
|
|
+ Vector3 cross = Vector3.Cross(dir, Vector3.up);
|
|
|
+ cross = cross.normalized;
|
|
|
+ int odds = Random.Range(0, 100);
|
|
|
+ p += cross * Random.Range(8, 25) * (odds < 50 ? 1 : -1);
|
|
|
+ GameObject g = GameObject.Instantiate(scenes1);
|
|
|
+ g.SetActive(true);
|
|
|
+ g.transform.position = p + new Vector3(0, Random.Range(-7, -4), 0);
|
|
|
+ g.transform.eulerAngles = new Vector3(-90, 0, Random.Range(0, 360));
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+ public Vector3 GetTarget(float time)
|
|
|
+ {
|
|
|
+ if (time > 1)
|
|
|
+ {
|
|
|
+ if (NextBesselPath == null)
|
|
|
+ {
|
|
|
+ NextBesselPath = InitBesselPath(currBesselPath.b, 0);
|
|
|
+ }
|
|
|
+
|
|
|
+ time = time % 1;
|
|
|
+ return NextBesselPath.GetValue(time);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ return currBesselPath.GetValue(time);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public Vector3 Move(float speedTime)
|
|
|
+ {
|
|
|
+ currTime += speedTime;
|
|
|
+ Vector3 targetPos = Vector3.zero;
|
|
|
+ if (currTime > 0.2f)
|
|
|
+ {
|
|
|
+ if (NextBesselPath == null)
|
|
|
+ {
|
|
|
+ int odds = Random.Range(0, 100);
|
|
|
+ if (odds < 50)
|
|
|
+ {
|
|
|
+ NextBesselPath = InitBesselPath(currBesselPath.b, -1);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ NextBesselPath = InitBesselPath(currBesselPath.b);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (currTime > 1)
|
|
|
+ {
|
|
|
+ if (NextBesselPath == null)
|
|
|
+ {
|
|
|
+ NextBesselPath = InitBesselPath(currBesselPath.b, -1);
|
|
|
+ }
|
|
|
+
|
|
|
+ currTime = currTime % 1;
|
|
|
+ targetPos = NextBesselPath.GetValue(currTime);
|
|
|
+ currBesselPath = NextBesselPath;
|
|
|
+ NextBesselPath = null;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ targetPos = currBesselPath.GetValue(currTime);
|
|
|
+ }
|
|
|
+ moveRoot.transform.position = targetPos;
|
|
|
+ return targetPos;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void Update(float t)
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
public void Dispose()
|
|
|
{
|
|
|
if (scenesHandle != null)
|
|
|
{
|
|
|
scenesHandle.Release();
|
|
|
}
|
|
|
- if (scenesHandle2 != null)
|
|
|
- {
|
|
|
- scenesHandle2.Release();
|
|
|
- }
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
}
|