using System; using System.Collections.Generic; using Common.Utility.CombatEvent; using Core.Utility; using Excel2Json; using Fort23.Core; using Fort23.UTool; using GameLogic.Combat.CombatTool.SceneTool; using GameLogic.CombatScenesTool; using UnityEngine; using Random = UnityEngine.Random; namespace GameLogic.Combat.CombatTool { public class CombatSenceController : IDisposable { private static readonly int Ran = Shader.PropertyToID("_ran"); private static readonly int Pos = Shader.PropertyToID("_pos"); // public CombatSencePath currBesselPath; // // public CombatSencePath NextBesselPath; private float moveTime; private Vector3 lasetPos; private float maxD = 100; private Vector3 lasetDir; public float currTime; public Transform moveRoot; private List reclaimSence = new List(); // protected GameObjectPool ShengShiQiuTi; private float shengShiStartSize = 3; private float shengShiEndSize = 300; // private float _shengShiAddTime; private bool _isUpdateShengShi; private SceneMonoConfigBasic SceneMonoConfig; // private RandomAllMap RandomAllMap; private float shengShiRan; // private List public async CTask InitScenes(int levelBattleId) { GameObject gameObject = new GameObject("mvoeRoot"); string sceneName = "LevelBattle03"; LevelbattleConfig levelbattleConfig = ConfigComponent.Instance.Get(levelBattleId); if (levelbattleConfig.ID > 0) { //sceneName= levelbattleConfig.sceneName; } #if UNITY_EDITOR TestCombatHeroConfig testCombatHeroConfig = GameObject.FindObjectOfType(); if (testCombatHeroConfig != null) { if (!string.IsNullOrEmpty(testCombatHeroConfig.testSenceName)) { sceneName = testCombatHeroConfig.testSenceName; } } #endif moveRoot = gameObject.transform; CTaskAwaitBuffer cTaskAwaitBuffer = new CTaskAwaitBuffer(); var task_a = AssetBundleLoadManager.Instance.LoadAssetAsyncTask(sceneName + ".prefab", delegate(AssetHandle assetHandle) { GameObject gameObject = assetHandle.AssetObject(); SceneMonoConfig = gameObject.GetComponent(); SceneMonoConfig.shengShiMaterial.SetFloat(Ran, 0.1f); }); cTaskAwaitBuffer.AddTask(task_a); lasetDir = Vector3.forward; lasetPos = new Vector3(0, 20, 0); await cTaskAwaitBuffer.WaitAll(); // currBesselPath = InitBesselPath(lasetPos); SceneMonoConfig.Init(Camera.main.transform.parent, moveRoot); } private async CTask GetSceneDecoration(SceneObjectConfig sceneObjectConfig) { GameObjectPool gameObjectPool = await sceneObjectConfig.GetNewPrefab(); SceneDecoration sceneDecoration = CObjectPool.Instance.Fetch(); sceneDecoration.Init(gameObjectPool); GameObject g = gameObjectPool.own; g.SetActive(true); return sceneDecoration; } // 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 dis) // { // float t = dis / currBesselPath.len; // currTime += t; // // Debug.Log("移动速度" + t + "/" + currBesselPath.len); // // Vector3 targetPos = Vector3.zero; // if (currTime > 0.01f) // { // if (NextBesselPath == null) // { // // int odds = Random.Range(0, 100); // // if (odds < 50) // // { // // NextBesselPath = InitBesselPath(currBesselPath.b, Random.Range(0, 100) < 50 ? -1 : 1); // // } // // else // { // NextBesselPath = InitBesselPath(currBesselPath.b); // } // } // } // // if (currTime > 1) // { // if (NextBesselPath == null) // { // NextBesselPath = InitBesselPath(currBesselPath.b); // } // // currTime = currTime % 1; // // targetPos = NextBesselPath.GetValue(currTime); // currBesselPath.reclaimTime = 3; // reclaimSence.Add(currBesselPath); // currBesselPath = NextBesselPath; // NextBesselPath = null; // CombatEventManager.Instance.Dispatch(CombatEventType.SencenBesselPathAlter, null); // } // else // { // } // // targetPos = currBesselPath.GetValue(currTime); // moveRoot.transform.position = targetPos; // return targetPos; // } public void StartPayShengShi(Transform root) { shengShiRan = 1; SceneMonoConfig.shengShiMaterial.SetFloat(Ran, shengShiRan); Vector3 pos = CombatController.currActiveCombat.playerHeroEntity.dotPos - CombatController.currActiveCombat .CombatCameraControllder.Camera.transform.position; pos.z = -30; SceneMonoConfig.shengShiMaterial.SetVector(Pos, pos); _isUpdateShengShi = true; // _shengShiAddTime = 0; } public void Update(float t) { moveRoot.transform.position = CombatController.currActiveCombat.CombatHeroController.GetTarget(0); SceneMonoConfig?.UpdateScene(); // if (currBesselPath != null) // { // currBesselPath.Update(t); // } // // if (NextBesselPath != null) // { // NextBesselPath.Update(t); // } if (_isUpdateShengShi) { // _shengShiAddTime += t * 1f; shengShiRan += t * 150; SceneMonoConfig.shengShiMaterial.SetFloat(Ran, shengShiRan); // float v = Mathf.Lerp(shengShiStartSize, shengShiEndSize, _shengShiAddTime); // ShengShiQiuTi.own.transform.localScale = Vector3.one * v; if (shengShiRan >= 200) { SceneMonoConfig.shengShiMaterial.SetFloat(Ran, 0.1f); _isUpdateShengShi = false; } } for (int i = 0; i < reclaimSence.Count; i++) { CombatSencePath sencePath = reclaimSence[i]; sencePath.reclaimTime -= t; if (sencePath.reclaimTime < 0) { sencePath.DormancyObj(); reclaimSence.RemoveAt(i); } } } public void Dispose() { // GObjectPool.Instance. } } }