app.hypergames.hypersdk 1.10.0 → 1.11.0-beta.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.
Files changed (115) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/Editor/Scripts/Setup/HyperSDKInstaller.cs +42 -0
  3. package/Editor/Scripts/Tools/HyperGameModeMenu.cs +27 -7
  4. package/Runtime/Internal/AssemblyInfo.cs +1 -0
  5. package/Runtime/Internal/Bootstrap/HyperLoader.cs +186 -8
  6. package/Runtime/Internal/Core/HyperRuntime.cs +82 -0
  7. package/Runtime/Internal/Core/HyperRuntimeHost.cs +6 -0
  8. package/Runtime/Internal/Data/URLData.cs +18 -1
  9. package/Runtime/Internal/Managers/BackendManager.cs +281 -24
  10. package/Runtime/Internal/Managers/DataManager.cs +207 -21
  11. package/Runtime/Internal/Managers/GameManager.cs +365 -17
  12. package/Runtime/Internal/Managers/ReplayManager.cs +117 -0
  13. package/Runtime/Internal/Managers/ReplayManager.cs.meta +11 -0
  14. package/Runtime/Internal/Managers/TimeManager.cs +54 -12
  15. package/Runtime/Internal/Replay/ReplayActivityRecorder.cs +182 -0
  16. package/Runtime/Internal/Replay/ReplayActivityRecorder.cs.meta +2 -0
  17. package/Runtime/Internal/Replay/ReplaySessionState.cs +181 -0
  18. package/Runtime/Internal/Replay/ReplaySessionState.cs.meta +2 -0
  19. package/Runtime/Internal/Replay.meta +8 -0
  20. package/Runtime/Internal/ScriptableObjects/HyperSDKSettings.cs +5 -0
  21. package/Runtime/Internal/UI/Animation/LoadingTextAnimation.cs +15 -1
  22. package/Runtime/Internal/UI/Components/ControlBar.cs +25 -2
  23. package/Runtime/Internal/UI/Components/PauseButton.cs +4 -1
  24. package/Runtime/Internal/UI/Components/ReplayController.cs +527 -0
  25. package/Runtime/Internal/UI/Components/ReplayController.cs.meta +2 -0
  26. package/Runtime/Internal/UI/Components/ReplayMarkerPulse.cs +89 -0
  27. package/Runtime/Internal/UI/Components/ReplayMarkerPulse.cs.meta +2 -0
  28. package/Runtime/Internal/UI/Components/ReplayPresentationCanvas.cs +183 -0
  29. package/Runtime/Internal/UI/Components/ReplayPresentationCanvas.cs.meta +2 -0
  30. package/Runtime/Internal/UI/Modals/LoadingFailedModal.cs +12 -0
  31. package/Runtime/Internal/UI/Modals/ReplayOverModal.cs +61 -0
  32. package/Runtime/Internal/UI/Modals/ReplayOverModal.cs.meta +2 -0
  33. package/Runtime/Internal/UI/Modals/StartingInstructionModal.cs +38 -29
  34. package/Runtime/Public/AssemblyInfo.cs +3 -0
  35. package/Runtime/Public/AssemblyInfo.cs.meta +2 -0
  36. package/Runtime/Public/Core/HyperSDK.cs +305 -109
  37. package/Runtime/Public/Hyper.asmdef +2 -1
  38. package/Runtime/Public/Replay/ReplayPlaybackEngine.cs +555 -0
  39. package/Runtime/Public/Replay/ReplayPlaybackEngine.cs.meta +2 -0
  40. package/Runtime/Public/Replay.meta +8 -0
  41. package/Runtime/Resources/Fonts/Nunito/Nunito-Light SDF.asset +528 -521
  42. package/Runtime/Resources/Materials/HyperReplayScanlines.preset +340 -0
  43. package/Runtime/Resources/Materials/HyperReplayScanlines.preset.meta +8 -0
  44. package/Runtime/Resources/Materials/ReplayScanlineOverlay.mat +55 -0
  45. package/Runtime/Resources/Materials/ReplayScanlineOverlay.mat.meta +8 -0
  46. package/Runtime/Resources/Shaders/ReplayScanlineOverlay.shader +150 -0
  47. package/Runtime/Resources/Shaders/ReplayScanlineOverlay.shader.meta +10 -0
  48. package/Runtime/Resources/Sprites/Replays/Fallback avatar.png +0 -0
  49. package/Runtime/Resources/Sprites/Replays/Fallback avatar.png.meta +156 -0
  50. package/Runtime/Resources/Sprites/Replays/Recording.png +0 -0
  51. package/Runtime/Resources/Sprites/Replays/Recording.png.meta +156 -0
  52. package/Runtime/Resources/Sprites/Replays/Replay frame.png +0 -0
  53. package/Runtime/Resources/Sprites/Replays/Replay frame.png.meta +156 -0
  54. package/Runtime/Resources/Sprites/Replays/Replay modal icon.png +0 -0
  55. package/Runtime/Resources/Sprites/Replays/Replay modal icon.png.meta +156 -0
  56. package/Runtime/Resources/Sprites/Replays.meta +8 -0
  57. package/Runtime/Resources/UIPrefabs/ControlBar.prefab +169 -2
  58. package/Runtime/Resources/UIPrefabs/GamePausedModal_Battle.prefab +1 -1
  59. package/Runtime/Resources/UIPrefabs/ReplayController.prefab +1269 -0
  60. package/Runtime/Resources/UIPrefabs/ReplayController.prefab.meta +7 -0
  61. package/Runtime/Resources/UIPrefabs/ReplayInputBlocker.prefab +90 -0
  62. package/Runtime/Resources/UIPrefabs/ReplayInputBlocker.prefab.meta +7 -0
  63. package/Runtime/Resources/UIPrefabs/ReplayOverModal.prefab +958 -0
  64. package/Runtime/Resources/UIPrefabs/ReplayOverModal.prefab.meta +7 -0
  65. package/Runtime/Resources/UIPrefabs/ReplaySeekOverlay.prefab +189 -0
  66. package/Runtime/Resources/UIPrefabs/ReplaySeekOverlay.prefab.meta +7 -0
  67. package/Runtime/Resources/UIPrefabs/SnackBar.prefab +2 -2
  68. package/Runtime/Shared/AssemblyInfo.cs +5 -0
  69. package/Runtime/Shared/AssemblyInfo.cs.meta +11 -0
  70. package/Runtime/Shared/DTOs/Enums.cs +8 -3
  71. package/Runtime/Shared/DTOs/Score/ScoreSnapshot.cs +13 -1
  72. package/Runtime/Shared/Replay/IReplayPlaybackEngine.cs +37 -0
  73. package/Runtime/Shared/Replay/IReplayPlaybackEngine.cs.meta +11 -0
  74. package/Runtime/Shared/Replay.meta +8 -0
  75. package/Samples~/LaneRunner/LaneRunnerSample.unity +1603 -0
  76. package/Samples~/LaneRunner/LaneRunnerSample.unity.meta +7 -0
  77. package/Samples~/LaneRunner/Materials/DoubleScore.mat +86 -0
  78. package/Samples~/LaneRunner/Materials/DoubleScore.mat.meta +8 -0
  79. package/Samples~/LaneRunner/Materials/Ground.mat +84 -0
  80. package/Samples~/LaneRunner/Materials/Ground.mat.meta +8 -0
  81. package/Samples~/LaneRunner/Materials/Lane.mat +84 -0
  82. package/Samples~/LaneRunner/Materials/Lane.mat.meta +8 -0
  83. package/Samples~/LaneRunner/Materials/LaneMarker.mat +84 -0
  84. package/Samples~/LaneRunner/Materials/LaneMarker.mat.meta +8 -0
  85. package/Samples~/LaneRunner/Materials/Obstacle.mat +84 -0
  86. package/Samples~/LaneRunner/Materials/Obstacle.mat.meta +8 -0
  87. package/Samples~/LaneRunner/Materials/Player.mat +84 -0
  88. package/Samples~/LaneRunner/Materials/Player.mat.meta +8 -0
  89. package/Samples~/LaneRunner/Materials.meta +8 -0
  90. package/Samples~/LaneRunner/Prefabs/DoubleScorePickup.prefab +152 -0
  91. package/Samples~/LaneRunner/Prefabs/DoubleScorePickup.prefab.meta +7 -0
  92. package/Samples~/LaneRunner/Prefabs/Obstacle.prefab +152 -0
  93. package/Samples~/LaneRunner/Prefabs/Obstacle.prefab.meta +7 -0
  94. package/Samples~/LaneRunner/Prefabs.meta +8 -0
  95. package/Samples~/LaneRunner/README.md +35 -0
  96. package/Samples~/LaneRunner/README.md.meta +7 -0
  97. package/Samples~/LaneRunner/Scripts/Gameplay/LaneRunnerCommand.cs +9 -0
  98. package/Samples~/LaneRunner/Scripts/Gameplay/LaneRunnerCommand.cs.meta +2 -0
  99. package/Samples~/LaneRunner/Scripts/Gameplay/LaneRunnerGame.cs +93 -0
  100. package/Samples~/LaneRunner/Scripts/Gameplay/LaneRunnerGame.cs.meta +2 -0
  101. package/Samples~/LaneRunner/Scripts/Gameplay/LaneRunnerPlayer.cs +155 -0
  102. package/Samples~/LaneRunner/Scripts/Gameplay/LaneRunnerPlayer.cs.meta +2 -0
  103. package/Samples~/LaneRunner/Scripts/Gameplay/LaneRunnerSpawner.cs +110 -0
  104. package/Samples~/LaneRunner/Scripts/Gameplay/LaneRunnerSpawner.cs.meta +2 -0
  105. package/Samples~/LaneRunner/Scripts/Gameplay/LaneRunnerTrackItem.cs +41 -0
  106. package/Samples~/LaneRunner/Scripts/Gameplay/LaneRunnerTrackItem.cs.meta +2 -0
  107. package/Samples~/LaneRunner/Scripts/Gameplay.meta +8 -0
  108. package/Samples~/LaneRunner/Scripts/Hyper/LaneRunnerReplayAdapter.cs +62 -0
  109. package/Samples~/LaneRunner/Scripts/Hyper/LaneRunnerReplayAdapter.cs.meta +2 -0
  110. package/Samples~/LaneRunner/Scripts/Hyper/LaneRunnerTournamentAdapter.cs +64 -0
  111. package/Samples~/LaneRunner/Scripts/Hyper/LaneRunnerTournamentAdapter.cs.meta +2 -0
  112. package/Samples~/LaneRunner/Scripts/Hyper.meta +8 -0
  113. package/Samples~/LaneRunner/Scripts.meta +8 -0
  114. package/Tests.meta +8 -0
  115. package/package.json +8 -1
