swipe arrow progress

This commit is contained in:
muskit
2023-10-09 01:22:41 -07:00
parent 1f179d6a79
commit c276e2732c
8 changed files with 185 additions and 50 deletions
+1 -1
View File
@@ -132,11 +132,11 @@ namespace WacK.Scenes
default:
continue;
}
noteDisplay.AddChild(nNote);
nNote.Init(note);
var nPos = nNote.Position;
nPos.Y = msNote.Key * -ScrollPxPerSec;
nNote.Position = nPos;
noteDisplay.AddChild(nNote);
}
}
}
@@ -0,0 +1,37 @@
using Godot;
using System;
namespace WacK.Things.TunnelObjects
{
[Tool]
public partial class SwipeArrow : Control
{
public readonly Color COLOR_CW = new("#FF8000");
public readonly Color COLOR_CCW = new("#00FF00");
private ShaderMaterial shader;
public override void _EnterTree()
{
shader = (ShaderMaterial) Material;
}
public void SetCW(bool isCW)
{
shader.SetShaderParameter("ArrowColor", isCW ? COLOR_CW : COLOR_CCW);
shader.SetShaderParameter("isCwShape", isCW);
}
public void SetPosSize(int pos, int size)
{
var p = Position;
p.X = Constants.BASE_2D_RESOLUTION / 60 * pos;
Position = p;
var s = Size;
s.Y = Constants.BASE_2D_RESOLUTION / 60 * size;
Size = s;
shader.SetShaderParameter("TileMult", s.Y / 64);
}
}
}
+31 -11
View File
@@ -9,34 +9,54 @@ namespace WacK.Things.TunnelObjects
private NinePatchRect noteBase;
public NotePlay noteData;
public void Init(NotePlay noteData)
public async void Init(NotePlay noteData)
{
await ToSignal(GetTree(), SceneTree.SignalName.ProcessFrame);
this.noteData = noteData;
SetSizePos((int)noteData.pos, (int)noteData.size);
SetPosSize((int)noteData.pos, (int)noteData.size);
// handle swipe arrow color
if (noteData.type == NotePlayType.SwipeCW)
{
var n = (SwipeArrow) FindChild("SwipeArrow");
n.SetCW(noteData.type == NotePlayType.SwipeCW);
}
}
public void SetSizePos(int pos, int size)
public void SetPosSize(int pos, int size)
{
var nbPos = pos;
var nbSize = size;
// TODO: end caps peak into bounds
if (3 <= size && size <= 59)
{
pos += 1;
size -= 2;
nbPos += 1;
nbSize -= 2;
}
else if (size >= 60)
{
size = 60;
nbSize = 60;
noteBase.RegionRect = new Rect2(12, 0, new Vector2(488, 36));
noteBase.PatchMarginLeft = 0;
noteBase.PatchMarginRight = 0;
}
var nPos = Position;
nPos.X = pos * (Constants.BASE_2D_RESOLUTION/60) - 12;
Position = nPos;
var nPos = noteBase.Position;
nPos.X = nbPos * (Constants.BASE_2D_RESOLUTION/60) - 12;
noteBase.Position = nPos;
var nSize = Size;
nSize.X = size * (Constants.BASE_2D_RESOLUTION/60) + 24;
Size = nSize;
var nSize = noteBase.Size;
nSize.X = nbSize * (Constants.BASE_2D_RESOLUTION/60) + 24;
noteBase.Size = nSize;
// handle swipe arrow size
if (noteData.type == NotePlayType.SwipeCW || noteData.type == NotePlayType.SwipeCCW)
{
var n = (SwipeArrow) FindChild("SwipeArrow");
n.SetPosSize(pos, size);
}
}
}
}