Added a bunch of features

This commit is contained in:
2018-04-11 16:54:57 +10:00
parent 2cd21dc329
commit a13da880b1
17 changed files with 737 additions and 23 deletions
+41
View File
@@ -0,0 +1,41 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Flash : MonoBehaviour {
SpriteRenderer spriteRenderer;
float alpha = 1.0f;
const float gradient = 0.1f;
const float period = 0.1f;
float lastClick; //prevent double exposure
void Awake() {
spriteRenderer = GetComponent<SpriteRenderer> ();
spriteRenderer.color = new Color (1f, 1f, 1f, 0f);
}
public void StartFlash() {
StartCoroutine (FlashCoroutine ());
}
IEnumerator FlashCoroutine() {
lastClick = Time.time;
float thisClick = lastClick;
alpha = 1.0f;
while (alpha > 0) {
yield return new WaitForSeconds (period);
if (thisClick != lastClick) {
break;
}
alpha -= gradient;
spriteRenderer.color = new Color (1f, 1f, 1f, alpha);
}
}
}