GroundHeightStep.cs 860 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class GroundHeightStep : AbstractSafetyAreaStep
  5. {
  6. private float planeHeight;
  7. public GroundHeightStep()
  8. {
  9. ResetPlaneHeight();
  10. }
  11. public void SetHeadPosition(Vector3 headPosition)
  12. {
  13. float largestHeight = headPosition.y - PlayAreaConstant.DEFAULT_HEIGHT_FROM_HEAD;
  14. if (largestHeight < planeHeight)
  15. {
  16. planeHeight = largestHeight;
  17. }
  18. }
  19. public void SetPlaneHeight(float interactionObjectHeight)
  20. {
  21. if (interactionObjectHeight < planeHeight)
  22. {
  23. planeHeight = interactionObjectHeight;
  24. }
  25. }
  26. public float GetPlaneHeight()
  27. {
  28. return planeHeight;
  29. }
  30. public void ResetPlaneHeight()
  31. {
  32. planeHeight = float.MaxValue;
  33. }
  34. }