|
|
|
@ -12,7 +12,7 @@ public class OscHandler : MonoBehaviour |
|
|
|
|
|
|
|
|
|
|
|
[SerializeField] |
|
|
|
[SerializeField] |
|
|
|
public CanvasGroup intro; |
|
|
|
public CanvasGroup intro; |
|
|
|
|
|
|
|
|
|
|
|
[SerializeField] |
|
|
|
[SerializeField] |
|
|
|
public CanvasGroup main; |
|
|
|
public CanvasGroup main; |
|
|
|
|
|
|
|
|
|
|
|
@ -56,6 +56,8 @@ public class OscHandler : MonoBehaviour |
|
|
|
[SerializeField] |
|
|
|
[SerializeField] |
|
|
|
public CanvasGroup hintforStep; |
|
|
|
public CanvasGroup hintforStep; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private IEnumerator coroutine_breath; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Start is called before the first frame update |
|
|
|
// Start is called before the first frame update |
|
|
|
void Start() |
|
|
|
void Start() |
|
|
|
@ -220,7 +222,8 @@ public class OscHandler : MonoBehaviour |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
statusText.text = input; |
|
|
|
// statusText.text = input; |
|
|
|
|
|
|
|
StartCoroutine(TypeWriter(statusText, input)); |
|
|
|
// hintforChat.alpha = 1f; |
|
|
|
// hintforChat.alpha = 1f; |
|
|
|
if (hintforChat.alpha < 1f) |
|
|
|
if (hintforChat.alpha < 1f) |
|
|
|
{ |
|
|
|
{ |
|
|
|
@ -229,24 +232,74 @@ public class OscHandler : MonoBehaviour |
|
|
|
|
|
|
|
|
|
|
|
if (hint.alpha < 1f) |
|
|
|
if (hint.alpha < 1f) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
// if (coroutine_hint != null) StopCoroutine(coroutine_hint); |
|
|
|
|
|
|
|
// coroutine_hint = FadeCanvasGroup(hint, hint.alpha, 1f, _hintDuration); |
|
|
|
|
|
|
|
// StartCoroutine(coroutine_hint); |
|
|
|
|
|
|
|
|
|
|
|
if (coroutine_hint != null) StopCoroutine(coroutine_hint); |
|
|
|
if (coroutine_hint != null) StopCoroutine(coroutine_hint); |
|
|
|
coroutine_hint = FadeCanvasGroup(hint, hint.alpha, 1f, _hintDuration); |
|
|
|
coroutine_hint = BreathFade(hint); |
|
|
|
StartCoroutine(coroutine_hint); |
|
|
|
StartCoroutine(coroutine_hint); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
public void onHint(string text) |
|
|
|
public void onHint(string text) |
|
|
|
{ |
|
|
|
{ |
|
|
|
Debug.Log("/hint message received: " + text); |
|
|
|
Debug.Log("/hint message received: " + text); |
|
|
|
|
|
|
|
|
|
|
|
stepText.text = text; |
|
|
|
// stepText.text = text; |
|
|
|
|
|
|
|
StartCoroutine(TypeWriter(stepText, text)); |
|
|
|
|
|
|
|
|
|
|
|
StartCoroutine(FadeCanvasGroup(hintforStep, hintforStep.alpha, 1f, _hintDuration)); |
|
|
|
StartCoroutine(FadeCanvasGroup(hintforStep, hintforStep.alpha, 1f, _hintDuration)); |
|
|
|
|
|
|
|
|
|
|
|
if (coroutine_hint != null) StopCoroutine(coroutine_hint); |
|
|
|
if (coroutine_breath != null) StopCoroutine(coroutine_breath); |
|
|
|
coroutine_hint = FadeCanvasGroup(hint, hint.alpha, text.Length > 0 ? 1f : 0f, _hintDuration); |
|
|
|
// coroutine_hint = FadeCanvasGroup(hint, hint.alpha, text.Length > 0 ? 1f : 0f, _hintDuration); |
|
|
|
StartCoroutine(coroutine_hint); |
|
|
|
// StartCoroutine(coroutine_hint); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
coroutine_breath = BreathFade(hintforStep); |
|
|
|
|
|
|
|
StartCoroutine(coroutine_breath); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private IEnumerator BreathFade(CanvasGroup canvasGroup, float maxAlpha=1f, float minAlpha=0.33f, |
|
|
|
|
|
|
|
float fadeInDuration=1.2f, float fadeOutDuration=1.2f, int cycles=20) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
for (int i = 0; i < cycles; i++) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
// Fade out |
|
|
|
|
|
|
|
float elapsed = 0f; |
|
|
|
|
|
|
|
while (elapsed < fadeOutDuration) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
elapsed += Time.deltaTime; |
|
|
|
|
|
|
|
canvasGroup.alpha = Mathf.Lerp(maxAlpha, minAlpha, elapsed / fadeOutDuration); |
|
|
|
|
|
|
|
yield return null; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
canvasGroup.alpha = minAlpha; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Fade in |
|
|
|
|
|
|
|
elapsed = 0f; |
|
|
|
|
|
|
|
while (elapsed < fadeInDuration) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
elapsed += Time.deltaTime; |
|
|
|
|
|
|
|
canvasGroup.alpha = Mathf.Lerp(minAlpha, maxAlpha, elapsed / fadeInDuration); |
|
|
|
|
|
|
|
yield return null; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
canvasGroup.alpha = maxAlpha; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
public IEnumerator TypeWriter(TextMeshProUGUI textComponent, string message, float typeSpeed = 0.2f) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
textComponent.text = ""; |
|
|
|
|
|
|
|
foreach (char c in message) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
textComponent.text += c; |
|
|
|
|
|
|
|
yield return new WaitForSeconds(typeSpeed); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|