You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
816 B

  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class BlockInput : MonoBehaviour
  5. {
  6. public Character character;
  7. public BlockReader blockReader;
  8. public float waitTime;
  9. public void Update()
  10. {
  11. if (Input.GetKeyDown(KeyCode.LeftShift) && Input.GetKeyDown(KeyCode.Space))
  12. ReadNext();
  13. else if (Input.GetKeyDown(KeyCode.Space))
  14. StartCoroutine(ReadRoutine(waitTime));
  15. }
  16. [ContextMenu("Read Next")]
  17. public void ReadNext()
  18. {
  19. blockReader.Read(character);
  20. }
  21. public IEnumerator ReadRoutine(float waitTime)
  22. {
  23. while (!blockReader.Finished)
  24. {
  25. ReadNext();
  26. yield return new WaitForSeconds(waitTime);
  27. }
  28. blockReader.Reset();
  29. }
  30. }