123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244 |
- 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 Utility.UITool;
- 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;
-
- public float moveSpeed = 2f;
- public bool isFlight;
- private bool _isFlightCameraFinish;
- private float _flightTime;
- private float _flightAddTime;
- private float _flightCurrTime;
- private Vector3 _flightDir;
- private Vector3 _flightStartDir;
- private float _flightStartSpeed;
- private float _flightSpeed;
- private ParticleSystemPool _flightFx1;
- private ParticleSystemPool _flightFx2;
- public Vector3 moveDir = Vector3.forward;
- // private List
- public async CTask InitScenes(string sceneName)
- {
- if (SceneMonoConfig != null)
- {
- SceneMonoConfig.Dispose();
- GameObject.Destroy(moveRoot.gameObject);
- GameObject.Destroy(SceneMonoConfig.gameObject);
- SceneMonoConfig = null;
- }
- shengShiRan = 0;
- _isUpdateShengShi = false;
- GameObject gameObject = new GameObject("mvoeRoot");
- if (string.IsNullOrEmpty(sceneName))
- {
- sceneName= "LevelBattle03";
- }
- // 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);
- SceneMonoConfig.UpdateScene();
- }
-
- public Vector3 GetTarget(float d)
- {
- if (CombatController.currActiveCombat.playerHeroEntity == null)
- {
- return new Vector3(0, 20, 0);
- }
- return CombatController.currActiveCombat.playerHeroEntity.dotPos + moveDir * d;
- }
- public async CTask Flight(float time, float jiaoDu, float speed)
- {
- _flightCurrTime = 0;
- _flightTime = time;
- _flightAddTime = 1.0f / time;
- isFlight = true;
- _isFlightCameraFinish = false;
- Quaternion quaternion = Quaternion.Euler(0, jiaoDu, 0);
- _flightDir = quaternion * moveDir;
- _flightStartDir = moveDir;
- _flightStartSpeed = moveSpeed;
- _flightSpeed = speed;
- CombatController.currActiveCombat.playerHeroEntity.PlayAnim("idle2", true, 0, false, 1);
- CombatController.currActiveCombat.CombatCameraControllder.SetFieldOfView(90, 0.5f);
- GObjectPool.Instance.Recycle(_flightFx1);
- GObjectPool.Instance.Recycle(_flightFx2);
- GObjectPool.Instance.FetchAsync<ParticleSystemPool>("fx fly qi", delegate(ParticleSystemPool pool)
- {
- _flightFx1 = pool;
- SpecialDotInfo specialDotInfo =
- CombatController.currActiveCombat.playerHeroEntity.GetSpecialDotInfo("hitpos");
- pool.own.transform.SetParent(specialDotInfo.targetTran);
- pool.own.transform.localPosition = Vector3.zero;
- });
- GObjectPool.Instance.FetchAsync<ParticleSystemPool>("fx zq jian loop", delegate(ParticleSystemPool pool)
- {
- _flightFx2 = pool;
- pool.own.transform.SetParent(CombatController.currActiveCombat.playerHeroEntity.GameObject.transform);
- pool.own.transform.localPosition = Vector3.zero;
- });
- }
-
- 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 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 = GetTarget(0);
- SceneMonoConfig?.UpdateScene();
-
- 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;
- }
- }
- if (isFlight)
- {
- _flightCurrTime += t * _flightAddTime;
- moveDir = Vector3.Lerp(_flightStartDir, _flightDir, _flightCurrTime);
- float flightSpeedCur =
- AnimationCurveManager.Instance.AnimationCurveLibrary.flightSpeedCurve.Evaluate(_flightCurrTime);
- moveSpeed = Mathf.Lerp(_flightStartSpeed, _flightSpeed, flightSpeedCur);
- if (_flightCurrTime > 0.95f&&!_isFlightCameraFinish)
- {
- _isFlightCameraFinish= true;
- CombatController.currActiveCombat.CombatCameraControllder.SetFieldOfView(70, 1);
- }
- if (_flightCurrTime >= 1)
- {
- moveDir = _flightDir;
- isFlight = false;
- moveSpeed = 2;
- GObjectPool.Instance.Recycle(_flightFx1);
- GObjectPool.Instance.Recycle(_flightFx2);
-
- CombatController.currActiveCombat.playerHeroEntity.PlayAnim("idle", true, 0, false, 1);
- }
- }
-
- }
- public void Dispose()
- {
- // GObjectPool.Instance.
- }
- }
- }
|