diff --git a/Assets/Characters/Animations/Sit To Stand.anim b/Assets/Characters/Animations/Sit To Stand.anim index f510e7b5..dbc58b6e 100644 --- a/Assets/Characters/Animations/Sit To Stand.anim +++ b/Assets/Characters/Animations/Sit To Stand.anim @@ -33901,7 +33901,7 @@ AnimationClip: m_LoopBlend: 0 m_LoopBlendOrientation: 0 m_LoopBlendPositionY: 1 - m_LoopBlendPositionXZ: 0 + m_LoopBlendPositionXZ: 1 m_KeepOriginalOrientation: 0 m_KeepOriginalPositionY: 0 m_KeepOriginalPositionXZ: 0 diff --git a/Assets/Characters/Animations/sittostandfix.fbx b/Assets/Characters/Animations/sittostandfix.fbx deleted file mode 100644 index 0ff4fec5..00000000 Binary files a/Assets/Characters/Animations/sittostandfix.fbx and /dev/null differ diff --git a/Assets/Scenes/CheapHouse.unity b/Assets/Scenes/CheapHouse.unity index 4e68764d..6c21962f 100644 --- a/Assets/Scenes/CheapHouse.unity +++ b/Assets/Scenes/CheapHouse.unity @@ -38,7 +38,7 @@ RenderSettings: m_ReflectionIntensity: 1 m_CustomReflection: {fileID: 0} m_Sun: {fileID: 0} - m_IndirectSpecularColor: {r: 0.17276844, g: 0.21589246, b: 0.2978263, a: 1} + m_IndirectSpecularColor: {r: 0.172768, g: 0.21589169, b: 0.29782546, a: 1} m_UseRadianceAmbientProbe: 0 --- !u!157 &3 LightmapSettings: diff --git a/Assets/Scenes/City.unity b/Assets/Scenes/City.unity index 4876c797..e6d9fad6 100644 --- a/Assets/Scenes/City.unity +++ b/Assets/Scenes/City.unity @@ -3387,7 +3387,7 @@ Transform: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 963194225} - m_LocalRotation: {x: 0.53717524, y: 0.00000001592945, z: -0.000000010144878, w: 0.8434707} + m_LocalRotation: {x: 0.53717524, y: 0.000000015757937, z: -0.000000010035648, w: 0.8434707} m_LocalPosition: {x: 29.11, y: 15, z: -57.39} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 @@ -3540,7 +3540,7 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 0} - m_AnchoredPosition: {x: 0, y: 0} + m_AnchoredPosition: {x: 250, y: 0} m_SizeDelta: {x: 480, y: 0} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &989266191 @@ -12170,7 +12170,7 @@ Transform: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 2110938951} - m_LocalRotation: {x: 0.53717524, y: 0.00000001592945, z: -0.000000010144878, w: 0.8434707} + m_LocalRotation: {x: 0.53717524, y: 0.000000015757937, z: -0.000000010035648, w: 0.8434707} m_LocalPosition: {x: 29.11, y: 15, z: -57.39} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 diff --git a/Assets/Scripts/InteractableObjects/Bed.cs b/Assets/Scripts/InteractableObjects/Bed.cs index 75907df4..1b3048cd 100644 --- a/Assets/Scripts/InteractableObjects/Bed.cs +++ b/Assets/Scripts/InteractableObjects/Bed.cs @@ -1,5 +1,4 @@ using System; -using System.Collections; public class Bed : BaseInteractableObject { @@ -7,18 +6,13 @@ public class Bed : BaseInteractableObject public override void Interact(Player player) { - _player=player; - StartCoroutine(Sleep()); + _player = player; + _player.SetPlayerAnimation(AnimationStates.Sitting, OnAnimationFinished); } - private IEnumerator Sleep() + private void OnAnimationFinished() { - _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() diff --git a/Assets/Scripts/Player/Player.cs b/Assets/Scripts/Player/Player.cs index 0baa668f..215b1a01 100644 --- a/Assets/Scripts/Player/Player.cs +++ b/Assets/Scripts/Player/Player.cs @@ -1,6 +1,5 @@ using Assets.Scripts.Actions.Interfaces; using System; -using System.Collections; using System.Collections.Generic; using System.Linq; using System.Reflection; @@ -33,6 +32,7 @@ public class Player : MonoBehaviour private const string WALK_VELOCITY = "WalkVelocity"; private ContainerItem _containerItem; + private Action _OnAnimationFinish; private void Awake() { @@ -64,8 +64,15 @@ public class Player : MonoBehaviour { if (IsBlockingAnimation(_currentAnimation)) { - StartCoroutine(IsAnimationStatePlaying(0)); + if (IsAnimationStatePlaying(0)) + { return; + } + else + { + _OnAnimationFinish?.Invoke(); + _OnAnimationFinish = null; + } } if (_currentTask == null || _currentTask.Status == TaskStatus.Complete) @@ -164,6 +171,11 @@ public class Player : MonoBehaviour return TaskStatus.Complete; } + public void SetPlayerAnimation(AnimationStates newState, Action onAnimationFinish) + { + _OnAnimationFinish = onAnimationFinish; + SetPlayerAnimation(newState); + } public void SetPlayerAnimation(AnimationStates newState) { if (newState == _currentAnimation) @@ -175,12 +187,12 @@ public class Player : MonoBehaviour } - public IEnumerator IsAnimationStatePlaying(int animLayer) + public bool IsAnimationStatePlaying(int animLayer) { string stateName = GetEnumMemberValue(_currentAnimation); var stateInfo = _animator.GetCurrentAnimatorStateInfo(animLayer); - yield return new WaitWhile(() => stateInfo.IsName(stateName) && stateInfo.normalizedTime < 1.0f); - yield break; + return stateInfo.IsName(stateName) && stateInfo.normalizedTime < 1.0f; + } public void AddTask(PlayerTasks task)