diff --git a/Assets/Scenes/MiniGames/DivingForPictures.unity b/Assets/Scenes/MiniGames/DivingForPictures.unity index 5e06b81d..a02cc54b 100644 --- a/Assets/Scenes/MiniGames/DivingForPictures.unity +++ b/Assets/Scenes/MiniGames/DivingForPictures.unity @@ -989,15 +989,15 @@ PolygonCollider2D: m_AutoTiling: 0 m_Points: m_Paths: - - - {x: 0.39752996, y: 1.9119657} - - {x: 0.5869277, y: 1.9659115} - - {x: 0.5859234, y: 2.273988} - - {x: 0.4216821, y: 2.3394482} - - {x: 0.21658361, y: 2.4846916} - - {x: -0.6874457, y: 2.5082667} - - {x: -0.7884688, y: 2.112848} - - {x: -0.71895736, y: 1.7035886} - - {x: 0.23126324, y: 1.6940142} + - - {x: 0.31323856, y: 1.88323} + - {x: 0.45284468, y: 1.9411527} + - {x: 0.4575874, y: 2.309153} + - {x: 0.33355933, y: 2.3528585} + - {x: 0.21461919, y: 2.444023} + - {x: -0.64820635, y: 2.445795} + - {x: -0.72810775, y: 2.1012561} + - {x: -0.6425891, y: 1.7388015} + - {x: 0.1824453, y: 1.7393905} m_UseDelaunayMesh: 0 --- !u!50 &747976403 Rigidbody2D: @@ -1940,6 +1940,50 @@ MonoBehaviour: ropeDamping: 0.3 initialSeparationDistance: 0.1 initialFallImpulse: 2 +--- !u!1 &1511344833 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1511344835} + - component: {fileID: 1511344834} + m_Layer: 0 + m_Name: DecorationSpawner + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &1511344834 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1511344833} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 711fdad9f8a4ece45aeed22006b3e4f4, type: 3} + m_Name: + m_EditorClassIdentifier: '::' +--- !u!4 &1511344835 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1511344833} + serializedVersion: 2 + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0.65042, y: 3.40914, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 0} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &1679185997 GameObject: m_ObjectHideFlags: 0 @@ -1985,24 +2029,38 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: tilePrefabs: + - {fileID: 2956826569642009690, guid: 423507a5af73a9640b858d93224a2659, type: 3} - {fileID: 2956826569642009690, guid: 9526b05f428f464459def30747966859, type: 3} - - {fileID: 2956826569642009690, guid: f9bab4478abe3d445b1f01a513a2c7e6, type: 3} - - {fileID: 2956826569642009690, guid: 71d7b85ecf91de44b9aa4335a349d8c8, type: 3} - - {fileID: 2956826569642009690, guid: b5fc5929ab94faf42bf9ebfc918a3597, type: 3} - - {fileID: 2956826569642009690, guid: c1e94865d6c6ccf49b342dfb286c7231, type: 3} - - {fileID: 2956826569642009690, guid: 8c90ffd155e124c46a063e1bd76e60fd, type: 3} - - {fileID: 2956826569642009690, guid: 257e799913b77da4cb840a3d799fec3d, type: 3} - - {fileID: 2956826569642009690, guid: be9f1ba3224927d47bdba480c08ff788, type: 3} - - {fileID: 2956826569642009690, guid: a1482a2f9a3028b4b9a3859eda1049c3, type: 3} - - {fileID: 2956826569642009690, guid: c0bbd17f27729404fb8813ad56fd3d8f, type: 3} - - {fileID: 2956826569642009690, guid: c68bd81229be16241bdbd8b6582a8b6d, type: 3} - - {fileID: 2956826569642009690, guid: 5099267fccf4be0478d710de2f3d4b3c, type: 3} - - {fileID: 2956826569642009690, guid: 693abc4534c5b604cb4ad954c57490f7, type: 3} - - {fileID: 2956826569642009690, guid: c9e945fe46bcda34eaf9f6249183e36e, type: 3} - - {fileID: 2956826569642009690, guid: 2c8ff0569f4f59e4a9f8a4f918e524c7, type: 3} - - {fileID: 2956826569642009690, guid: 30f32f6da706b44428c9a104c403b5f7, type: 3} - - {fileID: 2956826569642009690, guid: a3ec47438b74c664ba026bf41f43a368, type: 3} - - {fileID: 2956826569642009690, guid: 95c046aefbdd7a0418e9ea0305e3567c, type: 3} + - {fileID: 2956826569642009690, guid: a3703750ec2f316408a6ff952b40c004, type: 3} + - {fileID: 2956826569642009690, guid: 1b645d98085a76545acaa8db4fb0f7e0, type: 3} + - {fileID: 2956826569642009690, guid: 86b321848a9c3d94d9fd461a4482ac7b, type: 3} + - {fileID: 2956826569642009690, guid: 4575c161d62b1e64e85ca638108e7015, type: 3} + - {fileID: 2956826569642009690, guid: 7f20defacde3de742a72ab659b2eeb56, type: 3} + - {fileID: 2956826569642009690, guid: 40c6d595022652b4bac2563e4f7a3f40, type: 3} + - {fileID: 2956826569642009690, guid: 4ba2e030d29d88b4b935487b793ac77b, type: 3} + - {fileID: 2956826569642009690, guid: 4692f9279f981b34eb596c6c263bec82, type: 3} + - {fileID: 2956826569642009690, guid: b44a4567ae637b3409d34c8b463aaf41, type: 3} + - {fileID: 2956826569642009690, guid: 09a8470180f44c049a1f137e091b5581, type: 3} + - {fileID: 2956826569642009690, guid: 0a73c9b6214318a429f319762ad25b99, type: 3} + - {fileID: 2956826569642009690, guid: 0f9b70cfab4dd454298ce9a509f01a35, type: 3} + - {fileID: 2956826569642009690, guid: 85e400c58e60c47458059c1e24c8576a, type: 3} + - {fileID: 2956826569642009690, guid: b3501bc08c6afbf4f868bc7b6c2a2d92, type: 3} + - {fileID: 2956826569642009690, guid: 4f9c8bd3fb844484492a54a2998b9b3b, type: 3} + - {fileID: 2956826569642009690, guid: bffdeb85669f34642bf4a2245699e5fe, type: 3} + - {fileID: 2956826569642009690, guid: 16ad8a46d2c7c534982f4ee943e06f74, type: 3} + - {fileID: 2956826569642009690, guid: 8011eb55cd0cc9e41bb5f0ac3e749476, type: 3} + - {fileID: 2956826569642009690, guid: 8c34fcc285149844ea77d25f8ad26042, type: 3} + - {fileID: 2956826569642009690, guid: 239014e1a6af07d448d07d40b36cda5b, type: 3} + - {fileID: 2956826569642009690, guid: ebd4f666663e75a4f8639d9a99e0841f, type: 3} + - {fileID: 2956826569642009690, guid: 36d40cc94947da14e8d38dc9a855a2dc, type: 3} + - {fileID: 2956826569642009690, guid: 3b623cd69ef664a4098dd8220420c926, type: 3} + - {fileID: 2956826569642009690, guid: f652b7013c44ca548a1613862f1de933, type: 3} + - {fileID: 2956826569642009690, guid: e4d68f42bb42dff4e8fec1aa575b49ce, type: 3} + - {fileID: 2956826569642009690, guid: 7b786a4d28e8f35428fdbf8e079c6072, type: 3} + - {fileID: 2956826569642009690, guid: 22b8d7a56a4737342a28b2adf4dd4efb, type: 3} + - {fileID: 2956826569642009690, guid: b5777e3dbbd31954fa50a1ad28d7c7fc, type: 3} + - {fileID: 2956826569642009690, guid: 81f9a8e9eaac386488a42675e9ec8aee, type: 3} + initialTilePrefab: {fileID: 2956826569642009690, guid: c6ea8519596514e4dbf0f3e02ce14a2c, type: 3} onTileSpawned: m_PersistentCalls: m_Calls: [] @@ -2012,6 +2070,22 @@ MonoBehaviour: onLastTileLeft: m_PersistentCalls: m_Calls: [] + depthDifficultyRanges: + - minDepth: 0 + maxDepth: 10 + difficulty: 1 + - minDepth: 11 + maxDepth: 20 + difficulty: 2 + - minDepth: 21 + maxDepth: 30 + difficulty: 3 + - minDepth: 31 + maxDepth: 40 + difficulty: 4 + - minDepth: 41 + maxDepth: 2147483647 + difficulty: 5 --- !u!1 &1834056336 GameObject: m_ObjectHideFlags: 0 @@ -2335,3 +2409,4 @@ SceneRoots: - {fileID: 323864665} - {fileID: 461301697} - {fileID: 2064311129} + - {fileID: 1511344835} diff --git a/Assets/Scripts/Core/Settings/DivingDeveloperSettings.cs b/Assets/Scripts/Core/Settings/DivingDeveloperSettings.cs index 69a233d7..39ee51e5 100644 --- a/Assets/Scripts/Core/Settings/DivingDeveloperSettings.cs +++ b/Assets/Scripts/Core/Settings/DivingDeveloperSettings.cs @@ -131,7 +131,7 @@ namespace AppleHills.Core.Settings [SerializeField] private LayerMask playerObstacleLayerMask = -1; [Tooltip("Whether to block player input during damage immunity period")] - [SerializeField] private bool blockInputDuringImmunity = true; + [SerializeField] private bool blockInputDuringImmunity; [Tooltip("Type of bump response: 0=Impulse, 1=SmoothToCenter")] [SerializeField] private BumpMode bumpMode = BumpMode.Impulse; diff --git a/Assets/Scripts/DamianExperiments/Minigame.meta b/Assets/Scripts/DamianExperiments/Minigame.meta new file mode 100644 index 00000000..bbd8a018 --- /dev/null +++ b/Assets/Scripts/DamianExperiments/Minigame.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: c80f2b7cca66f6042809fa08192e8eff +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/DamianExperiments/Minigame/decorationSpawner.cs b/Assets/Scripts/DamianExperiments/Minigame/decorationSpawner.cs new file mode 100644 index 00000000..8cda3189 --- /dev/null +++ b/Assets/Scripts/DamianExperiments/Minigame/decorationSpawner.cs @@ -0,0 +1,16 @@ +using UnityEngine; + +public class decorationSpawner : MonoBehaviour +{ + // Start is called once before the first execution of Update after the MonoBehaviour is created + void Start() + { + + } + + // Update is called once per frame + void Update() + { + + } +} diff --git a/Assets/Scripts/DamianExperiments/Minigame/decorationSpawner.cs.meta b/Assets/Scripts/DamianExperiments/Minigame/decorationSpawner.cs.meta new file mode 100644 index 00000000..f2512e66 --- /dev/null +++ b/Assets/Scripts/DamianExperiments/Minigame/decorationSpawner.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 711fdad9f8a4ece45aeed22006b3e4f4 \ No newline at end of file diff --git a/Assets/Scripts/Minigames/DivingForPictures/Tiles/Tile.cs b/Assets/Scripts/Minigames/DivingForPictures/Tiles/Tile.cs index 14844d35..6a637530 100644 --- a/Assets/Scripts/Minigames/DivingForPictures/Tiles/Tile.cs +++ b/Assets/Scripts/Minigames/DivingForPictures/Tiles/Tile.cs @@ -6,6 +6,29 @@ /// public class Tile : MonoBehaviour { + [Header("Path In")] + public bool pathInLeft; + public bool pathInCenter; + public bool pathInRight; + + [Header("Path Out")] + public bool pathOutLeft; + public bool pathOutCenter; + public bool pathOutRight; + + [Header("Difficulty")] + public int difficultyLevel; // 1 (easy) to 5 (hard) + + // --- FLOATING AREA LOGIC --- + [Header("Middle Obstacle")] + // Indicates if this tile has a floating area in the middle + public bool hasFloatingAreaMiddle; + // Indicates if this tile continues a floating area in the middle + public bool continuesFloatingAreaMiddle; + // Indicates if this tile ends a floating area in the middle + public bool endsFloatingAreaMiddle; + // You can set these in the Inspector for each tile prefab to control floating area behavior + // This is primarily a marker component, but we could add tile-specific properties here if needed // Optional: Add properties that might be useful for all tiles diff --git a/Assets/Scripts/Minigames/DivingForPictures/Tiles/TrenchTileSpawner.cs b/Assets/Scripts/Minigames/DivingForPictures/Tiles/TrenchTileSpawner.cs index 827cd6de..796a276f 100644 --- a/Assets/Scripts/Minigames/DivingForPictures/Tiles/TrenchTileSpawner.cs +++ b/Assets/Scripts/Minigames/DivingForPictures/Tiles/TrenchTileSpawner.cs @@ -18,6 +18,10 @@ namespace Minigames.DivingForPictures [Tooltip("List of possible trench tile prefabs.")] [SerializeField] private List tilePrefabs; + [Header("Initial Tile")] + [Tooltip("Prefab for the initial trench tile. This will always be spawned first.")] + [SerializeField] private GameObject initialTilePrefab; + [Header("Events")] [FormerlySerializedAs("OnTileSpawned")] public UnityEvent onTileSpawned; @@ -67,6 +71,44 @@ namespace Minigames.DivingForPictures // Screen normalization private float _screenNormalizationFactor = 1.0f; + // Tracks if a floating area in the middle is currently active + private bool isFloatingAreaActive = false; + + // Current depth of the trench + private int _currentDepth = 0; + + [System.Serializable] + public struct DepthDifficultyRange + { + public int minDepth; + public int maxDepth; + public int difficulty; + } + + [Header("Difficulty Depths")] + [Tooltip("Configure depth ranges and their corresponding difficulty levels.")] + [SerializeField] private List depthDifficultyRanges = new List + { + new DepthDifficultyRange { minDepth = 0, maxDepth = 10, difficulty = 1 }, + new DepthDifficultyRange { minDepth = 11, maxDepth = 20, difficulty = 2 }, + new DepthDifficultyRange { minDepth = 21, maxDepth = 30, difficulty = 3 }, + new DepthDifficultyRange { minDepth = 31, maxDepth = 40, difficulty = 4 }, + new DepthDifficultyRange { minDepth = 41, maxDepth = int.MaxValue, difficulty = 5 } + }; + + public int CurrentDifficulty + { + get + { + foreach (var range in depthDifficultyRanges) + { + if (_currentDepth >= range.minDepth && _currentDepth <= range.maxDepth) + return range.difficulty; + } + return 1; // Default fallback + } + } + private void Awake() { _mainCamera = Camera.main; @@ -213,7 +255,7 @@ namespace Minigames.DivingForPictures if (prefab == null) { Debug.LogError("Null prefab found in tilePrefabs list!"); - continue; + return; } Renderer renderer = prefab.GetComponentInChildren(); @@ -300,7 +342,14 @@ namespace Minigames.DivingForPictures float prevHeight = GetTileHeight(prevTile); y = prevTile.transform.position.y - prevHeight; } - SpawnTileAtY(y); + if (i == 0 && initialTilePrefab != null) + { + SpawnSpecificTileAtY(initialTilePrefab, y); + } + else + { + SpawnTileAtY(y); + } } } @@ -594,6 +643,89 @@ namespace Minigames.DivingForPictures } } + /// + /// Checks if two tiles are fully compatible for spawning, following clarified floating area rules. + /// + private bool AreTilesFullyCompatible(Tile prev, Tile next) + { + // Path compatibility: at least one path is open in both Out (prev) and In (next) + bool pathCompatible = + (prev.pathOutLeft && next.pathInLeft) || + (prev.pathOutCenter && next.pathInCenter) || + (prev.pathOutRight && next.pathInRight); + + // --- Updated floating area rules --- + // Continue tile: can only spawn after Start, and must be followed by End + if (next.continuesFloatingAreaMiddle) + { + if (!prev.hasFloatingAreaMiddle) + return false; + } + // End tile: can only spawn after Start or Continue + if (next.endsFloatingAreaMiddle) + { + if (!(prev.hasFloatingAreaMiddle || prev.continuesFloatingAreaMiddle)) + return false; + } + // After a Start tile, only Continue or End can follow + if (prev.hasFloatingAreaMiddle) + { + if (!(next.continuesFloatingAreaMiddle || next.endsFloatingAreaMiddle)) + return false; + } + // After a Continue tile, only End can follow + if (prev.continuesFloatingAreaMiddle) + { + if (!next.endsFloatingAreaMiddle) + return false; + } + // Otherwise, normal tiles are always allowed + return pathCompatible; + } + + /// + /// Gets a weighted random index among fully compatible tiles, prioritizing least recently used. + /// + private int GetWeightedCompatibleTileIndex(Tile prevTile) + { + var compatibleIndices = new List(); + int currentDifficulty = CurrentDifficulty; + for (int i = 0; i < tilePrefabs.Count; i++) + { + var candidateGO = tilePrefabs[i]; + var candidate = candidateGO?.GetComponent(); + if (candidate == null) continue; + if (candidate.difficultyLevel > currentDifficulty) continue; + bool compatible = AreTilesFullyCompatible(prevTile, candidate); + if (compatible) + compatibleIndices.Add(i); + } + if (compatibleIndices.Count == 0) + { + Debug.LogError("No compatible tile found for previous tile and current difficulty. Spawning aborted."); + return -1; + } + List weights = new List(compatibleIndices.Count); + foreach (var i in compatibleIndices) + { + int lastUsed = _tileLastUsed.TryGetValue(i, out var value) ? value : -tilePrefabs.Count; + int age = _spawnCounter - lastUsed; + float weight = Mathf.Clamp(age, 1, tilePrefabs.Count * 2); + weights.Add(weight); + } + float totalWeight = 0f; + foreach (var weight in weights) + totalWeight += weight; + float randomValue = Random.value * totalWeight; + for (int idx = 0; idx < compatibleIndices.Count; idx++) + { + if (randomValue < weights[idx]) + return compatibleIndices[idx]; + randomValue -= weights[idx]; + } + return compatibleIndices[Random.Range(0, compatibleIndices.Count)]; + } + /// /// Spawn a new tile at the specified Y position /// @@ -606,7 +738,32 @@ namespace Minigames.DivingForPictures return; } - int prefabIndex = GetWeightedRandomTileIndex(); + int prefabIndex; + // First tile: any tile + if (_activeTiles.Count == 0) + { + prefabIndex = GetWeightedRandomTileIndex(); + } + else + { + GameObject prevTileGO = _activeTiles[_activeTiles.Count - 1]; + Tile prevTile = prevTileGO != null ? prevTileGO.GetComponent() : null; + if (prevTile != null) + { + // Use weighted compatible selection + prefabIndex = GetWeightedCompatibleTileIndex(prevTile); + if (prefabIndex == -1) + { + Debug.LogError("No compatible tile can be spawned after previous tile. Aborting spawn."); + return; + } + } + else + { + prefabIndex = GetWeightedRandomTileIndex(); + } + } + GameObject prefab = tilePrefabs[prefabIndex]; if (prefab == null) { @@ -615,7 +772,6 @@ namespace Minigames.DivingForPictures } GameObject tile; - if (_devSettings != null && _devSettings.TrenchTileUseObjectPooling && _tilePool != null) { tile = _tilePool.GetTile(prefabIndex); @@ -624,12 +780,9 @@ namespace Minigames.DivingForPictures Debug.LogError("Failed to get tile from pool!"); return; } - tile.transform.position = new Vector3(0f, y, TileSpawnZ); tile.transform.rotation = prefab.transform.rotation; tile.transform.SetParent(transform); - - // Set the layer to the configured trench tile layer if (_devSettings != null) { tile.layer = _devSettings.TrenchTileLayer; @@ -638,20 +791,112 @@ namespace Minigames.DivingForPictures } else { - // Use the prefab's original rotation tile = Instantiate(prefab, new Vector3(0f, y, TileSpawnZ), prefab.transform.rotation, transform); - - // Set the layer to the configured trench tile layer if (_devSettings != null) { tile.layer = _devSettings.TrenchTileLayer; SetLayerRecursively(tile, _devSettings.TrenchTileLayer); } } - _activeTiles.Add(tile); _tileLastUsed[prefabIndex] = _spawnCounter++; + _currentDepth++; + Debug.Log($"[TrenchTileSpawner] Current Depth: {_currentDepth}"); onTileSpawned?.Invoke(tile); + + // --- FLOATING AREA STATE MANAGEMENT --- + Tile spawnedTile = tile.GetComponent(); + if (spawnedTile != null) + { + if (spawnedTile.hasFloatingAreaMiddle || spawnedTile.continuesFloatingAreaMiddle) + { + isFloatingAreaActive = true; + } + if (spawnedTile.endsFloatingAreaMiddle) + { + isFloatingAreaActive = false; + } + } + } + + /// + /// Spawn a specific tile at the specified Y position + /// + /// The tile prefab to spawn + /// The Y position to spawn at + private void SpawnSpecificTileAtY(GameObject prefab, float y) + { + GameObject tile; + if (_devSettings != null && _devSettings.TrenchTileUseObjectPooling && _tilePool != null) + { + int prefabIndex = tilePrefabs.IndexOf(prefab); + if (prefabIndex >= 0) + { + tile = _tilePool.GetTile(prefabIndex); + if (tile == null) + { + Debug.LogError("Failed to get initial tile from pool!"); + return; + } + } + else + { + tile = Instantiate(prefab, new Vector3(0f, y, TileSpawnZ), prefab.transform.rotation, transform); + } + tile.transform.position = new Vector3(0f, y, TileSpawnZ); + tile.transform.rotation = prefab.transform.rotation; + tile.transform.SetParent(transform); + if (_devSettings != null) + { + tile.layer = _devSettings.TrenchTileLayer; + SetLayerRecursively(tile, _devSettings.TrenchTileLayer); + } + } + else + { + tile = Instantiate(prefab, new Vector3(0f, y, TileSpawnZ), prefab.transform.rotation, transform); + if (_devSettings != null) + { + tile.layer = _devSettings.TrenchTileLayer; + SetLayerRecursively(tile, _devSettings.TrenchTileLayer); + } + } + _activeTiles.Add(tile); + _currentDepth++; + Debug.Log($"[TrenchTileSpawner] Current Depth: {_currentDepth}"); + onTileSpawned?.Invoke(tile); + // Optionally update floating area state if needed + Tile spawnedTile = tile.GetComponent(); + if (spawnedTile != null) + { + if (spawnedTile.hasFloatingAreaMiddle || spawnedTile.continuesFloatingAreaMiddle) + { + isFloatingAreaActive = true; + } + if (spawnedTile.endsFloatingAreaMiddle) + { + isFloatingAreaActive = false; + } + } + } + + /// + /// Gets a list of allowed tile indices for the current difficulty + /// + /// List of allowed prefab indices + private List GetAllowedTileIndicesForCurrentDifficulty() + { + var allowedIndices = new List(); + int currentDifficulty = CurrentDifficulty; + for (int i = 0; i < tilePrefabs.Count; i++) + { + var tileComponent = tilePrefabs[i]?.GetComponent(); + if (tileComponent != null && tileComponent.difficultyLevel <= currentDifficulty) + { + allowedIndices.Add(i); + } + } + return allowedIndices; } /// @@ -660,14 +905,19 @@ namespace Minigames.DivingForPictures /// The selected prefab index private int GetWeightedRandomTileIndex() { - int prefabCount = tilePrefabs.Count; - List weights = new List(prefabCount); - - for (int i = 0; i < prefabCount; i++) + var allowedIndices = GetAllowedTileIndicesForCurrentDifficulty(); + if (allowedIndices.Count == 0) { - int lastUsed = _tileLastUsed.TryGetValue(i, out var value) ? value : -prefabCount; + Debug.LogError("No allowed tiles for current difficulty!"); + return 0; + } + List weights = new List(allowedIndices.Count); + + for (int i = 0; i < allowedIndices.Count; i++) + { + int lastUsed = _tileLastUsed.TryGetValue(allowedIndices[i], out var value) ? value : -tilePrefabs.Count; int age = _spawnCounter - lastUsed; - float weight = Mathf.Clamp(age, 1, prefabCount * 2); // More unused = higher weight + float weight = Mathf.Clamp(age, 1, tilePrefabs.Count * 2); // More unused = higher weight weights.Add(weight); } @@ -678,16 +928,16 @@ namespace Minigames.DivingForPictures } float randomValue = Random.value * totalWeight; - for (int i = 0; i < prefabCount; i++) + for (int i = 0; i < allowedIndices.Count; i++) { if (randomValue < weights[i]) { - return i; + return allowedIndices[i]; } randomValue -= weights[i]; } - return Random.Range(0, prefabCount); // fallback + return Random.Range(0, allowedIndices.Count); // fallback } /// @@ -1005,13 +1255,13 @@ namespace Minigames.DivingForPictures { StopCoroutine(_speedRampingCoroutine); } - _speedRampingCoroutine = StartCoroutine(SpeedRampingCoroutine()); + _speedRampingCoroutine = StartCoroutine(SpeedRampingRoutine()); } /// /// Coroutine that handles increasing the movement speed over time /// - private IEnumerator SpeedRampingCoroutine() + private IEnumerator SpeedRampingRoutine() { const float checkInterval = 1.0f; // Check once per second as requested Debug.Log($"[TrenchTileSpawner] Started speed ramping coroutine with interval: {checkInterval}s"); diff --git a/Assets/Settings/Developer/DivingDeveloperSettings.asset b/Assets/Settings/Developer/DivingDeveloperSettings.asset index 528ea282..6aab2201 100644 --- a/Assets/Settings/Developer/DivingDeveloperSettings.asset +++ b/Assets/Settings/Developer/DivingDeveloperSettings.asset @@ -37,18 +37,18 @@ MonoBehaviour: playerBlinkDamageColor: {r: 1, g: 0, b: 0, a: 1} playerBlinkRate: 0.15 playerDamageColorAlpha: 0.7 - playerWobbleFrequency: 1.5 - playerBaseWobbleAmplitude: 8 - playerSpeedToAmplitude: 2 - playerMaxRotationLimit: 45 - playerVerticalFrequency: 0.5 + playerWobbleFrequency: 1.2 + playerBaseWobbleAmplitude: 5 + playerSpeedToAmplitude: 1 + playerMaxRotationLimit: 40 + playerVerticalFrequency: 0.4 playerVerticalAmplitude: 0.2 playerVelocitySmoothing: 10 playerRotationSmoothing: 10 playerObstacleLayerMask: serializedVersion: 2 m_Bits: 5120 - blockInputDuringImmunity: 1 + blockInputDuringImmunity: 0 bumpMode: 0 bumpCurve: serializedVersion: 2 diff --git a/Assets/Settings/DivingMinigameSettings.asset b/Assets/Settings/DivingMinigameSettings.asset index aa2700a2..1d7d085e 100644 --- a/Assets/Settings/DivingMinigameSettings.asset +++ b/Assets/Settings/DivingMinigameSettings.asset @@ -12,7 +12,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 0ce4dba7a1c54e73b1b3d7131a1c0570, type: 3} m_Name: DivingMinigameSettings m_EditorClassIdentifier: - lerpSpeed: 2 + lerpSpeed: 6 maxOffset: 10 clampXMin: -3.5 clampXMax: 3.5 @@ -45,7 +45,7 @@ MonoBehaviour: obstacleSpawnCollisionRadius: 1 normalizedObstacleMinMoveSpeed: 1 normalizedObstacleMaxMoveSpeed: 3 - damageImmunityDuration: 1 - bumpForce: 5 + damageImmunityDuration: 2.5 + bumpForce: 2 smoothMoveSpeed: 8 - blockInputDuringBump: 1 + blockInputDuringBump: 0