Newer
Older
DungeonShooting / DungeonShooting_Godot / src / framework / activity / WaitForSeconds.cs
@lijincheng lijincheng on 14 Feb 2023 436 bytes 协程完善
  1.  
  2. /// <summary>
  3. /// 用于协程返回, 表示当前协程等待指定秒数
  4. /// </summary>
  5. public class WaitForSeconds
  6. {
  7. private float _timer;
  8. private float _current = 0;
  9. public WaitForSeconds(float time)
  10. {
  11. _timer = time;
  12. }
  13.  
  14. public bool NextStep(float delta)
  15. {
  16. if (_current >= _timer)
  17. {
  18. return true;
  19. }
  20.  
  21. _current += delta;
  22. return false;
  23. }
  24. }