123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235 |
- 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<CombatSencePath> reclaimSence = new List<CombatSencePath>();
- // 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<LevelbattleConfig>(levelBattleId);
- if (levelbattleConfig.ID > 0)
- {
- //sceneName= levelbattleConfig.sceneName;
- }
- #if UNITY_EDITOR
- TestCombatHeroConfig testCombatHeroConfig = GameObject.FindObjectOfType<TestCombatHeroConfig>();
- 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<GameObject>(sceneName + ".prefab",
- delegate(AssetHandle assetHandle)
- {
- GameObject gameObject = assetHandle.AssetObject<GameObject>();
- SceneMonoConfig = gameObject.GetComponent<SceneMonoConfigBasic>();
- 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<SceneDecoration> GetSceneDecoration(SceneObjectConfig sceneObjectConfig)
- {
- GameObjectPool gameObjectPool = await sceneObjectConfig.GetNewPrefab();
- SceneDecoration sceneDecoration = CObjectPool.Instance.Fetch<SceneDecoration>();
- 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.
- }
- }
- }
|