2023-11-23 21:31:23 +00:00
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using UnityEngine;
|
|
|
|
using Jukebox;
|
|
|
|
using UnityEngine.UI;
|
|
|
|
|
|
|
|
namespace HeavenStudio
|
|
|
|
{
|
|
|
|
public class ScreenTiling : MonoBehaviour
|
|
|
|
{
|
|
|
|
private RawImage _image;
|
|
|
|
|
2023-11-24 22:49:59 +00:00
|
|
|
private List<RiqEntity> _tileEvents = new();
|
|
|
|
private List<RiqEntity> _scrollEvents = new();
|
2023-11-23 21:31:23 +00:00
|
|
|
|
|
|
|
private void Awake()
|
|
|
|
{
|
|
|
|
_image = GetComponent<RawImage>();
|
|
|
|
}
|
|
|
|
|
|
|
|
private void Start()
|
|
|
|
{
|
|
|
|
GameManager.instance.onBeatChanged += OnBeatChanged;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void OnBeatChanged(double beat)
|
|
|
|
{
|
2023-11-24 22:49:59 +00:00
|
|
|
_tileEvents = EventCaller.GetAllInGameManagerList("vfx", new string[] { "screenTiling" });
|
|
|
|
_scrollEvents = EventCaller.GetAllInGameManagerList("vfx", new string[] { "scrollTiles" });
|
2023-11-23 21:31:23 +00:00
|
|
|
ResetUVRect();
|
|
|
|
Update();
|
|
|
|
}
|
|
|
|
|
|
|
|
private void Update()
|
|
|
|
{
|
2023-11-24 22:49:59 +00:00
|
|
|
float newXTiles = 1;
|
|
|
|
float newYTiles = 1;
|
|
|
|
float newXScroll = 0;
|
|
|
|
float newYScroll = 0;
|
|
|
|
foreach (var e in _tileEvents)
|
2023-11-23 21:31:23 +00:00
|
|
|
{
|
|
|
|
float normalized = Conductor.instance.GetPositionFromBeat(e.beat, e.length);
|
|
|
|
if (normalized < 0) break;
|
|
|
|
|
|
|
|
float clampNormal = Mathf.Clamp01(normalized);
|
|
|
|
|
|
|
|
var func = Util.EasingFunction.GetEasingFunction((Util.EasingFunction.Ease)e["ease"]);
|
|
|
|
|
2023-11-24 22:49:59 +00:00
|
|
|
switch ((StaticCamera.ViewAxis)e["axis"])
|
|
|
|
{
|
|
|
|
case StaticCamera.ViewAxis.All:
|
|
|
|
newXTiles = func(e["xStart"], e["xEnd"], clampNormal);
|
|
|
|
newYTiles = func(e["yStart"], e["yEnd"], clampNormal);
|
|
|
|
break;
|
|
|
|
case StaticCamera.ViewAxis.X:
|
|
|
|
newXTiles = func(e["xStart"], e["xEnd"], clampNormal);
|
|
|
|
break;
|
|
|
|
case StaticCamera.ViewAxis.Y:
|
|
|
|
newYTiles = func(e["yStart"], e["yEnd"], clampNormal);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach (var e in _scrollEvents)
|
|
|
|
{
|
|
|
|
float normalized = Conductor.instance.GetPositionFromBeat(e.beat, e.length);
|
|
|
|
if (normalized < 0) break;
|
|
|
|
|
|
|
|
float clampNormal = Mathf.Clamp01(normalized);
|
|
|
|
|
|
|
|
var func = Util.EasingFunction.GetEasingFunction((Util.EasingFunction.Ease)e["ease"]);
|
2023-11-23 21:31:23 +00:00
|
|
|
|
2023-11-24 22:49:59 +00:00
|
|
|
switch ((StaticCamera.ViewAxis)e["axis"])
|
|
|
|
{
|
|
|
|
case StaticCamera.ViewAxis.All:
|
|
|
|
newXScroll = func(e["xScrollStart"], e["xScrollEnd"], clampNormal);
|
|
|
|
newYScroll = func(e["yScrollStart"], e["yScrollEnd"], clampNormal);
|
|
|
|
break;
|
|
|
|
case StaticCamera.ViewAxis.X:
|
|
|
|
newXScroll = func(e["xScrollStart"], e["xScrollEnd"], clampNormal);
|
|
|
|
break;
|
|
|
|
case StaticCamera.ViewAxis.Y:
|
|
|
|
newYScroll = func(e["yScrollStart"], e["yScrollEnd"], clampNormal);
|
|
|
|
break;
|
|
|
|
}
|
2023-11-23 21:31:23 +00:00
|
|
|
}
|
2023-11-24 22:49:59 +00:00
|
|
|
_image.uvRect = new Rect(newXScroll, newYScroll, newXTiles, newYTiles);
|
2023-11-23 21:31:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void ResetUVRect()
|
|
|
|
{
|
|
|
|
_image.uvRect = new Rect(0, 0, 1, 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|