CombatSenceController.cs 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. using System;
  2. using System.Collections.Generic;
  3. using Common.Utility.CombatEvent;
  4. using Core.Utility;
  5. using Excel2Json;
  6. using Fort23.Core;
  7. using Fort23.UTool;
  8. using GameLogic.Combat.CombatTool.SceneTool;
  9. using GameLogic.CombatScenesTool;
  10. using UnityEngine;
  11. using Random = UnityEngine.Random;
  12. namespace GameLogic.Combat.CombatTool
  13. {
  14. public class CombatSenceController : IDisposable
  15. {
  16. private static readonly int Ran = Shader.PropertyToID("_ran");
  17. private static readonly int Pos = Shader.PropertyToID("_pos");
  18. // public CombatSencePath currBesselPath;
  19. //
  20. // public CombatSencePath NextBesselPath;
  21. private float moveTime;
  22. private Vector3 lasetPos;
  23. private float maxD = 100;
  24. private Vector3 lasetDir;
  25. public float currTime;
  26. public Transform moveRoot;
  27. // private List<CombatSencePath> reclaimSence = new List<CombatSencePath>();
  28. // protected GameObjectPool ShengShiQiuTi;
  29. private float shengShiStartSize = 3;
  30. private float shengShiEndSize = 300;
  31. // private float _shengShiAddTime;
  32. private bool _isUpdateShengShi;
  33. private SceneMonoConfigBasic SceneMonoConfig;
  34. // private RandomAllMap RandomAllMap;
  35. private float shengShiRan;
  36. // private List
  37. public async CTask InitScenes(string sceneName)
  38. {
  39. if (SceneMonoConfig != null)
  40. {
  41. SceneMonoConfig.Dispose();
  42. GameObject.Destroy(moveRoot.gameObject);
  43. GameObject.Destroy(SceneMonoConfig.gameObject);
  44. SceneMonoConfig = null;
  45. }
  46. shengShiRan = 0;
  47. _isUpdateShengShi = false;
  48. GameObject gameObject = new GameObject("mvoeRoot");
  49. if (string.IsNullOrEmpty(sceneName))
  50. {
  51. sceneName= "LevelBattle03";
  52. }
  53. // string sceneName = "LevelBattle03";
  54. // LevelbattleConfig levelbattleConfig = ConfigComponent.Instance.Get<LevelbattleConfig>(levelBattleId);
  55. // if (levelbattleConfig.ID > 0)
  56. // {
  57. // //sceneName= levelbattleConfig.sceneName;
  58. // }
  59. #if UNITY_EDITOR
  60. TestCombatHeroConfig testCombatHeroConfig = GameObject.FindObjectOfType<TestCombatHeroConfig>();
  61. if (testCombatHeroConfig != null)
  62. {
  63. if (!string.IsNullOrEmpty(testCombatHeroConfig.testSenceName))
  64. {
  65. sceneName = testCombatHeroConfig.testSenceName;
  66. }
  67. }
  68. #endif
  69. moveRoot = gameObject.transform;
  70. CTaskAwaitBuffer cTaskAwaitBuffer = new CTaskAwaitBuffer();
  71. var task_a = AssetBundleLoadManager.Instance.LoadAssetAsyncTask<GameObject>(sceneName + ".prefab",
  72. delegate(AssetHandle assetHandle)
  73. {
  74. GameObject gameObject = assetHandle.AssetObject<GameObject>();
  75. SceneMonoConfig = gameObject.GetComponent<SceneMonoConfigBasic>();
  76. SceneMonoConfig.shengShiMaterial.SetFloat(Ran, 0.1f);
  77. });
  78. cTaskAwaitBuffer.AddTask(task_a);
  79. lasetDir = Vector3.forward;
  80. lasetPos = new Vector3(0, 20, 0);
  81. await cTaskAwaitBuffer.WaitAll();
  82. // currBesselPath = InitBesselPath(lasetPos);
  83. SceneMonoConfig.Init(Camera.main.transform.parent, moveRoot);
  84. SceneMonoConfig.UpdateScene();
  85. }
  86. private async CTask<SceneDecoration> GetSceneDecoration(SceneObjectConfig sceneObjectConfig)
  87. {
  88. GameObjectPool gameObjectPool = await sceneObjectConfig.GetNewPrefab();
  89. SceneDecoration sceneDecoration = CObjectPool.Instance.Fetch<SceneDecoration>();
  90. sceneDecoration.Init(gameObjectPool);
  91. GameObject g = gameObjectPool.own;
  92. g.SetActive(true);
  93. return sceneDecoration;
  94. }
  95. public void StartPayShengShi(Transform root)
  96. {
  97. shengShiRan = 1;
  98. SceneMonoConfig.shengShiMaterial.SetFloat(Ran, shengShiRan);
  99. Vector3 pos = CombatController.currActiveCombat.playerHeroEntity.dotPos - CombatController.currActiveCombat
  100. .CombatCameraControllder.Camera.transform.position;
  101. pos.z = -30;
  102. SceneMonoConfig.shengShiMaterial.SetVector(Pos, pos);
  103. _isUpdateShengShi = true;
  104. // _shengShiAddTime = 0;
  105. }
  106. public void Update(float t)
  107. {
  108. moveRoot.transform.position = CombatController.currActiveCombat.CombatHeroController.GetTarget(0);
  109. SceneMonoConfig?.UpdateScene();
  110. if (_isUpdateShengShi)
  111. {
  112. // _shengShiAddTime += t * 1f;
  113. shengShiRan += t * 150;
  114. SceneMonoConfig.shengShiMaterial.SetFloat(Ran, shengShiRan);
  115. // float v = Mathf.Lerp(shengShiStartSize, shengShiEndSize, _shengShiAddTime);
  116. // ShengShiQiuTi.own.transform.localScale = Vector3.one * v;
  117. if (shengShiRan >= 200)
  118. {
  119. SceneMonoConfig.shengShiMaterial.SetFloat(Ran, 0.1f);
  120. _isUpdateShengShi = false;
  121. }
  122. }
  123. }
  124. public void Dispose()
  125. {
  126. // GObjectPool.Instance.
  127. }
  128. }
  129. }