Initial import of Rhyculator
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
commit
728bb0c657
315 files changed
+96030
No files matched your search
@@ -0,0 +1,53 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class GridColor : MonoBehaviour
|
||||
{
|
||||
public Image cellImage;
|
||||
public Sprite defaultSprite;
|
||||
public Sprite whiteSprite;
|
||||
public Sprite blueSprite;
|
||||
public Sprite orangeSprite;
|
||||
public Sprite redSprite;
|
||||
public Sprite greenSprite;
|
||||
public int cellX;
|
||||
public int cellY;
|
||||
public float flashDuration = 0.3f;
|
||||
|
||||
private float flashEnd;
|
||||
private bool colored; // 目前顯示的是判定色(優先於按住時的白色)
|
||||
|
||||
void Awake()
|
||||
{
|
||||
if (cellImage == null) cellImage = GetComponent<Image>();
|
||||
if (defaultSprite == null) defaultSprite = cellImage.sprite;
|
||||
enabled = false; // 沒有閃爍時不跑 Update
|
||||
}
|
||||
|
||||
// 按住提示:不覆蓋判定色
|
||||
public void FlashWhite()
|
||||
{
|
||||
if (enabled && colored) return;
|
||||
Flash(whiteSprite, false);
|
||||
}
|
||||
|
||||
public void FlashBlue() => Flash(blueSprite, true);
|
||||
public void FlashOrange() => Flash(orangeSprite, true);
|
||||
public void FlashRed() => Flash(redSprite, true);
|
||||
public void FlashGreen() => Flash(greenSprite, true);
|
||||
|
||||
private void Flash(Sprite sprite, bool isColor)
|
||||
{
|
||||
cellImage.sprite = sprite;
|
||||
colored = isColor;
|
||||
flashEnd = Time.time + flashDuration;
|
||||
enabled = true;
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (Time.time < flashEnd) return;
|
||||
cellImage.sprite = defaultSprite;
|
||||
enabled = false;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user