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,80 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class HoldHintSpawner : MonoBehaviour
|
||||
{
|
||||
public GameObject holdProgressPrefab;
|
||||
public int rows = 6;
|
||||
public int columns = 5;
|
||||
public float baseWidth = 1080f;
|
||||
public float cellBase = 180f;
|
||||
public float spaceBase = 20f;
|
||||
public float heightBase = 90f;
|
||||
|
||||
public HoldProgress[,] holdProgressArray;
|
||||
public Vector2 offset = new Vector2(-60f, 60f);
|
||||
public Vector2 prefabSize = new Vector2(300f, 300f);
|
||||
|
||||
void Start()
|
||||
{
|
||||
float scale = Screen.width / baseWidth;
|
||||
|
||||
float cellSize = cellBase * scale;
|
||||
float spacing = spaceBase * scale;
|
||||
float heightOffset = heightBase * scale;
|
||||
|
||||
holdProgressArray = new HoldProgress[columns, rows];
|
||||
|
||||
RectTransform rt = GetComponent<RectTransform>();
|
||||
if (rt == null) rt = gameObject.AddComponent<RectTransform>();
|
||||
|
||||
rt.anchorMin = new Vector2(0.5f, 0f);
|
||||
rt.anchorMax = new Vector2(0.5f, 0f);
|
||||
rt.pivot = new Vector2(0.5f, 0f);
|
||||
|
||||
float totalWidth = columns * cellSize + (columns - 1) * spacing;
|
||||
float startX = -totalWidth / 2f;
|
||||
float startY = heightOffset;
|
||||
|
||||
Vector2[,] positions = new Vector2[columns, rows];
|
||||
for (int y = 0; y < rows; y++)
|
||||
{
|
||||
for (int x = 0; x < columns; x++)
|
||||
{
|
||||
float posX = startX + x * (cellSize + spacing) + offset.x;
|
||||
float posY = startY + y * (cellSize + spacing) + offset.y;
|
||||
positions[x, y] = new Vector2(posX, posY);
|
||||
}
|
||||
}
|
||||
|
||||
for (int y = 0; y < rows; y++)
|
||||
{
|
||||
for (int x = 0; x < columns; x++)
|
||||
{
|
||||
GameObject obj = Instantiate(holdProgressPrefab, transform);
|
||||
RectTransform objRT = obj.GetComponent<RectTransform>();
|
||||
objRT.anchorMin = new Vector2(0f, 0f);
|
||||
objRT.anchorMax = new Vector2(0f, 0f);
|
||||
objRT.pivot = new Vector2(0f, 0f);
|
||||
objRT.sizeDelta = prefabSize;
|
||||
objRT.anchoredPosition = positions[x, y];
|
||||
|
||||
HoldProgress progress = obj.GetComponent<HoldProgress>();
|
||||
holdProgressArray[x, y] = progress;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void StartProgressAt(int x, int y, float seconds)
|
||||
{
|
||||
if (x < 0 || y < 0 || x >= columns || y >= rows) return;
|
||||
HoldProgress progress = holdProgressArray[x, y];
|
||||
progress?.StartProgress(seconds);
|
||||
}
|
||||
|
||||
public void StopProgressAt(int x, int y)
|
||||
{
|
||||
if (x < 0 || y < 0 || x >= columns || y >= rows) return;
|
||||
HoldProgress progress = holdProgressArray[x, y];
|
||||
progress?.StopProgress();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user