好多新内容
This commit is contained in:
@@ -32,6 +32,14 @@ public class Animation_GenerateJudgementSituationPrefab : MonoBehaviour
|
||||
[Header("Inspector")]
|
||||
public float jumpForce = 5.0f; // Documentation text normalized.
|
||||
public float gravity = -16f; // Documentation text normalized.
|
||||
[Tooltip("Horizontal drift distance range for judge popup text. Adds a real arc instead of a straight pop.")]
|
||||
public Vector2 horizontalDriftRange = new Vector2(0.25f, 0.65f);
|
||||
[Tooltip("Random Z rotation range applied over the popup lifetime.")]
|
||||
public float rotationRange = 8f;
|
||||
[Tooltip("Temporary scale punch at the beginning of the popup.")]
|
||||
public float scalePunch = 0.18f;
|
||||
[Tooltip("How long the initial scale punch takes before settling back.")]
|
||||
public float scalePunchDuration = 0.18f;
|
||||
|
||||
[Header("Inspector")]
|
||||
public float fadeInTime = 0.1f; // Documentation text normalized.
|
||||
@@ -50,6 +58,8 @@ public class Animation_GenerateJudgementSituationPrefab : MonoBehaviour
|
||||
private Coroutine prewarmJudgeCoroutine;
|
||||
private readonly System.Collections.Generic.Dictionary<GameObject, System.Collections.Generic.Stack<GameObject>> judgePools
|
||||
= new System.Collections.Generic.Dictionary<GameObject, System.Collections.Generic.Stack<GameObject>>();
|
||||
private readonly System.Collections.Generic.HashSet<GameObject> rentedJudges
|
||||
= new System.Collections.Generic.HashSet<GameObject>();
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
@@ -160,6 +170,7 @@ public class Animation_GenerateJudgementSituationPrefab : MonoBehaviour
|
||||
return;
|
||||
|
||||
instance.transform.localPosition = Vector3.zero;
|
||||
instance.transform.localRotation = Quaternion.identity;
|
||||
|
||||
// Documentation text normalized.
|
||||
float finalScale = baseScale;
|
||||
@@ -205,6 +216,10 @@ public class Animation_GenerateJudgementSituationPrefab : MonoBehaviour
|
||||
try
|
||||
{
|
||||
instance = CreatePooledJudge(prefab);
|
||||
if (instance != null)
|
||||
{
|
||||
rentedJudges.Add(instance);
|
||||
}
|
||||
ReturnJudgeToPool(instance);
|
||||
}
|
||||
catch { }
|
||||
@@ -220,21 +235,18 @@ public class Animation_GenerateJudgementSituationPrefab : MonoBehaviour
|
||||
{
|
||||
if (obj == null) yield break;
|
||||
|
||||
SpriteRenderer sr = obj.GetComponent<SpriteRenderer>();
|
||||
SpriteRenderer[] renderers = obj.GetComponentsInChildren<SpriteRenderer>(true);
|
||||
float elapsed = 0f;
|
||||
float vVelocity = jumpForce;
|
||||
Vector3 currentLocalPos = Vector3.zero;
|
||||
|
||||
// Documentation text normalized.
|
||||
float totalLifeTime = fadeOutStartTime + fadeOutDuration;
|
||||
float driftSign = Random.value < 0.5f ? -1f : 1f;
|
||||
float driftDistance = Random.Range(horizontalDriftRange.x, horizontalDriftRange.y) * driftSign;
|
||||
float horizontalVelocity = totalLifeTime > 0.001f ? driftDistance / totalLifeTime : 0f;
|
||||
float targetRotation = Random.Range(-rotationRange, rotationRange);
|
||||
Vector3 currentLocalPos = Vector3.zero;
|
||||
Vector3 baseScaleValue = obj.transform.localScale;
|
||||
|
||||
// Documentation text normalized.
|
||||
if (sr != null)
|
||||
{
|
||||
Color c = sr.color;
|
||||
c.a = 0f;
|
||||
sr.color = c;
|
||||
}
|
||||
SetRenderersAlpha(renderers, 0f);
|
||||
|
||||
// Documentation text normalized.
|
||||
while (elapsed < totalLifeTime)
|
||||
@@ -246,45 +258,46 @@ public class Animation_GenerateJudgementSituationPrefab : MonoBehaviour
|
||||
|
||||
// Documentation text normalized.
|
||||
vVelocity += gravity * dt;
|
||||
currentLocalPos.x += horizontalVelocity * dt;
|
||||
currentLocalPos.y += vVelocity * dt;
|
||||
obj.transform.localPosition = currentLocalPos;
|
||||
obj.transform.localRotation = Quaternion.Euler(0f, 0f, Mathf.Lerp(0f, targetRotation, Mathf.Clamp01(elapsed / totalLifeTime)));
|
||||
|
||||
float scaleT = scalePunchDuration > 0.001f ? Mathf.Clamp01(elapsed / scalePunchDuration) : 1f;
|
||||
float punch = Mathf.Sin(scaleT * Mathf.PI) * scalePunch;
|
||||
obj.transform.localScale = baseScaleValue * (1f + punch);
|
||||
|
||||
// Documentation text normalized.
|
||||
if (sr != null)
|
||||
float alpha;
|
||||
|
||||
// Documentation text normalized.
|
||||
if (elapsed < fadeInTime)
|
||||
{
|
||||
float alpha;
|
||||
|
||||
// Documentation text normalized.
|
||||
if (elapsed < fadeInTime)
|
||||
{
|
||||
alpha = Mathf.InverseLerp(0f, fadeInTime, elapsed);
|
||||
}
|
||||
// Documentation text normalized.
|
||||
else if (elapsed > fadeOutStartTime)
|
||||
{
|
||||
// Documentation text normalized.
|
||||
alpha = Mathf.InverseLerp(totalLifeTime, fadeOutStartTime, elapsed);
|
||||
}
|
||||
// Documentation text normalized.
|
||||
else
|
||||
{
|
||||
alpha = 1f;
|
||||
}
|
||||
|
||||
Color c = sr.color;
|
||||
c.a = Mathf.Clamp01(alpha);
|
||||
sr.color = c;
|
||||
alpha = Mathf.InverseLerp(0f, fadeInTime, elapsed);
|
||||
}
|
||||
// Documentation text normalized.
|
||||
else if (elapsed > fadeOutStartTime)
|
||||
{
|
||||
// Documentation text normalized.
|
||||
alpha = Mathf.InverseLerp(totalLifeTime, fadeOutStartTime, elapsed);
|
||||
}
|
||||
// Documentation text normalized.
|
||||
else
|
||||
{
|
||||
alpha = 1f;
|
||||
}
|
||||
|
||||
SetRenderersAlpha(renderers, Mathf.Clamp01(alpha));
|
||||
|
||||
yield return null;
|
||||
}
|
||||
|
||||
// Documentation text normalized.
|
||||
if (obj != null && sr != null)
|
||||
if (obj != null)
|
||||
{
|
||||
Color c = sr.color;
|
||||
c.a = 0f;
|
||||
sr.color = c;
|
||||
obj.transform.localScale = baseScaleValue;
|
||||
obj.transform.localRotation = Quaternion.identity;
|
||||
SetRenderersAlpha(renderers, 0f);
|
||||
}
|
||||
|
||||
// Documentation text normalized.
|
||||
@@ -292,6 +305,23 @@ public class Animation_GenerateJudgementSituationPrefab : MonoBehaviour
|
||||
if (obj != null) ReturnJudgeToPool(obj);
|
||||
}
|
||||
|
||||
private static void SetRenderersAlpha(SpriteRenderer[] renderers, float alpha)
|
||||
{
|
||||
if (renderers == null)
|
||||
return;
|
||||
|
||||
for (int i = 0; i < renderers.Length; i++)
|
||||
{
|
||||
SpriteRenderer sr = renderers[i];
|
||||
if (sr == null)
|
||||
continue;
|
||||
|
||||
Color c = sr.color;
|
||||
c.a = alpha;
|
||||
sr.color = c;
|
||||
}
|
||||
}
|
||||
|
||||
private GameObject GetPooledJudge(GameObject prefab, Transform parent)
|
||||
{
|
||||
if (prefab == null || parent == null)
|
||||
@@ -319,6 +349,7 @@ public class Animation_GenerateJudgementSituationPrefab : MonoBehaviour
|
||||
|
||||
instance.transform.SetParent(parent, false);
|
||||
instance.SetActive(true);
|
||||
rentedJudges.Add(instance);
|
||||
return instance;
|
||||
}
|
||||
|
||||
@@ -341,6 +372,9 @@ public class Animation_GenerateJudgementSituationPrefab : MonoBehaviour
|
||||
if (instance == null)
|
||||
return;
|
||||
|
||||
if (!rentedJudges.Remove(instance))
|
||||
return;
|
||||
|
||||
var tag = instance.GetComponent<PooledJudgeTag>();
|
||||
if (tag == null || tag.prefabSource == null)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user