Disabled Saves, moved Folders adn renamed Data files, and added a state machine to the cookie puzzle
This commit is contained in:
@@ -0,0 +1,69 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
public class FlashBehaviour : MonoBehaviour
|
||||
{
|
||||
public GameObject square; // Assign in inspector or find in Start
|
||||
public float flashInDuration = 0.05f;
|
||||
public float flashOutDuration = 0.2f;
|
||||
|
||||
private Color squareColor;
|
||||
private Coroutine flashCoroutine;
|
||||
private SpriteRenderer spriteRenderer;
|
||||
|
||||
void Start()
|
||||
{
|
||||
|
||||
if (square == null)
|
||||
square = transform.Find("Square")?.gameObject;
|
||||
|
||||
if (square != null)
|
||||
spriteRenderer = square.GetComponent<SpriteRenderer>();
|
||||
|
||||
if (spriteRenderer != null)
|
||||
{
|
||||
squareColor = spriteRenderer.color;
|
||||
squareColor.a = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void TriggerFlash()
|
||||
{
|
||||
if (flashCoroutine != null)
|
||||
StopCoroutine(flashCoroutine);
|
||||
flashCoroutine = StartCoroutine(FlashRoutine());
|
||||
}
|
||||
|
||||
private IEnumerator FlashRoutine()
|
||||
{
|
||||
// Fade in
|
||||
float t = 0;
|
||||
while (t < flashInDuration)
|
||||
{
|
||||
t += Time.deltaTime;
|
||||
SetAlpha(Mathf.Lerp(0, 1, t / flashInDuration));
|
||||
yield return null;
|
||||
}
|
||||
SetAlpha(1);
|
||||
|
||||
// Fade out
|
||||
t = 0;
|
||||
while (t < flashOutDuration)
|
||||
{
|
||||
t += Time.deltaTime;
|
||||
SetAlpha(Mathf.Lerp(1, 0, t / flashOutDuration));
|
||||
yield return null;
|
||||
}
|
||||
SetAlpha(0);
|
||||
}
|
||||
|
||||
private void SetAlpha(float alpha)
|
||||
{
|
||||
if (spriteRenderer != null)
|
||||
{
|
||||
squareColor.a = alpha;
|
||||
spriteRenderer.color = squareColor;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 194155c0137366c4ea64558d2601e19a
|
||||
@@ -0,0 +1,33 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class TrashSpawner : MonoBehaviour
|
||||
{
|
||||
// Assign in inspector: the pool of sprites to choose from
|
||||
public Sprite[] spritePool;
|
||||
[Tooltip("Visual radius for spawn point in editor")]
|
||||
public float gizmoRadius = 0.5f;
|
||||
|
||||
// Visual indicator for editor only
|
||||
private void OnDrawGizmos()
|
||||
{
|
||||
Gizmos.color = Color.cadetBlue;
|
||||
Gizmos.DrawWireSphere(transform.position, gizmoRadius);
|
||||
|
||||
// Draw a cross in the center for better visibility
|
||||
Gizmos.DrawLine(
|
||||
transform.position + Vector3.left * gizmoRadius * 0.5f,
|
||||
transform.position + Vector3.right * gizmoRadius * 0.5f);
|
||||
Gizmos.DrawLine(
|
||||
transform.position + Vector3.up * gizmoRadius * 0.5f,
|
||||
transform.position + Vector3.down * gizmoRadius * 0.5f);
|
||||
}
|
||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||
void Start()
|
||||
{
|
||||
var sr = GetComponent<SpriteRenderer>();
|
||||
if (spritePool != null && spritePool.Length > 0 && sr != null)
|
||||
{
|
||||
sr.sprite = spritePool[Random.Range(0, spritePool.Length)];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: edd79c7026d196b49867a3ed7e7828b3
|
||||
Reference in New Issue
Block a user