@@ -0,0 +1,110 @@
1
+ using System.Collections.Generic;
2
+ using Hyper;
3
+ using UnityEngine;
4
+
5
+ namespace HyperSamples.LaneRunner
6
+ {
7
+ public sealed class LaneRunnerSpawner : MonoBehaviour
8
+ {
9
+ [SerializeField] private GameObject obstaclePrefab;
10
+ [SerializeField] private GameObject doubleScorePrefab;
11
+ [SerializeField] private Transform itemRoot;
12
+ [SerializeField] private float spawnX = 38f;
13
+ [SerializeField] private float despawnX = -8f;
14
+ [SerializeField] private float laneWidth = 2.4f;
15
+ [SerializeField] private float rowSpacing = 10f;
16
+
17
+ private readonly List<LaneRunnerTrackItem> activeItems = new List<LaneRunnerTrackItem>();
18
+ private HyperRandomStream random;
19
+ private LaneRunnerGame game;
20
+ private float distanceToNextRow;
21
+ private int rowIndex;
22
+
23
+ public void Begin(LaneRunnerGame owner)
24
+ {
25
+ game = owner;
26
+ random = HyperRandom.GetContext();
27
+ distanceToNextRow = 8f;
28
+ rowIndex = 0;
29
+ Clear();
30
+
31
+ for (float x = 14f; x <= spawnX; x += rowSpacing)
32
+ SpawnRow(x);
33
+ }
34
+
35
+ public void Tick(float speed, float fixedDeltaTime)
36
+ {
37
+ float distance = speed * fixedDeltaTime;
38
+ distanceToNextRow -= distance;
39
+
40
+ for (int i = activeItems.Count - 1; i >= 0; i--)
41
+ {
42
+ LaneRunnerTrackItem item = activeItems[i];
43
+ if (item == null || item.IsCollected || !item.gameObject.activeSelf)
44
+ {
45
+ RemoveItemAt(i);
46
+ continue;
47
+ }
48
+
49
+ item.Advance(distance);
50
+ if (item.transform.position.x < despawnX)
51
+ RemoveItemAt(i);
52
+ }
53
+
54
+ if (distanceToNextRow > 0f) return;
55
+
56
+ SpawnRow(spawnX);
57
+ distanceToNextRow += rowSpacing;
58
+ }
59
+
60
+ public void Clear()
61
+ {
62
+ for (int i = activeItems.Count - 1; i >= 0; i--)
63
+ {
64
+ if (activeItems[i] != null) Destroy(activeItems[i].gameObject);
65
+ }
66
+ activeItems.Clear();
67
+ }
68
+
69
+ private void SpawnRow(float x)
70
+ {
71
+ int safeLane = random.Range(-1, 2);
72
+ int obstacleCount = random.Range(1, 3);
73
+
74
+ for (int lane = -1; lane <= 1; lane++)
75
+ {
76
+ if (lane == safeLane) continue;
77
+ if (obstacleCount == 1 && lane != ((safeLane + 2) % 3) - 1) continue;
78
+ Spawn(obstaclePrefab, x, lane, 0.75f);
79
+ }
80
+
81
+ if (rowIndex > 0 && rowIndex % 5 == 0)
82
+ Spawn(doubleScorePrefab, x + 2f, safeLane, 1.15f);
83
+
84
+ rowIndex++;
85
+ }
86
+
87
+ private void Spawn(GameObject prefab, float x, int lane, float y)
88
+ {
89
+ if (prefab == null) return;
90
+ GameObject instance = Instantiate(prefab, itemRoot == null ? transform : itemRoot);
91
+ LaneRunnerTrackItem item = instance.GetComponent<LaneRunnerTrackItem>();
92
+ if (item == null)
93
+ {
94
+ Debug.LogWarning($"Lane Runner track prefab '{prefab.name}' is missing LaneRunnerTrackItem.");
95
+ Destroy(instance);
96
+ return;
97
+ }
98
+ item.transform.position = new Vector3(x, y, lane * laneWidth);
99
+ item.Initialize(game);
100
+ activeItems.Add(item);
101
+ }
102
+
103
+ private void RemoveItemAt(int index)
104
+ {
105
+ LaneRunnerTrackItem item = activeItems[index];
106
+ activeItems.RemoveAt(index);
107
+ if (item != null) Destroy(item.gameObject);
108
+ }
109
+ }
110
+ }
@@ -0,0 +1,2 @@
1
+ fileFormatVersion: 2
2
+ guid: 4f207f8c064231944bdb73e8f1bf6298
@@ -0,0 +1,41 @@
1
+ using UnityEngine;
2
+
3
+ namespace HyperSamples.LaneRunner
4
+ {
5
+ [RequireComponent(typeof(Collider))]
6
+ public sealed class LaneRunnerTrackItem : MonoBehaviour
7
+ {
8
+ [SerializeField] private bool doubleScorePickup;
9
+
10
+ public bool IsCollected { get; private set; }
11
+
12
+ private LaneRunnerGame game;
13
+
14
+ public void Initialize(LaneRunnerGame owner)
15
+ {
16
+ game = owner;
17
+ IsCollected = false;
18
+ }
19
+
20
+ public void Advance(float distance)
21
+ {
22
+ transform.position += Vector3.left * distance;
23
+ }
24
+
25
+ private void OnTriggerEnter(Collider other)
26
+ {
27
+ if (IsCollected || other.GetComponent<LaneRunnerPlayer>() == null) return;
28
+
29
+ IsCollected = true;
30
+ if (doubleScorePickup)
31
+ {
32
+ game?.CollectDoubleScore();
33
+ gameObject.SetActive(false);
34
+ }
35
+ else
36
+ {
37
+ game?.HitObstacle();
38
+ }
39
+ }
40
+ }
41
+ }
@@ -0,0 +1,2 @@
1
+ fileFormatVersion: 2
2
+ guid: d30ecc4be65668940a5990199de8c899
@@ -0,0 +1,8 @@
1
+ fileFormatVersion: 2
2
+ guid: 50e9b2fc32d8460fa3865982f0527b1b
3
+ folderAsset: yes
4
+ DefaultImporter:
5
+ externalObjects: {}
6
+ userData:
7
+ assetBundleName:
8
+ assetBundleVariant:
@@ -0,0 +1,62 @@
1
+ using Hyper;
2
+ using UnityEngine;
3
+
4
+ namespace HyperSamples.LaneRunner
5
+ {
6
+ /// <summary>
7
+ /// Maps the game's three commands to compact replay actions. The SDK owns
8
+ /// recording eligibility, timestamps, loading, scheduling and completion.
9
+ /// </summary>
10
+ public sealed class LaneRunnerReplayAdapter : MonoBehaviour
11
+ {
12
+ private const string LeftAction = "Left";
13
+ private const string RightAction = "Right";
14
+ private const string JumpAction = "Jump";
15
+
16
+ [SerializeField] private LaneRunnerPlayer player;
17
+
18
+ private void OnEnable()
19
+ {
20
+ player.CommandApplied += HandleCommandApplied;
21
+ HyperSDK.Replay.OnAction += HandleReplayAction;
22
+ }
23
+
24
+ private void OnDisable()
25
+ {
26
+ player.CommandApplied -= HandleCommandApplied;
27
+ HyperSDK.Replay.OnAction -= HandleReplayAction;
28
+ }
29
+
30
+ private static void HandleCommandApplied(LaneRunnerCommand command)
31
+ {
32
+ switch (command)
33
+ {
34
+ case LaneRunnerCommand.MoveLeft:
35
+ HyperSDK.Data.RecordActivity(LeftAction);
36
+ break;
37
+ case LaneRunnerCommand.MoveRight:
38
+ HyperSDK.Data.RecordActivity(RightAction);
39
+ break;
40
+ case LaneRunnerCommand.Jump:
41
+ HyperSDK.Data.RecordActivity(JumpAction);
42
+ break;
43
+ }
44
+ }
45
+
46
+ private void HandleReplayAction(string action)
47
+ {
48
+ switch (action)
49
+ {
50
+ case LeftAction:
51
+ player.QueueCommand(LaneRunnerCommand.MoveLeft);
52
+ break;
53
+ case RightAction:
54
+ player.QueueCommand(LaneRunnerCommand.MoveRight);
55
+ break;
56
+ case JumpAction:
57
+ player.QueueCommand(LaneRunnerCommand.Jump);
58
+ break;
59
+ }
60
+ }
61
+ }
62
+ }
@@ -0,0 +1,2 @@
1
+ fileFormatVersion: 2
2
+ guid: 992c0965393c18c48b51eb8465bda2ff
@@ -0,0 +1,64 @@
1
+ using Hyper;
2
+ using UnityEngine;
3
+
4
+ namespace HyperSamples.LaneRunner
5
+ {
6
+ /// <summary>
7
+ /// Keeps Hyper tournament concerns outside the core game scripts.
8
+ /// </summary>
9
+ public sealed class LaneRunnerTournamentAdapter : MonoBehaviour
10
+ {
11
+ private const string DoubleScorePowerup = "DoubleScore";
12
+
13
+ [SerializeField] private LaneRunnerGame game;
14
+
15
+ private void OnEnable()
16
+ {
17
+ HyperSDK.Event.OnGameStart += HandleGameStart;
18
+ HyperSDK.Event.OnGameEnded += HandleGameEnded;
19
+ game.ScoreChanged += HandleScoreChanged;
20
+ game.DoubleScoreChanged += HandleDoubleScoreChanged;
21
+ game.GameOverRequested += HandleGameOverRequested;
22
+ }
23
+
24
+ private void OnDisable()
25
+ {
26
+ HyperSDK.Event.OnGameStart -= HandleGameStart;
27
+ HyperSDK.Event.OnGameEnded -= HandleGameEnded;
28
+ game.ScoreChanged -= HandleScoreChanged;
29
+ game.DoubleScoreChanged -= HandleDoubleScoreChanged;
30
+ game.GameOverRequested -= HandleGameOverRequested;
31
+ }
32
+
33
+ private void HandleGameStart()
34
+ {
35
+ game.Begin(!HyperSDK.Game.IsReplayMode);
36
+ }
37
+
38
+ private void HandleGameEnded()
39
+ {
40
+ game.Stop();
41
+ HyperSDK.Data.SetGlobalMultiplier(1f);
42
+ HyperSDK.Data.RemovePowerup(DoubleScorePowerup);
43
+ }
44
+
45
+ private static void HandleScoreChanged(int score)
46
+ {
47
+ HyperSDK.Data.UpdateScore(score);
48
+ }
49
+
50
+ private static void HandleDoubleScoreChanged(bool active)
51
+ {
52
+ HyperSDK.Data.SetGlobalMultiplier(active ? 2f : 1f);
53
+ if (active)
54
+ HyperSDK.Data.AddPowerup(DoubleScorePowerup);
55
+ else
56
+ HyperSDK.Data.RemovePowerup(DoubleScorePowerup);
57
+ }
58
+
59
+ private static void HandleGameOverRequested()
60
+ {
61
+ HyperSDK.Game.EndGame();
62
+ }
63
+ }
64
+ }
@@ -0,0 +1,2 @@
1
+ fileFormatVersion: 2
2
+ guid: 4e31803cf44f24943bc2b44151847e33
@@ -0,0 +1,8 @@
1
+ fileFormatVersion: 2
2
+ guid: 6d279faf270845c6af01e7933573dfd4
3
+ folderAsset: yes
4
+ DefaultImporter:
5
+ externalObjects: {}
6
+ userData:
7
+ assetBundleName:
8
+ assetBundleVariant:
@@ -0,0 +1,8 @@
1
+ fileFormatVersion: 2
2
+ guid: e289c118561207c48b9fdcaa27354c85
3
+ folderAsset: yes
4
+ DefaultImporter:
5
+ externalObjects: {}
6
+ userData:
7
+ assetBundleName:
8
+ assetBundleVariant:
package/Tests.meta ADDED
@@ -0,0 +1,8 @@
1
+ fileFormatVersion: 2
2
+ guid: 450bf3fa27218cc40a3c76492833297c
3
+ folderAsset: yes
4
+ DefaultImporter:
5
+ externalObjects: {}
6
+ userData:
7
+ assetBundleName:
8
+ assetBundleVariant:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "app.hypergames.hypersdk",
3
- "version": "1.10.0",
3
+ "version": "1.11.0-beta.2",
4
4
  "displayName": "HyperSDK",
5
5
  "description": "Official Unity SDK for Hyper: multiplayer battles, leaderboards, deterministic RNG, session management, tutorials, and WebGL optimizations for production-ready games.",
6
6
  "unity": "6000.0",
@@ -31,6 +31,13 @@
31
31
  "type": "git",
32
32
  "url": "https://github.com/mvmhyper/hyper-sdk.git"
33
33
  },
34
+ "samples": [
35
+ {
36
+ "displayName": "Lane Runner",
37
+ "description": "A scene-authored three-lane runner demonstrating score reporting, power-ups, deterministic spawning, and replay integration.",
38
+ "path": "Samples~/LaneRunner"
39
+ }
40
+ ],
34
41
  "dependencies": {
35
42
  "com.unity.nuget.newtonsoft-json": "3.2.1"
36
43
  }