new file: Audio/track.mp3 new file: Audio/track.mp3.import modified: Charts/track.json modified: Scenes/Game/level.tscn new file: Scripts/.DS_Store modified: Scripts/Core/GameManager.cs modified: Scripts/Core/MusicClock.cs modified: Scripts/Core/TrackGenerator.cs modified: Scripts/Data/ChartEvent.cs modified: Scripts/Data/TrackData.cs modified: Scripts/GameObjects/NoteObject.cs
43 lines
1.2 KiB
C#
43 lines
1.2 KiB
C#
using Godot;
|
|
using Onrinto.Chart;
|
|
|
|
public partial class NoteObject : Node3D
|
|
{
|
|
private double _hitSeconds;
|
|
private float _hitAbsZ;
|
|
private bool _isHit = false;
|
|
private bool _initialized = false;
|
|
|
|
public void Initialize(ChartEvent chartEvent)
|
|
{
|
|
_hitSeconds = chartEvent.HitTime;
|
|
_hitAbsZ = chartEvent.HitAbsZ;
|
|
float initialZ = _hitAbsZ - GameManager.Instance.CurrentAbsZ;
|
|
Position = new Vector3(chartEvent.Position.X, chartEvent.Position.Y, initialZ);
|
|
|
|
_initialized = true;
|
|
}
|
|
|
|
// Called when the node enters the scene tree for the first time.
|
|
public override void _Ready()
|
|
{
|
|
|
|
}
|
|
|
|
// Called every frame. 'delta' is the elapsed time since the previous frame.
|
|
public override void _Process(double delta)
|
|
{
|
|
if (!_initialized) return;
|
|
|
|
double _currentTime = MusicClock.Instance.CurrentTime;
|
|
|
|
float newZ = (float)((_hitAbsZ - GameManager.Instance.CurrentAbsZ) * GameManager.Instance.FinalSpeed);
|
|
Position = new Vector3(Position.X, Position.Y, newZ); // Update Z position
|
|
|
|
if(_hitSeconds - _currentTime < -0.5) QueueFree(); // Remove note
|
|
|
|
// Toggle visibility instead of removing
|
|
Visible = (newZ >= 0 && newZ <= GameManager.Instance.VisibleDistance);
|
|
}
|
|
}
|