CombatController.cs 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. using Common.Utility.CombatEvent;
  2. using Core.State;
  3. using Fort23.Core;
  4. using GameLogic.Combat.CombatState;
  5. using GameLogic.Combat.CombatType;
  6. using GameLogic.Combat.Hero.HeroGPU;
  7. using GameLogic.CombatScenesTool;
  8. using UnityEngine;
  9. using UTool.CustomizeTimeLogic.FxLogic.TimeLineEventinterface;
  10. namespace GameLogic.Combat.CombatTool
  11. {
  12. public class CombatController
  13. {
  14. public static CombatController currActiveCombat;
  15. public CombatHeroController CombatHeroController;
  16. public CombatCameraControllder CombatCameraControllder;
  17. public CombatTypeBasic CombatTypeBasic;
  18. protected StateControl stateControl;
  19. private AssetHandle scenesHandle;
  20. public GameObject gameObject;
  21. public GameTimeLineParticleFactory GameTimeLineParticleFactory;
  22. public bool isUpdate;
  23. public CombatStateBasic CurrState
  24. {
  25. get { return stateControl.CurrIState as CombatStateBasic; }
  26. }
  27. public async CTask InitCombat()
  28. {
  29. GameTimeLineParticleFactory = new GameTimeLineParticleFactory();
  30. TimeLineFxParticleTool.Instance.Init(GameTimeLineParticleFactory);
  31. currActiveCombat = this;
  32. stateControl = new StateControl();
  33. stateControl.AddState("idle", new CombatIdleState(this));
  34. stateControl.AddState("update", new CombatUpdateState(this));
  35. scenesHandle =
  36. await AssetBundleLoadManager.Instance.LoadAssetAsyncTask<GameObject>("Chapter01.prefab");
  37. gameObject = scenesHandle.AssetObject<GameObject>();
  38. gameObject.SetActive(true);
  39. Camera camera = Camera.main;
  40. CombatCameraControllder = new CombatCameraControllder();
  41. CombatCameraControllder.Init(this, camera);
  42. CombatHeroController = new CombatHeroController();
  43. CombatHeroController.Init(this);
  44. CombatTypeBasic = new TestCombatType();
  45. CombatTypeBasic.Init(this);
  46. await CombatTypeBasic.StartGame();
  47. ChangeState("update");
  48. isUpdate = true;
  49. }
  50. public void ChangeState(string name)
  51. {
  52. stateControl.ChangeState(name);
  53. }
  54. public void Update(float t)
  55. {
  56. if (!isUpdate)
  57. {
  58. return;
  59. }
  60. stateControl.Update(t);
  61. CombatTypeBasic?.Update(t);
  62. }
  63. }
  64. }