diff --git a/Assets/Scenes/MiniGames/DivingForPictures.unity b/Assets/Scenes/MiniGames/DivingForPictures.unity
index e30a8a07..ad5edc52 100644
--- a/Assets/Scenes/MiniGames/DivingForPictures.unity
+++ b/Assets/Scenes/MiniGames/DivingForPictures.unity
@@ -2001,7 +2001,7 @@ MonoBehaviour:
- {fileID: 2956826569642009690, guid: 7f7f10ca24a5afe46be797daea64111a, type: 3}
initialTileCount: 3
tileSpawnBuffer: 1
- moveSpeed: 3
+ moveSpeed: 2
speedUpFactor: 0
speedUpInterval: 0
maxMoveSpeed: 12
@@ -2014,6 +2014,7 @@ MonoBehaviour:
onTileDestroyed:
m_PersistentCalls:
m_Calls: []
+ velocityCalculationInterval: 0.5
--- !u!1 &1834056336
GameObject:
m_ObjectHideFlags: 0
diff --git a/Assets/Scripts/Minigames/DivingForPictures/TrenchTileSpawner.cs b/Assets/Scripts/Minigames/DivingForPictures/TrenchTileSpawner.cs
index 7d2bf387..28789276 100644
--- a/Assets/Scripts/Minigames/DivingForPictures/TrenchTileSpawner.cs
+++ b/Assets/Scripts/Minigames/DivingForPictures/TrenchTileSpawner.cs
@@ -1,4 +1,5 @@
-using System.Collections.Generic;
+using System.Collections;
+using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.Serialization;
@@ -48,6 +49,12 @@ namespace Minigames.DivingForPictures
private float _screenBottom;
private float _screenTop;
private TrenchTilePool _tilePool;
+
+ // Current velocity for tile movement
+ private float _currentVelocity;
+
+ // Interval for velocity calculations (seconds)
+ [SerializeField] private float velocityCalculationInterval = 0.5f;
private const float TileSpawnZ = -1f;
private const float DefaultTileHeight = 5f;
@@ -89,15 +96,57 @@ namespace Minigames.DivingForPictures
{
CalculateScreenBounds();
SpawnInitialTiles();
+
+ // Initialize velocity and start the velocity calculation coroutine
+ _currentVelocity = moveSpeed * Time.fixedDeltaTime;
+ StartCoroutine(VelocityCalculationRoutine());
}
private void Update()
{
- MoveTiles();
+ HandleMovement();
HandleTileDestruction();
HandleTileSpawning();
HandleSpeedRamping();
}
+
+ ///
+ /// Gets the current velocity of the tiles
+ ///
+ /// The current upward velocity of the tiles
+ public float GetCurrentVelocity()
+ {
+ return _currentVelocity;
+ }
+
+ ///
+ /// Sets a custom velocity, overriding the calculated one
+ ///
+ /// The new velocity value
+ public void SetVelocity(float velocity)
+ {
+ _currentVelocity = velocity;
+ }
+
+ ///
+ /// Coroutine that periodically calculates the velocity based on game state
+ ///
+ private IEnumerator VelocityCalculationRoutine()
+ {
+ while (true)
+ {
+ CalculateVelocity();
+ yield return new WaitForSeconds(velocityCalculationInterval);
+ }
+ }
+
+ ///
+ /// Calculates the current velocity based on move speed
+ ///
+ private void CalculateVelocity()
+ {
+ _currentVelocity = moveSpeed * Time.fixedDeltaTime;
+ }
///
/// Calculate height values for all tile prefabs
@@ -170,9 +219,25 @@ namespace Minigames.DivingForPictures
///
private void SpawnInitialTiles()
{
+ // Calculate starting Y position - moved 2 tiles up from the bottom of the screen
+ float startingY = _screenBottom;
+
+ // If we have prefab tiles with known heights, use their average height for offset calculation
+ float tileHeightEstimate = DefaultTileHeight;
+ if (tilePrefabs != null && tilePrefabs.Count > 0 && tilePrefabs[0] != null)
+ {
+ if (_tileHeights.TryGetValue(tilePrefabs[0], out float height))
+ {
+ tileHeightEstimate = height;
+ }
+ }
+
+ // Move starting position up by 2 tile heights
+ startingY += tileHeightEstimate * 2;
+
for (int i = 0; i < initialTileCount; i++)
{
- float y = _screenBottom;
+ float y = startingY;
// Calculate proper Y position based on previous tiles
if (i > 0 && _activeTiles.Count > 0)
{
@@ -206,16 +271,15 @@ namespace Minigames.DivingForPictures
}
///
- /// Move all active tiles upward
+ /// Handles the movement of all active tiles based on the current velocity
///
- private void MoveTiles()
+ private void HandleMovement()
{
- float moveDelta = moveSpeed * Time.deltaTime;
foreach (var tile in _activeTiles)
{
if (tile != null)
{
- tile.transform.position += Vector3.up * moveDelta;
+ tile.transform.position += Vector3.up * _currentVelocity;
}
}
}