Signed-off-by: TRAfoer <lhf190@outlook.com>
This commit is contained in:
@@ -15,7 +15,7 @@ namespace Ichni.RhythmGame
|
||||
/// </summary>
|
||||
public partial class LookAt : AnimationBase
|
||||
{
|
||||
|
||||
public GameCamera gameCamera;
|
||||
public TransformSubmodule targetTransformSubmodule;
|
||||
public GameElement lookAtObject;
|
||||
public FlexibleBool enabling;
|
||||
@@ -32,10 +32,10 @@ namespace Ichni.RhythmGame
|
||||
look.lookAtObject = lookAtTarget;
|
||||
look.enabling = enabling;
|
||||
look.animationReturnType = FlexibleReturnType.Before;
|
||||
|
||||
|
||||
look.targetTransformSubmodule = (animatedObject as IHaveTransformSubmodule).transformSubmodule;
|
||||
look.targetTransformSubmodule.lookAt = look;
|
||||
|
||||
look.gameCamera = EditorManager.instance.cameraManager.gameCamera;
|
||||
return look;
|
||||
}
|
||||
|
||||
@@ -43,18 +43,33 @@ namespace Ichni.RhythmGame
|
||||
{
|
||||
timeDurationSubmodule = new TimeDurationSubmodule(this);
|
||||
}
|
||||
protected override void Update()
|
||||
{
|
||||
|
||||
}
|
||||
void LateUpdate()
|
||||
{
|
||||
UpdateAnimation(EditorManager.instance.songInformation.songTime);
|
||||
}
|
||||
protected override void UpdateAnimation(float songTime)
|
||||
{
|
||||
if (lookAtObject is null) return;
|
||||
|
||||
|
||||
enabling.UpdateFlexibleBool(songTime);
|
||||
targetTransformSubmodule.eulerAnglesOffsetLock = enabling.value;
|
||||
|
||||
|
||||
if (enabling.value)
|
||||
{
|
||||
animationReturnType = FlexibleReturnType.MiddleExecuting;
|
||||
targetTransformSubmodule.eulerAnglesDirtyMark = true;
|
||||
gameCamera.UpdateLookAt(this);
|
||||
|
||||
}
|
||||
else if (animationReturnType != FlexibleReturnType.MiddleInterval)
|
||||
{
|
||||
animationReturnType = FlexibleReturnType.MiddleInterval;
|
||||
targetTransformSubmodule.eulerAnglesOffset.Add(Vector3.zero);
|
||||
targetTransformSubmodule.eulerAnglesDirtyMark = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace Ichni.RhythmGame
|
||||
{
|
||||
public partial class GameCamera : GameElement, IHaveTransformSubmodule, IHaveTimeDurationSubmodule
|
||||
{
|
||||
[FormerlySerializedAs("camera")]
|
||||
[FormerlySerializedAs("camera")]
|
||||
public Camera gameCamera;
|
||||
public Transform rotationPoint;
|
||||
public Transform positionPoint;
|
||||
@@ -93,18 +93,24 @@ namespace Ichni.RhythmGame
|
||||
|
||||
public partial class GameCamera
|
||||
{
|
||||
private void LateUpdate() // 处理LookAt
|
||||
public void UpdateLookAt(LookAt lookAt) // 处理LookAt
|
||||
{
|
||||
if (transformSubmodule?.lookAt is not null &&
|
||||
transformSubmodule.eulerAnglesOffsetLock &&
|
||||
if (
|
||||
transformSubmodule.eulerAnglesOffsetLock &&
|
||||
transformSubmodule.eulerAnglesDirtyMark)
|
||||
{
|
||||
|
||||
Vector3 lookingDirection = (lookAt.lookAtObject.transform.position - transform.position).normalized;
|
||||
|
||||
Vector3 eulerAnglesOffse = Quaternion.LookRotation(lookingDirection).eulerAngles;
|
||||
|
||||
transformSubmodule.eulerAnglesOffset.Add(eulerAnglesOffse);
|
||||
Vector3 offset = transformSubmodule.eulerAnglesOffset.Sum();
|
||||
transformSubmodule.currentEulerAngles = transformSubmodule.originalEulerAngles + offset;
|
||||
|
||||
transform.LookAt(transformSubmodule.lookAt.lookAtObject.transform);
|
||||
transform.localEulerAngles += transformSubmodule.currentEulerAngles;
|
||||
|
||||
|
||||
// transform.LookAt(transformSubmodule.lookAt.lookAtObject.transform);
|
||||
transform.localEulerAngles = transformSubmodule.currentEulerAngles;
|
||||
|
||||
transformSubmodule.eulerAnglesDirtyMark = false;
|
||||
transformSubmodule.eulerAnglesOffset.Clear();
|
||||
}
|
||||
@@ -120,7 +126,7 @@ namespace Ichni.RhythmGame
|
||||
}
|
||||
|
||||
bool willRefresh = false;
|
||||
|
||||
|
||||
if (!transformSubmodule.eulerAnglesOffsetLock && transformSubmodule.eulerAnglesDirtyMark)
|
||||
{
|
||||
Vector3 offset = transformSubmodule.eulerAnglesOffset.Sum();
|
||||
@@ -145,7 +151,7 @@ namespace Ichni.RhythmGame
|
||||
{
|
||||
Refresh();
|
||||
}
|
||||
|
||||
|
||||
}).AddTo(gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user