com.amanotes.magictilescore 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +240 -0
- package/CHANGELOG.md.meta +7 -0
- package/Docs/Class-Hierarchy.md +729 -0
- package/Docs/Class-Hierarchy.md.meta +7 -0
- package/Docs/Component-Architecture.md +43 -0
- package/Docs/Component-Architecture.md.meta +7 -0
- package/Docs/File-Structure.md +327 -0
- package/Docs/File-Structure.md.meta +7 -0
- package/Docs/Game-Architecture.md +41 -0
- package/Docs/Game-Architecture.md.meta +7 -0
- package/Docs/Input-System-Guide.md +419 -0
- package/Docs/Input-System-Guide.md.meta +7 -0
- package/Docs/Knot-System-Guide.md +309 -0
- package/Docs/Knot-System-Guide.md.meta +7 -0
- package/Docs/Meta-System-Guide.md +249 -0
- package/Docs/Meta-System-Guide.md.meta +7 -0
- package/Docs/New-Game-Checklist.md +102 -0
- package/Docs/New-Game-Checklist.md.meta +7 -0
- package/Docs/README.md +37 -0
- package/Docs/README.md.meta +7 -0
- package/Docs/RhythmCore-Architecture.md +373 -0
- package/Docs/RhythmCore-Architecture.md.meta +7 -0
- package/Docs/RhythmCore-Customize-Guide.md +391 -0
- package/Docs/RhythmCore-Customize-Guide.md.meta +7 -0
- package/Docs/Understanding-Rhythm-Core.md +483 -0
- package/Docs/Understanding-Rhythm-Core.md.meta +7 -0
- package/Docs/VisualWarp-System-Guide.md +377 -0
- package/Docs/VisualWarp-System-Guide.md.meta +7 -0
- package/Docs/Widget2D-System-Guide.md +450 -0
- package/Docs/Widget2D-System-Guide.md.meta +7 -0
- package/Docs.meta +8 -0
- package/Editor/AdjustHueEditor.cs +90 -0
- package/Editor/AdjustHueEditor.cs.meta +11 -0
- package/Editor/ClassInstanceDrawer.cs +256 -0
- package/Editor/ClassInstanceDrawer.cs.meta +11 -0
- package/Editor/CollapsibleGroupEditor.cs +142 -0
- package/Editor/CollapsibleGroupEditor.cs.meta +11 -0
- package/Editor/ListSongNoteEditor.cs +317 -0
- package/Editor/ListSongNoteEditor.cs.meta +11 -0
- package/Editor/MagicTilesCore.Editor.asmdef +20 -0
- package/Editor/MagicTilesCore.Editor.asmdef.meta +7 -0
- package/Editor/MetaLogicDrawer.cs +488 -0
- package/Editor/MetaLogicDrawer.cs.meta +11 -0
- package/Editor/RhythmContextEditor.EditorDrawer.cs +46 -0
- package/Editor/RhythmContextEditor.EditorDrawer.cs.meta +3 -0
- package/Editor/RhythmContextEditor.cs +587 -0
- package/Editor/RhythmContextEditor.cs.meta +3 -0
- package/Editor/RhythmGameEditor.cs +45 -0
- package/Editor/RhythmGameEditor.cs.meta +11 -0
- package/Editor/RhythmTileEditor.cs +93 -0
- package/Editor/RhythmTileEditor.cs.meta +11 -0
- package/Editor/TagConfigDrawer.cs +30 -0
- package/Editor/TagConfigDrawer.cs.meta +11 -0
- package/Editor.meta +8 -0
- package/LICENSE.md +7 -0
- package/LICENSE.md.meta +7 -0
- package/README.md +88 -0
- package/README.md.meta +7 -0
- package/Runtime/AssemblyInfo.cs +4 -0
- package/Runtime/AssemblyInfo.cs.meta +11 -0
- package/Runtime/Input/Base/BaseTileInput.cs +44 -0
- package/Runtime/Input/Base/BaseTileInput.cs.meta +11 -0
- package/Runtime/Input/Base/IInputHandler.cs +11 -0
- package/Runtime/Input/Base/IInputHandler.cs.meta +11 -0
- package/Runtime/Input/Base/InputData.cs +94 -0
- package/Runtime/Input/Base/InputData.cs.meta +3 -0
- package/Runtime/Input/Base/InputDirection.cs +17 -0
- package/Runtime/Input/Base/InputDirection.cs.meta +3 -0
- package/Runtime/Input/Base/InputPhase.cs +4 -0
- package/Runtime/Input/Base/InputPhase.cs.meta +3 -0
- package/Runtime/Input/Base.meta +3 -0
- package/Runtime/Input/Components/DragInput.cs +44 -0
- package/Runtime/Input/Components/DragInput.cs.meta +11 -0
- package/Runtime/Input/Components/HoldInput.cs +75 -0
- package/Runtime/Input/Components/HoldInput.cs.meta +12 -0
- package/Runtime/Input/Components/SwipeInput.cs +45 -0
- package/Runtime/Input/Components/SwipeInput.cs.meta +12 -0
- package/Runtime/Input/Components/TouchInput.cs +31 -0
- package/Runtime/Input/Components/TouchInput.cs.meta +11 -0
- package/Runtime/Input/Components.meta +8 -0
- package/Runtime/Input.meta +8 -0
- package/Runtime/MagicTilesCore.asmdef +24 -0
- package/Runtime/MagicTilesCore.asmdef.meta +7 -0
- package/Runtime/MoodChange/AdjustHue.ComponentInfo.cs +12 -0
- package/Runtime/MoodChange/AdjustHue.ComponentInfo.cs.meta +3 -0
- package/Runtime/MoodChange/AdjustHue.MaterialInfo.cs +115 -0
- package/Runtime/MoodChange/AdjustHue.MaterialInfo.cs.meta +3 -0
- package/Runtime/MoodChange/AdjustHue.ParticleSystemInfo.cs +36 -0
- package/Runtime/MoodChange/AdjustHue.ParticleSystemInfo.cs.meta +3 -0
- package/Runtime/MoodChange/AdjustHue.SpriteRendererInfo.cs +28 -0
- package/Runtime/MoodChange/AdjustHue.SpriteRendererInfo.cs.meta +3 -0
- package/Runtime/MoodChange/AdjustHue.TrailRendererInfo.cs +37 -0
- package/Runtime/MoodChange/AdjustHue.TrailRendererInfo.cs.meta +3 -0
- package/Runtime/MoodChange/AdjustHue.cs +219 -0
- package/Runtime/MoodChange/AdjustHue.cs.meta +11 -0
- package/Runtime/MoodChange/ColorHueExtensions.cs +227 -0
- package/Runtime/MoodChange/ColorHueExtensions.cs.meta +3 -0
- package/Runtime/MoodChange/HueCache.cs +167 -0
- package/Runtime/MoodChange/HueCache.cs.meta +11 -0
- package/Runtime/MoodChange/MoodChange.cs +52 -0
- package/Runtime/MoodChange/MoodChange.cs.meta +3 -0
- package/Runtime/MoodChange.meta +3 -0
- package/Runtime/Physics/TriggerCallback.cs +21 -0
- package/Runtime/Physics/TriggerCallback.cs.meta +3 -0
- package/Runtime/Physics.meta +8 -0
- package/Runtime/Preset/AudioSourcePlayer/AudioSourcePlayer.cs +153 -0
- package/Runtime/Preset/AudioSourcePlayer/AudioSourcePlayer.cs.meta +11 -0
- package/Runtime/Preset/AudioSourcePlayer/AudioSourcePlayer.prefab +145 -0
- package/Runtime/Preset/AudioSourcePlayer/AudioSourcePlayer.prefab.meta +7 -0
- package/Runtime/Preset/AudioSourcePlayer.meta +8 -0
- package/Runtime/Preset/AudioTimeText/AudioTimeText.cs +22 -0
- package/Runtime/Preset/AudioTimeText/AudioTimeText.cs.meta +11 -0
- package/Runtime/Preset/AudioTimeText/AudioTimeText.prefab +188 -0
- package/Runtime/Preset/AudioTimeText/AudioTimeText.prefab.meta +7 -0
- package/Runtime/Preset/AudioTimeText.meta +8 -0
- package/Runtime/Preset/ParticleSystemPlayer/ParticleSystemPlayer.cs +32 -0
- package/Runtime/Preset/ParticleSystemPlayer/ParticleSystemPlayer.cs.meta +11 -0
- package/Runtime/Preset/ParticleSystemPlayer.meta +8 -0
- package/Runtime/Preset/RendererAlpha.cs +56 -0
- package/Runtime/Preset/RendererAlpha.cs.meta +11 -0
- package/Runtime/Preset/ScoreText/ScoreText.anim +198 -0
- package/Runtime/Preset/ScoreText/ScoreText.anim.meta +8 -0
- package/Runtime/Preset/ScoreText/ScoreText.cs +32 -0
- package/Runtime/Preset/ScoreText/ScoreText.cs.meta +11 -0
- package/Runtime/Preset/ScoreText/ScoreText_2D.prefab +170 -0
- package/Runtime/Preset/ScoreText/ScoreText_2D.prefab.meta +7 -0
- package/Runtime/Preset/ScoreText/ScoreText_3D.prefab +206 -0
- package/Runtime/Preset/ScoreText/ScoreText_3D.prefab.meta +7 -0
- package/Runtime/Preset/ScoreText.meta +8 -0
- package/Runtime/Preset/StartHint/StartHint.cs +26 -0
- package/Runtime/Preset/StartHint/StartHint.cs.meta +3 -0
- package/Runtime/Preset/StartHint.meta +8 -0
- package/Runtime/Preset/WowText/WowText.cs +38 -0
- package/Runtime/Preset/WowText/WowText.cs.meta +3 -0
- package/Runtime/Preset/WowText.meta +8 -0
- package/Runtime/Preset.meta +8 -0
- package/Runtime/Rhythm/Components/Controls.meta +8 -0
- package/Runtime/Rhythm/Components/Helper/CameraFollow.cs +28 -0
- package/Runtime/Rhythm/Components/Helper/CameraFollow.cs.meta +11 -0
- package/Runtime/Rhythm/Components/Helper/MeshSpriteSorter.cs +89 -0
- package/Runtime/Rhythm/Components/Helper/MeshSpriteSorter.cs.meta +11 -0
- package/Runtime/Rhythm/Components/Helper/RecycleLayoutZ.cs +74 -0
- package/Runtime/Rhythm/Components/Helper/RecycleLayoutZ.cs.meta +11 -0
- package/Runtime/Rhythm/Components/Helper.meta +8 -0
- package/Runtime/Rhythm/Components.meta +8 -0
- package/Runtime/Rhythm/Core/GameMode.cs +10 -0
- package/Runtime/Rhythm/Core/GameMode.cs.meta +3 -0
- package/Runtime/Rhythm/Core/IAudioPlayer.cs +16 -0
- package/Runtime/Rhythm/Core/IAudioPlayer.cs.meta +3 -0
- package/Runtime/Rhythm/Core/IRhythmBehaviour.cs +10 -0
- package/Runtime/Rhythm/Core/IRhythmBehaviour.cs.meta +3 -0
- package/Runtime/Rhythm/Core/RhythmBehaviour.cs +57 -0
- package/Runtime/Rhythm/Core/RhythmBehaviour.cs.meta +11 -0
- package/Runtime/Rhythm/Core/RhythmDebug.cs +48 -0
- package/Runtime/Rhythm/Core/RhythmDebug.cs.meta +11 -0
- package/Runtime/Rhythm/Core/RhythmGameT.cs +323 -0
- package/Runtime/Rhythm/Core/RhythmGameT.cs.meta +3 -0
- package/Runtime/Rhythm/Core/RhythmMatch.cs +65 -0
- package/Runtime/Rhythm/Core/RhythmMatch.cs.meta +11 -0
- package/Runtime/Rhythm/Core/RhythmTile.cs +77 -0
- package/Runtime/Rhythm/Core/RhythmTile.cs.meta +3 -0
- package/Runtime/Rhythm/Core/RhythmTileHandler.cs +59 -0
- package/Runtime/Rhythm/Core/RhythmTileHandler.cs.meta +3 -0
- package/Runtime/Rhythm/Core.meta +8 -0
- package/Runtime/Rhythm/Extensions/CollectionExtensions.cs +120 -0
- package/Runtime/Rhythm/Extensions/CollectionExtensions.cs.meta +11 -0
- package/Runtime/Rhythm/Extensions/ColliderExtensions.cs +27 -0
- package/Runtime/Rhythm/Extensions/ColliderExtensions.cs.meta +11 -0
- package/Runtime/Rhythm/Extensions/GameHandlerExtensions.cs +56 -0
- package/Runtime/Rhythm/Extensions/GameHandlerExtensions.cs.meta +11 -0
- package/Runtime/Rhythm/Extensions/GameObjectExtensions.cs +61 -0
- package/Runtime/Rhythm/Extensions/GameObjectExtensions.cs.meta +11 -0
- package/Runtime/Rhythm/Extensions/InputDirectionExtensions.cs +76 -0
- package/Runtime/Rhythm/Extensions/InputDirectionExtensions.cs.meta +11 -0
- package/Runtime/Rhythm/Extensions/MTCListExtensions.cs +127 -0
- package/Runtime/Rhythm/Extensions/MTCListExtensions.cs.meta +11 -0
- package/Runtime/Rhythm/Extensions/MeshRendererExtensions.cs +81 -0
- package/Runtime/Rhythm/Extensions/MeshRendererExtensions.cs.meta +11 -0
- package/Runtime/Rhythm/Extensions/ParticleSystemExtensions.cs +54 -0
- package/Runtime/Rhythm/Extensions/ParticleSystemExtensions.cs.meta +11 -0
- package/Runtime/Rhythm/Extensions.meta +8 -0
- package/Runtime/Rhythm/Game/MTCSongAutoStart.cs +40 -0
- package/Runtime/Rhythm/Game/MTCSongAutoStart.cs.meta +11 -0
- package/Runtime/Rhythm/Game/RhythmConfig.cs +68 -0
- package/Runtime/Rhythm/Game/RhythmConfig.cs.meta +11 -0
- package/Runtime/Rhythm/Game/RhythmContext.Api.cs +533 -0
- package/Runtime/Rhythm/Game/RhythmContext.Api.cs.meta +11 -0
- package/Runtime/Rhythm/Game/RhythmContext.Dev.cs +121 -0
- package/Runtime/Rhythm/Game/RhythmContext.Dev.cs.meta +11 -0
- package/Runtime/Rhythm/Game/RhythmContext.Initialization.cs +114 -0
- package/Runtime/Rhythm/Game/RhythmContext.Initialization.cs.meta +11 -0
- package/Runtime/Rhythm/Game/RhythmContext.Runtime.cs +126 -0
- package/Runtime/Rhythm/Game/RhythmContext.Runtime.cs.meta +11 -0
- package/Runtime/Rhythm/Game/RhythmContext.State.cs +221 -0
- package/Runtime/Rhythm/Game/RhythmContext.State.cs.meta +11 -0
- package/Runtime/Rhythm/Game/RhythmContext.Tile.cs +90 -0
- package/Runtime/Rhythm/Game/RhythmContext.Tile.cs.meta +11 -0
- package/Runtime/Rhythm/Game/RhythmContext.TimeMachine.cs +315 -0
- package/Runtime/Rhythm/Game/RhythmContext.TimeMachine.cs.meta +11 -0
- package/Runtime/Rhythm/Game/RhythmContext.cs +312 -0
- package/Runtime/Rhythm/Game/RhythmContext.cs.meta +11 -0
- package/Runtime/Rhythm/Game/RhythmContextExtensions.cs +91 -0
- package/Runtime/Rhythm/Game/RhythmContextExtensions.cs.meta +11 -0
- package/Runtime/Rhythm/Game/Tile/ITileProgress.cs +7 -0
- package/Runtime/Rhythm/Game/Tile/ITileProgress.cs.meta +3 -0
- package/Runtime/Rhythm/Game/Tile/TileContext.cs +194 -0
- package/Runtime/Rhythm/Game/Tile/TileContext.cs.meta +11 -0
- package/Runtime/Rhythm/Game/Tile.meta +3 -0
- package/Runtime/Rhythm/Game.meta +3 -0
- package/Runtime/Rhythm/Math/Parabol.cs +35 -0
- package/Runtime/Rhythm/Math/Parabol.cs.meta +11 -0
- package/Runtime/Rhythm/Math.meta +8 -0
- package/Runtime/Rhythm/System/Event/GameEvent.cs +82 -0
- package/Runtime/Rhythm/System/Event/GameEvent.cs.meta +3 -0
- package/Runtime/Rhythm/System/Event.meta +8 -0
- package/Runtime/Rhythm/System/Meta/MetaLogic.cs +121 -0
- package/Runtime/Rhythm/System/Meta/MetaLogic.cs.meta +11 -0
- package/Runtime/Rhythm/System/Meta/VisualSpeedMeta.cs +132 -0
- package/Runtime/Rhythm/System/Meta/VisualSpeedMeta.cs.meta +11 -0
- package/Runtime/Rhythm/System/Meta.meta +8 -0
- package/Runtime/Rhythm/System/SongData/ListSongNote.cs +45 -0
- package/Runtime/Rhythm/System/SongData/ListSongNote.cs.meta +3 -0
- package/Runtime/Rhythm/System/SongData.meta +8 -0
- package/Runtime/Rhythm/System/StateMachine/RhythmStateMachine.State.cs +22 -0
- package/Runtime/Rhythm/System/StateMachine/RhythmStateMachine.State.cs.meta +11 -0
- package/Runtime/Rhythm/System/StateMachine/RhythmStateMachine.cs +138 -0
- package/Runtime/Rhythm/System/StateMachine/RhythmStateMachine.cs.meta +11 -0
- package/Runtime/Rhythm/System/StateMachine.meta +8 -0
- package/Runtime/Rhythm/System/TimeKnot/ListTimeKnots.cs +135 -0
- package/Runtime/Rhythm/System/TimeKnot/ListTimeKnots.cs.meta +11 -0
- package/Runtime/Rhythm/System/TimeKnot.meta +8 -0
- package/Runtime/Rhythm/System/TimeMachine/MTCTimeInterpolator.cs +365 -0
- package/Runtime/Rhythm/System/TimeMachine/MTCTimeInterpolator.cs.meta +11 -0
- package/Runtime/Rhythm/System/TimeMachine/MTCTimeMachine.TimeMarker.cs +107 -0
- package/Runtime/Rhythm/System/TimeMachine/MTCTimeMachine.TimeMarker.cs.meta +3 -0
- package/Runtime/Rhythm/System/TimeMachine/MTCTimeMachine.TimeNode.cs +14 -0
- package/Runtime/Rhythm/System/TimeMachine/MTCTimeMachine.TimeNode.cs.meta +3 -0
- package/Runtime/Rhythm/System/TimeMachine/MTCTimeMachine.TimeSpanNode.cs +21 -0
- package/Runtime/Rhythm/System/TimeMachine/MTCTimeMachine.TimeSpanNode.cs.meta +3 -0
- package/Runtime/Rhythm/System/TimeMachine/MTCTimeMachine.ZLaneSpeed.cs +28 -0
- package/Runtime/Rhythm/System/TimeMachine/MTCTimeMachine.ZLaneSpeed.cs.meta +3 -0
- package/Runtime/Rhythm/System/TimeMachine/MTCTimeMachine.cs +131 -0
- package/Runtime/Rhythm/System/TimeMachine/MTCTimeMachine.cs.meta +11 -0
- package/Runtime/Rhythm/System/TimeMachine.meta +8 -0
- package/Runtime/Rhythm/System/VisualKnot/VisualKnotLogic.cs +160 -0
- package/Runtime/Rhythm/System/VisualKnot/VisualKnotLogic.cs.meta +11 -0
- package/Runtime/Rhythm/System/VisualKnot.meta +8 -0
- package/Runtime/Rhythm/System/VisualWarp/IVisualWarp.cs +10 -0
- package/Runtime/Rhythm/System/VisualWarp/IVisualWarp.cs.meta +11 -0
- package/Runtime/Rhythm/System/VisualWarp/LinearVisualWarp.cs +27 -0
- package/Runtime/Rhythm/System/VisualWarp/LinearVisualWarp.cs.meta +11 -0
- package/Runtime/Rhythm/System/VisualWarp.meta +8 -0
- package/Runtime/Rhythm/System.meta +8 -0
- package/Runtime/Rhythm.meta +8 -0
- package/Runtime.meta +8 -0
- package/package.json +12 -0
- package/package.json.meta +7 -0
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
using System;
|
|
2
|
+
using System.Collections.Generic;
|
|
3
|
+
using Amanotes.Core;
|
|
4
|
+
using UnityEngine;
|
|
5
|
+
using static Amanotes.Core.RhythmJson;
|
|
6
|
+
|
|
7
|
+
#if UNITY_EDITOR
|
|
8
|
+
using UnityEditor;
|
|
9
|
+
#endif
|
|
10
|
+
|
|
11
|
+
namespace Amanotes.MagicTilesCore
|
|
12
|
+
{
|
|
13
|
+
public struct KnotData
|
|
14
|
+
{
|
|
15
|
+
public VisualKnot prevKnot;
|
|
16
|
+
public VisualKnot nextKnot;
|
|
17
|
+
public float progress;
|
|
18
|
+
public int activeNoteIndex;
|
|
19
|
+
public Vector3 warpedPosition;
|
|
20
|
+
public Quaternion warpedRotation;
|
|
21
|
+
public bool knotChanged;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
[CreateAssetMenu(menuName = "Rhythm/Context")]
|
|
25
|
+
public partial class RhythmContext : ScriptableObject
|
|
26
|
+
{
|
|
27
|
+
[SerializeField] internal RhythmConfig _config;
|
|
28
|
+
[SerializeField] internal ListSongNote _songNotes;
|
|
29
|
+
[SerializeField] internal List<ScriptableObject> _gameConfigs = new List<ScriptableObject>();
|
|
30
|
+
[SerializeField] public bool isAutoPlay;
|
|
31
|
+
|
|
32
|
+
// Editor state - persistent across edit/play mode
|
|
33
|
+
[SerializeField] internal int _editorSelectedTab = 0;
|
|
34
|
+
|
|
35
|
+
[NonSerialized] internal bool _isReady;
|
|
36
|
+
[NonSerialized] internal bool _constantSpeed = true;
|
|
37
|
+
[NonSerialized] internal bool _hasInitialized = false;
|
|
38
|
+
[NonSerialized] internal bool _hasSongLoaded = false;
|
|
39
|
+
|
|
40
|
+
[NonSerialized] private VisualSpeedMeta visualSpeedMeta;
|
|
41
|
+
[NonSerialized] public readonly VisualKnotLogic visualKnotLogic = new VisualKnotLogic();
|
|
42
|
+
[NonSerialized] private readonly List<VisualKnot> _tempKnots = new List<VisualKnot>();
|
|
43
|
+
|
|
44
|
+
public RhythmConfig config => _config;
|
|
45
|
+
public ListSongNote songNotes => _songNotes;
|
|
46
|
+
|
|
47
|
+
// Config property getters
|
|
48
|
+
public float touchLatency => _config.touchLatency;
|
|
49
|
+
public float deviceAudioLatency => _config.deviceAudioLatency;
|
|
50
|
+
public float noteGenerate_bufferTime => _config.noteGenerate_bufferTime;
|
|
51
|
+
public float noteDispose_delayTime => _config.noteDispose_delayTime;
|
|
52
|
+
public float loopPrepareTime => _config.loopPrepareTime;
|
|
53
|
+
public float rewindingDuration => _config.rewindingDuration;
|
|
54
|
+
public float gameDepartTime => _config.gameDepartTime;
|
|
55
|
+
public float endingBufferTime => _config.endingBufferTime;
|
|
56
|
+
public float mp3Offset => _config.mp3Offset;
|
|
57
|
+
public float audioSpeed;
|
|
58
|
+
public int nLanes => _config.nLanes;
|
|
59
|
+
public bool isAutoRewind => _config.isAutoRewind;
|
|
60
|
+
|
|
61
|
+
public List<string> excludeFromAutoPlay => _config.excludeFromAutoPlay;
|
|
62
|
+
public PoolGroup tilePoolGroup => _config.tilePoolGroup;
|
|
63
|
+
public PoolGroup vfxPoolGroup => _config.vfxPoolGroup;
|
|
64
|
+
public List<RhythmDebug.TagConfig> debugTags => _config.debugTags;
|
|
65
|
+
|
|
66
|
+
public float visualSpeed
|
|
67
|
+
{
|
|
68
|
+
get
|
|
69
|
+
{
|
|
70
|
+
if (_constantSpeed) return config.visualSpeed;
|
|
71
|
+
return ((VisualSpeedMeta.Info)visualSpeedMeta.currentMeta)?.speed ?? 1f;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
[NonSerialized] public readonly RhythmStateMachine stateMachine = new RhythmStateMachine();
|
|
76
|
+
[NonSerialized] public RhythmGame game;
|
|
77
|
+
[NonSerialized] public IPrefabPool prefabPool;
|
|
78
|
+
[NonSerialized] public IAudioPlayer audioPlayer;
|
|
79
|
+
[NonSerialized] public RhythmMatch matchData;
|
|
80
|
+
[NonSerialized] public Dictionary<string, MetaLogic> gameMetas = new Dictionary<string, MetaLogic>();
|
|
81
|
+
[NonSerialized] public List<(string key, string value)> forceCreationMetas = new List<(string key, string value)>();
|
|
82
|
+
[NonSerialized] public bool fakeMode;
|
|
83
|
+
[NonSerialized] public int _forceMissNote = 0;
|
|
84
|
+
[NonSerialized] public int _forceWrongNote = 0;
|
|
85
|
+
|
|
86
|
+
[NonSerialized] public float audioDuration;
|
|
87
|
+
[NonSerialized] public IVisualWarp visualWarp;
|
|
88
|
+
|
|
89
|
+
public Transform tileParent => game?.tileParent ?? game?.transform;
|
|
90
|
+
|
|
91
|
+
public Action OnGameInit, OnLoadingSong, OnSongLoaded;
|
|
92
|
+
public Action OnGamePrepare, OnGameReady, OnGameStart, OnGameStop;
|
|
93
|
+
public Action OnGamePause, OnGamePlay, OnGameDie, OnGameRevive;
|
|
94
|
+
public Action OnGameEnd, OnGameEndRound, OnGameReset, OnGameRewind, OnGameShutdown;
|
|
95
|
+
public Action OnGameNotReady, OnViewSizeChange, OnTileSpawn;
|
|
96
|
+
public Action<TileContext> OnTileMissed, OnWrongLaneTap, OnTileStatusChange;
|
|
97
|
+
public Action<string> OnGameStateChange;
|
|
98
|
+
public Action<float> OnGameProgress, OnVisualSpeedChange;
|
|
99
|
+
#if SNAPBEAT
|
|
100
|
+
public Action<GameMode> OnGameModeChange;
|
|
101
|
+
#endif
|
|
102
|
+
public Action<int> OnGameScoreChange;
|
|
103
|
+
public Action OnGameConfigChange;
|
|
104
|
+
public Action<string, string> OnMetaChanged;
|
|
105
|
+
public Action OnPrepareData, OnInit;
|
|
106
|
+
public Action<float> OnBeforeSeek, OnAfterSeek;
|
|
107
|
+
public Action OnInitDone;
|
|
108
|
+
public Action<VisualKnot, VisualKnot> OnKnotChanged;
|
|
109
|
+
public Action<int> OnActiveNoteChanged;
|
|
110
|
+
|
|
111
|
+
[NonSerialized] private KnotData _knotData;
|
|
112
|
+
|
|
113
|
+
public KnotData knotData => _knotData;
|
|
114
|
+
|
|
115
|
+
public (SongNote, TileContext) GetNoteDetail(int noteIdx)
|
|
116
|
+
{
|
|
117
|
+
var songNote = songNotes.GetNoteAt(noteIdx);
|
|
118
|
+
if (songNote == null)
|
|
119
|
+
{
|
|
120
|
+
Debug.LogWarning("Invalid touch: SongNote not found <" + noteIdx + ">");
|
|
121
|
+
return (null, null);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
var tile = GetTileContext(noteIdx);
|
|
125
|
+
if (tile == null)
|
|
126
|
+
{
|
|
127
|
+
Debug.LogWarning("Invalid touch: TileContext not found <" + noteIdx + ">");
|
|
128
|
+
return (songNote, null);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
return (songNote, tile);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
public float GetTimeDistanceToNote(int noteIndex)
|
|
135
|
+
{
|
|
136
|
+
var note = songNotes.GetNoteAt(noteIndex);
|
|
137
|
+
if (note == null) return 0f;
|
|
138
|
+
return GetTimeDistanceToTimeAppear(note.time);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
public float GetTimeDistanceToNote(SongNote note)
|
|
142
|
+
{
|
|
143
|
+
return GetTimeDistanceToTimeAppear(note.time);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
public float GetTimeDistanceToTimeAppear(float timeAppear)
|
|
147
|
+
{
|
|
148
|
+
return timeAppear - (gameTime - gameDepartTime);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
public float GetPositionDistanceToNote(int index)
|
|
152
|
+
=> GetPositionDistanceToNote(songNotes.GetNoteAt(index));
|
|
153
|
+
|
|
154
|
+
public float GetPositionDistanceToNote(SongNote note)
|
|
155
|
+
{
|
|
156
|
+
var currentPos = GetDistanceAtTime(gameTime - gameDepartTime);
|
|
157
|
+
return note.position - currentPos;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
public void ResetListeners()
|
|
161
|
+
{
|
|
162
|
+
OnGameProgress = null;
|
|
163
|
+
OnGameStateChange = null;
|
|
164
|
+
OnViewSizeChange = null;
|
|
165
|
+
OnTileStatusChange = null;
|
|
166
|
+
#if SNAPBEAT
|
|
167
|
+
OnGameModeChange = null;
|
|
168
|
+
#endif
|
|
169
|
+
OnGameConfigChange = null;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/// <summary>
|
|
173
|
+
/// INTERNAL: Initializes core game systems (matchData, prefabPool) during engine setup.
|
|
174
|
+
/// Called once during initialization by InitializeCoroutine().
|
|
175
|
+
/// External code should NOT call this - use InitGame() + SetupSong() instead.
|
|
176
|
+
/// For gameplay reset, use StopGame() which returns to PREPARE state.
|
|
177
|
+
/// </summary>
|
|
178
|
+
internal void InitializeCoreSystems()
|
|
179
|
+
{
|
|
180
|
+
if (game == null)
|
|
181
|
+
{
|
|
182
|
+
Debug.LogWarning("InitializeCoreSystems called but game is null");
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
matchData = game.CreateMatchData();
|
|
187
|
+
matchData.Init(this);
|
|
188
|
+
|
|
189
|
+
if (prefabPool != null)
|
|
190
|
+
{
|
|
191
|
+
prefabPool.RegisterGroup(tilePoolGroup, tileParent);
|
|
192
|
+
prefabPool.RegisterGroup(vfxPoolGroup, tileParent);
|
|
193
|
+
game.StartCoroutine(prefabPool.Initialize());
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
OnGameReset?.Invoke();
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
[Obsolete("Use InitializeCoreSystems() for clarity")]
|
|
200
|
+
public void ResetGame() => InitializeCoreSystems();
|
|
201
|
+
|
|
202
|
+
public (VisualKnot prevKnot, VisualKnot nextKnot, float percent) GetKnotInfo(float time)
|
|
203
|
+
=> visualKnotLogic.InterpolateKnot(time);
|
|
204
|
+
|
|
205
|
+
public void ClearAllData()
|
|
206
|
+
{
|
|
207
|
+
stateMachine.Clear();
|
|
208
|
+
|
|
209
|
+
OnGameInit = null;
|
|
210
|
+
OnLoadingSong = null;
|
|
211
|
+
OnSongLoaded = null;
|
|
212
|
+
OnGamePrepare = null;
|
|
213
|
+
OnGameReady = null;
|
|
214
|
+
OnGameNotReady = null;
|
|
215
|
+
OnGameStart = null;
|
|
216
|
+
OnGameStop = null;
|
|
217
|
+
OnGamePlay = null;
|
|
218
|
+
OnGamePause = null;
|
|
219
|
+
OnGameDie = null;
|
|
220
|
+
OnGameRewind = null;
|
|
221
|
+
OnGameRevive = null;
|
|
222
|
+
OnGameEnd = null;
|
|
223
|
+
OnGameEndRound = null;
|
|
224
|
+
OnGameReset = null;
|
|
225
|
+
OnGameShutdown = null; // Added missing event
|
|
226
|
+
|
|
227
|
+
// Progress and state events
|
|
228
|
+
OnGameProgress = null; // Added missing event
|
|
229
|
+
OnGameStateChange = null; // Added missing event
|
|
230
|
+
OnViewSizeChange = null;
|
|
231
|
+
OnGameRewind = null;
|
|
232
|
+
OnGameShutdown = null;
|
|
233
|
+
#if SNAPBEAT
|
|
234
|
+
OnGameModeChange = null;
|
|
235
|
+
#endif
|
|
236
|
+
OnGameScoreChange = null;
|
|
237
|
+
OnGameConfigChange = null;
|
|
238
|
+
OnVisualSpeedChange = null;
|
|
239
|
+
OnMetaChanged = null;
|
|
240
|
+
|
|
241
|
+
// Tile events
|
|
242
|
+
OnTileSpawn = null;
|
|
243
|
+
OnTileStatusChange = null;
|
|
244
|
+
OnTileMissed = null;
|
|
245
|
+
OnWrongLaneTap = null;
|
|
246
|
+
|
|
247
|
+
// Knot tracking events
|
|
248
|
+
OnKnotChanged = null; // Added missing event
|
|
249
|
+
OnActiveNoteChanged = null; // Added missing event
|
|
250
|
+
|
|
251
|
+
// Init events
|
|
252
|
+
OnPrepareData = null;
|
|
253
|
+
OnInit = null;
|
|
254
|
+
OnInitDone = null;
|
|
255
|
+
OnBeforeSeek = null;
|
|
256
|
+
OnAfterSeek = null;
|
|
257
|
+
|
|
258
|
+
if (tm != null)
|
|
259
|
+
{
|
|
260
|
+
tm.ResetAndClear();
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
DetachAll();
|
|
264
|
+
gameMetas.Clear();
|
|
265
|
+
|
|
266
|
+
if (audioPlayer != null)
|
|
267
|
+
{
|
|
268
|
+
audioPlayer.Pause();
|
|
269
|
+
audioPlayer.Seek(0);
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
game = null;
|
|
273
|
+
prefabPool = null;
|
|
274
|
+
audioPlayer = null;
|
|
275
|
+
matchData = null;
|
|
276
|
+
visualSpeedMeta = null;
|
|
277
|
+
visualKnotLogic.Clear();
|
|
278
|
+
|
|
279
|
+
// Temp
|
|
280
|
+
_firstActive = null;
|
|
281
|
+
_isPlaying = false;
|
|
282
|
+
_isRewinding = false;
|
|
283
|
+
_rewindTimeElapse = 0f;
|
|
284
|
+
_rewindStartTime = 0f;
|
|
285
|
+
_rewindEndTime = 0f;
|
|
286
|
+
_rewindToNoteIndex = -1;
|
|
287
|
+
|
|
288
|
+
_wasAutoPlay = false;
|
|
289
|
+
_constantSpeed = true;
|
|
290
|
+
_isReady = false;
|
|
291
|
+
_hasInitialized = false;
|
|
292
|
+
_hasSongLoaded = false;
|
|
293
|
+
#if SNAPBEAT
|
|
294
|
+
_gameMode = GameMode.Play;
|
|
295
|
+
#endif
|
|
296
|
+
_isInitialized = false;
|
|
297
|
+
|
|
298
|
+
config.context = null;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
#if UNITY_EDITOR
|
|
302
|
+
private void OnValidate()
|
|
303
|
+
{
|
|
304
|
+
if (PrefabUtility.IsPartOfPrefabAsset(this)) return;
|
|
305
|
+
if (!UnityEditor.EditorApplication.isPlayingOrWillChangePlaymode && UnityEditor.EditorApplication.isPlaying)
|
|
306
|
+
{
|
|
307
|
+
ClearAllData();
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
#endif
|
|
311
|
+
}
|
|
312
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
using System.Collections.Generic;
|
|
2
|
+
using System.Linq;
|
|
3
|
+
using UnityEngine;
|
|
4
|
+
|
|
5
|
+
using static Amanotes.Core.RhythmJson;
|
|
6
|
+
namespace Amanotes.MagicTilesCore
|
|
7
|
+
{
|
|
8
|
+
public static class RhythmContextExtensions
|
|
9
|
+
{
|
|
10
|
+
internal static void SafeSeek(this IAudioPlayer audioPlayer, float time, bool autoPlayPause = true)
|
|
11
|
+
{
|
|
12
|
+
if (audioPlayer == null)
|
|
13
|
+
{
|
|
14
|
+
Debug.LogWarning("SafeSeek: AudioPlayer is null");
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
float duration = audioPlayer.audioDuration;
|
|
19
|
+
if (duration <= 0)
|
|
20
|
+
{
|
|
21
|
+
Debug.LogWarning($"SafeSeek: Cannot seek when audio duration is {duration}. Audio may not be loaded.");
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
float clampedTime = Mathf.Clamp(time, 0, duration);
|
|
26
|
+
RhythmContext.LogAudio($"SafeSeek: Seeking to time {time:F3}s (clamped to {clampedTime:F3}s, duration: {duration:F3}s)");
|
|
27
|
+
|
|
28
|
+
try
|
|
29
|
+
{
|
|
30
|
+
audioPlayer.Seek(clampedTime);
|
|
31
|
+
}
|
|
32
|
+
catch (System.Exception ex)
|
|
33
|
+
{
|
|
34
|
+
Debug.LogError($"SafeSeek: Failed to seek to time {clampedTime:F3}s. Error: {ex.Message}");
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (autoPlayPause == false) return;
|
|
39
|
+
|
|
40
|
+
if (time <= 0 || time >= duration)
|
|
41
|
+
{
|
|
42
|
+
RhythmContext.LogAudio($"SafeSeek: Pausing audio (time {time:F3}s out of bounds [0, {duration:F3}])");
|
|
43
|
+
audioPlayer.Pause();
|
|
44
|
+
}
|
|
45
|
+
else
|
|
46
|
+
{
|
|
47
|
+
if (!audioPlayer.isPlaying)
|
|
48
|
+
{
|
|
49
|
+
RhythmContext.LogAudio($"SafeSeek: Starting audio playback");
|
|
50
|
+
audioPlayer.Play();
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
internal static void TransitionToPlayMode(this RhythmContext context)
|
|
56
|
+
{
|
|
57
|
+
#if SNAPBEAT
|
|
58
|
+
if (context.IsEditMode)
|
|
59
|
+
{
|
|
60
|
+
context.CurrentGameMode = GameMode.Play;
|
|
61
|
+
if (context.audioPlayer != null) context.audioPlayer.Seek(Mathf.Max(0, context.audioSeekTime));
|
|
62
|
+
}
|
|
63
|
+
#endif
|
|
64
|
+
|
|
65
|
+
context._firstActive = null;
|
|
66
|
+
context.UpdateAllTileStatus();
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
private static readonly List<(SongNote note,TileContext tile)> updateList = new List<(SongNote,TileContext)>();
|
|
70
|
+
internal static void UpdateAllTileStatus(this RhythmContext context)
|
|
71
|
+
{
|
|
72
|
+
updateList.Clear();
|
|
73
|
+
|
|
74
|
+
// Optimized: Direct iteration instead of LINQ for better performance
|
|
75
|
+
foreach (var kvp in context.tileMap)
|
|
76
|
+
{
|
|
77
|
+
var note = context.songNotes.GetNoteAt(kvp.Key);
|
|
78
|
+
if (note != null)
|
|
79
|
+
{
|
|
80
|
+
updateList.Add((note, kvp.Value));
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
for (var i = 0; i < updateList.Count; i++)
|
|
85
|
+
{
|
|
86
|
+
var item = updateList[i];
|
|
87
|
+
context.UpdateNoteStatusFromTime(item.tile, item.note);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
using System;
|
|
2
|
+
using System.Collections.Generic;
|
|
3
|
+
using UnityEngine;
|
|
4
|
+
|
|
5
|
+
using static Amanotes.Core.RhythmJson;
|
|
6
|
+
namespace Amanotes.MagicTilesCore
|
|
7
|
+
{
|
|
8
|
+
public enum TileStatus
|
|
9
|
+
{
|
|
10
|
+
None,
|
|
11
|
+
Touching,
|
|
12
|
+
End,
|
|
13
|
+
Missed,
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
public sealed class TileContext
|
|
18
|
+
{
|
|
19
|
+
public readonly int index;
|
|
20
|
+
public readonly SongNote note;
|
|
21
|
+
public readonly RhythmContext context;
|
|
22
|
+
public readonly float slideLength;
|
|
23
|
+
public readonly List<VisualKnot> knots = new List<VisualKnot>();
|
|
24
|
+
|
|
25
|
+
public TileContext(int index, SongNote note, RhythmContext context)
|
|
26
|
+
{
|
|
27
|
+
this.index = index;
|
|
28
|
+
this.note = note;
|
|
29
|
+
this.context = context;
|
|
30
|
+
slideLength = context.config.GetSlideLength(note);
|
|
31
|
+
|
|
32
|
+
context.visualKnotLogic.ExtractKnotsByNoteIdx(knots, index);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
public float GetKnotProgressAtTime(float time)
|
|
36
|
+
{
|
|
37
|
+
if (knots.Count == 0) return 0f;
|
|
38
|
+
if (knots.Count == 1) return 0f;
|
|
39
|
+
|
|
40
|
+
// If time is before first knot, return 0
|
|
41
|
+
if (time <= knots[0].time) return 0f;
|
|
42
|
+
|
|
43
|
+
// If time is after last knot, return last knot index
|
|
44
|
+
if (time >= knots[knots.Count - 1].time) return knots.Count - 1;
|
|
45
|
+
|
|
46
|
+
// Linear search for the knot segment
|
|
47
|
+
for (int i = 0; i < knots.Count - 1; i++)
|
|
48
|
+
{
|
|
49
|
+
var currentKnot = knots[i];
|
|
50
|
+
var nextKnot = knots[i + 1];
|
|
51
|
+
|
|
52
|
+
if (time >= currentKnot.time && time <= nextKnot.time)
|
|
53
|
+
{
|
|
54
|
+
// Calculate progress within this segment
|
|
55
|
+
float segmentDuration = nextKnot.time - currentKnot.time;
|
|
56
|
+
if (segmentDuration <= 0f) return i;
|
|
57
|
+
|
|
58
|
+
float segmentProgress = (time - currentKnot.time) / segmentDuration;
|
|
59
|
+
return i + segmentProgress;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return knots.Count - 1;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
public float? perfectLinePos;
|
|
67
|
+
public float progress = 0f; // For long notes progress tracking
|
|
68
|
+
public float accuracy = -1;
|
|
69
|
+
public float stTouchDiff = -1;
|
|
70
|
+
public float edTouchDiff = -1;
|
|
71
|
+
|
|
72
|
+
public RhythmTile view { get; private set; }
|
|
73
|
+
|
|
74
|
+
public TileContext AttachView()
|
|
75
|
+
{
|
|
76
|
+
if (view != null) return this;
|
|
77
|
+
Status = TileStatus.None;
|
|
78
|
+
RhythmContext.LogTileLifecycle($"AttachView: Getting prefab for tile {index} type '{note.type}'");
|
|
79
|
+
view = context.game.CreateRhythmTile(note);
|
|
80
|
+
if (view == null)
|
|
81
|
+
{
|
|
82
|
+
RhythmContext.LogTileLifecycle($"Failed to get prefab for tile {index} type '{note.type}'");
|
|
83
|
+
Debug.LogWarning($"Unsupported type (no prefab): <{note.type}> | {note.index}");
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
if (view == null) return this;
|
|
87
|
+
view.OnAttach(this);
|
|
88
|
+
view.RefreshTileStatus(); // force refresh tile status
|
|
89
|
+
RhythmContext.LogTileLifecycle($"AttachView: Successfully attached tile {index} type '{note.type}'");
|
|
90
|
+
context.OnTileSpawn?.Invoke();
|
|
91
|
+
return this;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
public void RemoveView()
|
|
95
|
+
{
|
|
96
|
+
if (view == null) return;
|
|
97
|
+
|
|
98
|
+
RhythmContext.LogTileLifecycle($"RemoveView: Detaching tile {index} type '{note.type}'");
|
|
99
|
+
context.Unregister((MonoBehaviour)view);
|
|
100
|
+
view.OnDetach();
|
|
101
|
+
view.tileContext = null;
|
|
102
|
+
context.config.tilePoolGroup.Return(view.gameObject);
|
|
103
|
+
RhythmContext.LogTileLifecycle($"RemoveView: Returned tile {index} to pool");
|
|
104
|
+
view = null;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
public NoteControl endControl
|
|
108
|
+
{
|
|
109
|
+
get
|
|
110
|
+
{
|
|
111
|
+
if (note?.controls == null || note.controls.Count == 0) return null;
|
|
112
|
+
return note.controls[note.controls.Count - 1];
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
public bool hasView => view != null;
|
|
117
|
+
|
|
118
|
+
private TileStatus _status;
|
|
119
|
+
public TileStatus Status
|
|
120
|
+
{
|
|
121
|
+
get => _status;
|
|
122
|
+
set
|
|
123
|
+
{
|
|
124
|
+
if (_status == value) return;
|
|
125
|
+
var oldStatus = _status;
|
|
126
|
+
_status = value;
|
|
127
|
+
RhythmContext.LogTileStatus($"Tile {index}: Status changed from {oldStatus} to {value}");
|
|
128
|
+
|
|
129
|
+
if (_status == TileStatus.None)
|
|
130
|
+
{
|
|
131
|
+
accuracy = -1;
|
|
132
|
+
progress = 0f;
|
|
133
|
+
stTouchDiff = -1;
|
|
134
|
+
edTouchDiff = -1;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
context.OnTileStatusChange?.Invoke(this);
|
|
138
|
+
if (_status == TileStatus.Touching || (_status == TileStatus.End && note.duration > 0))
|
|
139
|
+
{
|
|
140
|
+
context.matchData.CalculateScore(this);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
view.RefreshTileStatus();
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
public void CalculateAutoProgress()
|
|
148
|
+
{
|
|
149
|
+
var note = context.songNotes.GetNoteAt(index);
|
|
150
|
+
float noteStartTime = note.time + context.config.gameDepartTime;
|
|
151
|
+
float noteEndTime = noteStartTime + note.duration;
|
|
152
|
+
float currentTime = context.gameTime;
|
|
153
|
+
|
|
154
|
+
// Calculate progress (0 to 1) based on current game time
|
|
155
|
+
if (currentTime >= noteStartTime && currentTime <= noteEndTime)
|
|
156
|
+
{
|
|
157
|
+
progress = Mathf.Clamp01(FillingProgress);
|
|
158
|
+
}
|
|
159
|
+
else if (currentTime < noteStartTime)
|
|
160
|
+
{
|
|
161
|
+
progress = 0f;
|
|
162
|
+
}
|
|
163
|
+
else if (currentTime > noteEndTime)
|
|
164
|
+
{
|
|
165
|
+
progress = 1f;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
public float FillingProgress
|
|
170
|
+
{
|
|
171
|
+
get
|
|
172
|
+
{
|
|
173
|
+
var note = context.songNotes.GetNoteAt(index);
|
|
174
|
+
if (note.duration <= 0f) return 0f;
|
|
175
|
+
|
|
176
|
+
float noteStartTime = note.time;
|
|
177
|
+
float noteEndTime = noteStartTime + note.duration;
|
|
178
|
+
float currentAudioTime = context.audioTime;
|
|
179
|
+
|
|
180
|
+
// Use VisualSpeedMeta position differences instead of simple time
|
|
181
|
+
float noteStartPos = context.GetDistanceAtTime(noteStartTime);
|
|
182
|
+
float noteEndPos = context.GetDistanceAtTime(noteEndTime);
|
|
183
|
+
float currentPos = context.GetDistanceAtTime(currentAudioTime);
|
|
184
|
+
|
|
185
|
+
float totalDistance = noteEndPos - noteStartPos;
|
|
186
|
+
if (totalDistance <= 0f) return 0f;
|
|
187
|
+
|
|
188
|
+
float currentDistance = currentPos - noteStartPos;
|
|
189
|
+
return currentDistance / totalDistance;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
using System;
|
|
2
|
+
using UnityEngine;
|
|
3
|
+
|
|
4
|
+
[Serializable]
|
|
5
|
+
public class Parabol
|
|
6
|
+
{
|
|
7
|
+
public float g;
|
|
8
|
+
public float v0;
|
|
9
|
+
public float y0;
|
|
10
|
+
|
|
11
|
+
public float GetY(float t)
|
|
12
|
+
{
|
|
13
|
+
return y0 + v0 * t + g * t * t / 2f;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
public float GetVY(float t)
|
|
17
|
+
{
|
|
18
|
+
return v0 + g*t;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
public static Parabol Calculate(float hA, float hB, float hJump)
|
|
22
|
+
{
|
|
23
|
+
var result = new Parabol();
|
|
24
|
+
var hMax = Mathf.Max(hA, hB) + hJump;
|
|
25
|
+
|
|
26
|
+
var h1 = hMax - hA;
|
|
27
|
+
var h2 = hB - hA;
|
|
28
|
+
|
|
29
|
+
result.y0 = hA;
|
|
30
|
+
result.v0 = 2 * h1 + 2 * Mathf.Sqrt(h1 * (h1 - h2));
|
|
31
|
+
result.g = 2 * (h2 - result.v0);
|
|
32
|
+
|
|
33
|
+
return result;
|
|
34
|
+
}
|
|
35
|
+
}
|