[TASK] Added more duck spawn, performance fixes, instruction in the minigame, option to zoom in on stickers
This commit is contained in:
56
Assets/MinigameInstruction.cs
Normal file
56
Assets/MinigameInstruction.cs
Normal file
@@ -0,0 +1,56 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
[RequireComponent(typeof(CanvasGroup))]
|
||||
public class MinigameInstruction : MonoBehaviour
|
||||
{
|
||||
|
||||
public float instructionTimeout = 2f;
|
||||
public float fadeinTime = 0.5f;
|
||||
|
||||
private CanvasGroup _canvasGroup;
|
||||
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
_canvasGroup = GetComponent<CanvasGroup>();
|
||||
_canvasGroup.alpha = 0;
|
||||
}
|
||||
|
||||
public void Show()
|
||||
{
|
||||
StartCoroutine(FadeIn());
|
||||
StartCoroutine(FadeOutAfterTimeout());
|
||||
}
|
||||
|
||||
private IEnumerator FadeIn()
|
||||
{
|
||||
// Debug.Log("Fading in");
|
||||
float t = 0;
|
||||
while (t < fadeinTime)
|
||||
{
|
||||
t += Time.deltaTime;
|
||||
_canvasGroup.alpha = t / fadeinTime;
|
||||
yield return null;
|
||||
}
|
||||
|
||||
_canvasGroup.alpha = 1;
|
||||
}
|
||||
|
||||
private IEnumerator FadeOutAfterTimeout()
|
||||
{
|
||||
yield return new WaitForSeconds(instructionTimeout + fadeinTime);
|
||||
// Debug.Log("Fading out");
|
||||
float t = 0;
|
||||
while (t < fadeinTime)
|
||||
{
|
||||
t += Time.deltaTime;
|
||||
_canvasGroup.alpha = 1 - t / fadeinTime;
|
||||
yield return null;
|
||||
}
|
||||
|
||||
_canvasGroup.alpha = 0;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user