PlayAreaStep.cs 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. public class PlayAreaStep : AbstractSafetyAreaStep<SafetyAreaMono>
  7. {
  8. private PlayAreaStateMachine playAreaStateMachine;
  9. public PlayAreaStep(SafetyAreaMono safetyAreaMono) : base(safetyAreaMono)
  10. {
  11. if (playAreaStateMachine == null)
  12. {
  13. playAreaStateMachine = new PlayAreaStateMachine();
  14. playAreaStateMachine.InitStateMachine(safetyAreaMono);
  15. }
  16. }
  17. public override void OnEnterStep(object data)
  18. {
  19. //reference.safetyGreyCameraUI.gameObject.SetActive(true);
  20. ShowPlane();
  21. ClearPlaneColor();
  22. ChangePlayAreaState(PlayAreaStateEnum.WaitingDraw);
  23. }
  24. public override void OnExitStep()
  25. {
  26. if (playAreaStateMachine != null)
  27. {
  28. playAreaStateMachine.ExitCurrentState();
  29. }
  30. //reference.safetyGreyCameraUI.gameObject.SetActive(false);
  31. }
  32. public override SafetyAreaStepEnum GetStepEnum()
  33. {
  34. return SafetyAreaStepEnum.PlayArea;
  35. }
  36. //切换游戏区域步骤的状态
  37. public void ChangePlayAreaState(PlayAreaStateEnum playAreaStateEnum, object data = null)
  38. {
  39. if (playAreaStateMachine != null)
  40. {
  41. playAreaStateMachine.ChangeState(playAreaStateEnum, data);
  42. }
  43. }
  44. //切换一次平面位置
  45. public void ChangePlanePosition()
  46. {
  47. reference.safetyPlaneMono.ContinueSetPlaneHeight();
  48. }
  49. //显示平面
  50. private void ShowPlane()
  51. {
  52. reference.safetyPlaneMono.gameObject.SetActive(true);
  53. }
  54. //清空平面颜色
  55. private void ClearPlaneColor()
  56. {
  57. reference.safetyPlaneMono.ClearAllMeshColor();
  58. }
  59. public override void OnUserCancel()
  60. {
  61. SafetyAreaManager.Instance.DestroyPlayArea();
  62. SafetyAreaManager.Instance.ExitSafeAreaStep();
  63. reference.DestroySafetyPlane();
  64. }
  65. }