start dealing with corutines

This commit is contained in:
2023-03-14 06:09:21 +02:00
parent 6d26efe67c
commit 63daaaf3e5
3 changed files with 21 additions and 13 deletions
+11 -3
View File
@@ -1,5 +1,5 @@
using System;
using UnityEngine;
using System.Collections;
public class Bed : BaseInteractableObject
{
@@ -8,9 +8,17 @@ public class Bed : BaseInteractableObject
public override void Interact(Player player)
{
_player=player;
Debug.Log("Sitting");
player.SetPlayerAnimation(AnimationStates.Sitting);
StartCoroutine(Sleep());
}
private IEnumerator Sleep()
{
_player.SetPlayerAnimation(AnimationStates.Sitting);
yield return StartCoroutine(_player.IsAnimationStatePlaying(0));
print("sitting animation finished");
TimeManager.Instance.FastForward(TimeSpan.FromHours(8), OnFastForwardEnd);
yield break;
}
private void OnFastForwardEnd()