update
This commit is contained in:
@@ -22,6 +22,11 @@ namespace Hallucinate.GameSetup.Maze
|
||||
|
||||
public float Scale => visualProfile != null ? visualProfile.scale : 1f;
|
||||
|
||||
public enum CellAnimationType { None, ScaleUp, DropDown, SpinIn }
|
||||
|
||||
[HideInInspector]
|
||||
public CellAnimationType currentAnimationType = CellAnimationType.ScaleUp;
|
||||
|
||||
[ShowInInspector]
|
||||
[ReadOnly]
|
||||
[BoxGroup("Runtime")]
|
||||
@@ -294,10 +299,27 @@ namespace Hallucinate.GameSetup.Maze
|
||||
{
|
||||
if (target == null) yield break;
|
||||
|
||||
if (currentAnimationType == CellAnimationType.None) yield break;
|
||||
|
||||
float duration = Mathf.Max(0.01f, visualProfile.animationDuration);
|
||||
float elapsed = 0;
|
||||
Vector3 finalScale = target.localScale;
|
||||
target.localScale = Vector3.one * 0.001f;
|
||||
Vector3 finalPosition = target.localPosition;
|
||||
Quaternion finalRotation = target.localRotation;
|
||||
|
||||
if (currentAnimationType == CellAnimationType.ScaleUp)
|
||||
{
|
||||
target.localScale = Vector3.one * 0.001f;
|
||||
}
|
||||
else if (currentAnimationType == CellAnimationType.DropDown)
|
||||
{
|
||||
target.localPosition = finalPosition + Vector3.up * 5f;
|
||||
}
|
||||
else if (currentAnimationType == CellAnimationType.SpinIn)
|
||||
{
|
||||
target.localScale = Vector3.one * 0.001f;
|
||||
target.localRotation = finalRotation * Quaternion.Euler(0, 180, 0);
|
||||
}
|
||||
|
||||
while (elapsed < duration)
|
||||
{
|
||||
@@ -305,16 +327,32 @@ namespace Hallucinate.GameSetup.Maze
|
||||
|
||||
elapsed += Time.deltaTime;
|
||||
float t = Mathf.Clamp01(elapsed / duration);
|
||||
float s = Mathf.Sin(t * Mathf.PI * 0.5f);
|
||||
|
||||
target.localScale = finalScale * Mathf.Max(0.001f, s);
|
||||
if (currentAnimationType == CellAnimationType.ScaleUp)
|
||||
{
|
||||
float s = Mathf.Sin(t * Mathf.PI * 0.5f);
|
||||
target.localScale = finalScale * Mathf.Max(0.001f, s);
|
||||
}
|
||||
else if (currentAnimationType == CellAnimationType.DropDown)
|
||||
{
|
||||
float s = Mathf.Sin(t * Mathf.PI * 0.5f);
|
||||
target.localPosition = Vector3.Lerp(finalPosition + Vector3.up * 5f, finalPosition, s);
|
||||
}
|
||||
else if (currentAnimationType == CellAnimationType.SpinIn)
|
||||
{
|
||||
float s = Mathf.Sin(t * Mathf.PI * 0.5f);
|
||||
target.localScale = finalScale * Mathf.Max(0.001f, s);
|
||||
target.localRotation = Quaternion.Lerp(finalRotation * Quaternion.Euler(0, 180, 0), finalRotation, s);
|
||||
}
|
||||
|
||||
yield return null;
|
||||
}
|
||||
|
||||
if (target != null)
|
||||
{
|
||||
// Scale
|
||||
target.localScale = finalScale;
|
||||
target.localPosition = finalPosition;
|
||||
target.localRotation = finalRotation;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user