fix animation end action, fast forward work as expected
This commit is contained in:
@@ -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
|
||||
|
||||
Binary file not shown.
@@ -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:
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user