Files
ProjectOnrinto_Godot/Scripts/Data/ChartEvent.cs
CrbnsCat10n 0e6bf1dcad new file: .editorconfig
new file:   .gitattributes
	new file:   Charts/track.json
	new file:   ProjectOnrinto.csproj
	new file:   ProjectOnrinto.sln
	new file:   Scenes/Audio/audio_stream_player.tscn
	new file:   Scenes/Game/level.tscn
	new file:   Scenes/Prefabs/beat.tscn
	new file:   Scripts/Core/GameManager.cs
	new file:   Scripts/Core/GameManager.cs.uid
	new file:   Scripts/Core/MusicClock.cs
	new file:   Scripts/Core/MusicClock.cs.uid
	new file:   Scripts/Core/TrackGenerator.cs
	new file:   Scripts/Core/TrackGenerator.cs.uid
	new file:   Scripts/Data/ChartEvent.cs
	new file:   Scripts/Data/ChartEvent.cs.uid
	new file:   Scripts/Data/JsonConverter.cs
	new file:   Scripts/Data/JsonConverter.cs.uid
	new file:   Scripts/Data/TrackData.cs
	new file:   Scripts/Data/TrackData.cs.uid
	new file:   Scripts/GameObjects/NoteObject.cs
	new file:   Scripts/GameObjects/NoteObject.cs.uid
	new file:   icon.svg
	new file:   icon.svg.import
	new file:   project.godot
2026-04-05 00:07:28 +08:00

95 lines
2.1 KiB
C#

using Godot;
using System;
using System.Text.Json.Serialization;
namespace Onrinto.Chart;
public enum EventType { Hole, Obstacle, Beat, Catch, Through, Jump, Dash, Float };
public enum AnimationType { Linear, Sin, Back };
public class TempoPoint
{
public double Tick { get; set; }
public float BPM { get; set; }
[JsonConstructor]
public TempoPoint(double tick, float bpm, bool isLinear)
{
Tick = tick;
BPM = bpm;
}
}
public class SpeedPoint
{
public double Tick { get; set; }
public float Speed { get; set; }
public bool IsLinear { get; set; }
[JsonConstructor]
public SpeedPoint(double tick, float speed, bool isLinear)
{
Tick = tick;
Speed = speed;
IsLinear = isLinear;
}
}
[JsonPolymorphic(TypeDiscriminatorPropertyName = "$type")]
[JsonDerivedType(typeof(ChartEvent), typeDiscriminator: "Onrinto.Chart.ChartEvent")]
[JsonDerivedType(typeof(AnimatedEvent), typeDiscriminator: "Onrinto.Chart.AnimatedEvent")]
[Serializable]
public class ChartEvent
{
public EventType Type { get; set; }
public double Tick { get; set; }
public Vector2 Position { get; set; }
public double HitTime { get; set; }
public double HitAbsZ { get; set; }
public ChartEvent(EventType type, double tick, Vector2 position)
{
Type = type;
Tick = tick;
Position = position;
}
}
[Serializable]
public class AnimatedEvent : ChartEvent
{
public AnimationType AniType { get; set; }
public int In_Out { get; set; }
public double AniStartTime { get; set; }
public double AniEndTime { get; set; }
public Vector2 StartPosition { get; set; }
public Vector2 EndPosition { get; set; }
public float RelativeSpeed { get; set; }
public AnimatedEvent(
EventType type,
double tick,
Vector2 position,
AnimationType aniType,
int in_Out,
double aniStartTime,
double aniEndTime,
float relativeSpeed,
Vector2 startPosition,
Vector2 endPosition
) : base(type, tick, position)
{
AniType = aniType;
In_Out = in_Out;
AniStartTime = aniStartTime;
AniEndTime = aniEndTime;
RelativeSpeed = relativeSpeed;
StartPosition = startPosition;
EndPosition = endPosition;
}
}