The feel is fine
This commit is contained in:
@@ -75,7 +75,7 @@ namespace Minigames.DivingForPictures
|
||||
Debug.LogError("[TrenchTileSpawner] Failed to load diving developer settings!");
|
||||
}
|
||||
|
||||
_baseMoveSpeed = _settings?.EndlessDescenderMoveSpeed ?? 3f; // Store the original base speed
|
||||
_baseMoveSpeed = _settings?.MoveSpeed ?? 3f; // Store the original base speed
|
||||
|
||||
// Calculate tile heights for each prefab
|
||||
CalculateTileHeights();
|
||||
@@ -150,7 +150,7 @@ namespace Minigames.DivingForPictures
|
||||
while (true)
|
||||
{
|
||||
CalculateVelocity();
|
||||
yield return new WaitForSeconds(_settings.EndlessDescenderVelocityCalculationInterval);
|
||||
yield return new WaitForSeconds(_settings.VelocityCalculationInterval);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -249,7 +249,7 @@ namespace Minigames.DivingForPictures
|
||||
// Move starting position up by 2 tile heights
|
||||
startingY += tileHeightEstimate * 2;
|
||||
|
||||
for (int i = 0; i < _settings.EndlessDescenderInitialTileCount; i++)
|
||||
for (int i = 0; i < _settings.InitialTileCount; i++)
|
||||
{
|
||||
float y = startingY;
|
||||
// Calculate proper Y position based on previous tiles
|
||||
@@ -293,7 +293,7 @@ namespace Minigames.DivingForPictures
|
||||
|
||||
// Update the actual move speed based on the velocity factor
|
||||
// This keeps the original move speed intact for game logic
|
||||
_baseMoveSpeed = _settings.EndlessDescenderMoveSpeed * Mathf.Abs(_velocityFactor);
|
||||
_baseMoveSpeed = _settings.MoveSpeed * Mathf.Abs(_velocityFactor);
|
||||
|
||||
// Recalculate velocity immediately
|
||||
CalculateVelocity();
|
||||
@@ -364,12 +364,12 @@ namespace Minigames.DivingForPictures
|
||||
if (_isSurfacing)
|
||||
{
|
||||
// When surfacing, destroy tiles at the bottom
|
||||
shouldDestroy = topTile.transform.position.y + tileHeight / 2 < _screenBottom - _settings.EndlessDescenderTileSpawnBuffer;
|
||||
shouldDestroy = topTile.transform.position.y + tileHeight / 2 < _screenBottom - _settings.TileSpawnBuffer;
|
||||
}
|
||||
else
|
||||
{
|
||||
// When descending, destroy tiles at the top
|
||||
shouldDestroy = topTile.transform.position.y - tileHeight / 2 > _screenTop + _settings.EndlessDescenderTileSpawnBuffer;
|
||||
shouldDestroy = topTile.transform.position.y - tileHeight / 2 > _screenTop + _settings.TileSpawnBuffer;
|
||||
}
|
||||
|
||||
if (shouldDestroy)
|
||||
@@ -433,12 +433,12 @@ namespace Minigames.DivingForPictures
|
||||
if (_isSurfacing)
|
||||
{
|
||||
// When surfacing, check if the bottom of the tile is above the top of the screen
|
||||
isLastTileLeaving = bottomTile.transform.position.y - tileHeight / 2 > _screenTop + _settings.EndlessDescenderTileSpawnBuffer;
|
||||
isLastTileLeaving = bottomTile.transform.position.y - tileHeight / 2 > _screenTop + _settings.TileSpawnBuffer;
|
||||
}
|
||||
else
|
||||
{
|
||||
// When descending, check if the top of the tile is below the bottom of the screen
|
||||
isLastTileLeaving = bottomTile.transform.position.y + tileHeight / 2 < _screenBottom - _settings.EndlessDescenderTileSpawnBuffer;
|
||||
isLastTileLeaving = bottomTile.transform.position.y + tileHeight / 2 < _screenBottom - _settings.TileSpawnBuffer;
|
||||
}
|
||||
|
||||
if (isLastTileLeaving)
|
||||
@@ -456,14 +456,14 @@ namespace Minigames.DivingForPictures
|
||||
{
|
||||
// When surfacing, spawn new tiles at the top
|
||||
float topEdge = bottomTile.transform.position.y + tileHeight / 2;
|
||||
shouldSpawn = topEdge < _screenTop + _settings.EndlessDescenderTileSpawnBuffer;
|
||||
shouldSpawn = topEdge < _screenTop + _settings.TileSpawnBuffer;
|
||||
newY = bottomTile.transform.position.y + tileHeight;
|
||||
}
|
||||
else
|
||||
{
|
||||
// When descending, spawn new tiles at the bottom
|
||||
float bottomEdge = bottomTile.transform.position.y - tileHeight / 2;
|
||||
shouldSpawn = bottomEdge > _screenBottom - _settings.EndlessDescenderTileSpawnBuffer;
|
||||
shouldSpawn = bottomEdge > _screenBottom - _settings.TileSpawnBuffer;
|
||||
newY = bottomTile.transform.position.y - tileHeight;
|
||||
}
|
||||
|
||||
@@ -479,9 +479,9 @@ namespace Minigames.DivingForPictures
|
||||
private void HandleSpeedRamping()
|
||||
{
|
||||
_speedUpTimer += Time.deltaTime;
|
||||
if (_speedUpTimer >= _settings.EndlessDescenderSpeedUpInterval)
|
||||
if (_speedUpTimer >= _settings.SpeedUpInterval)
|
||||
{
|
||||
_baseMoveSpeed = Mathf.Min(_baseMoveSpeed + _settings.EndlessDescenderSpeedUpFactor, _settings.EndlessDescenderMaxMoveSpeed);
|
||||
_baseMoveSpeed = Mathf.Min(_baseMoveSpeed + _settings.SpeedUpFactor, _settings.MaxMoveSpeed);
|
||||
_speedUpTimer = 0f;
|
||||
}
|
||||
}
|
||||
@@ -520,11 +520,25 @@ namespace Minigames.DivingForPictures
|
||||
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;
|
||||
SetLayerRecursively(tile, _devSettings.TrenchTileLayer);
|
||||
}
|
||||
}
|
||||
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);
|
||||
@@ -660,7 +674,7 @@ namespace Minigames.DivingForPictures
|
||||
Gizmos.color = Color.cyan;
|
||||
if (_settings != null)
|
||||
{
|
||||
for (int i = 0; i < _settings.EndlessDescenderInitialTileCount; i++)
|
||||
for (int i = 0; i < _settings.InitialTileCount; i++)
|
||||
{
|
||||
float height = DefaultTileHeight;
|
||||
if (tilePrefabs != null && tilePrefabs.Count > 0 && tilePrefabs[0] != null &&
|
||||
@@ -674,5 +688,25 @@ namespace Minigames.DivingForPictures
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Set the layer of a GameObject and all its children recursively
|
||||
/// </summary>
|
||||
/// <param name="obj">The GameObject to set the layer for</param>
|
||||
/// <param name="layer">The layer index to set</param>
|
||||
private void SetLayerRecursively(GameObject obj, int layer)
|
||||
{
|
||||
if (obj == null) return;
|
||||
|
||||
obj.layer = layer;
|
||||
|
||||
foreach (Transform child in obj.transform)
|
||||
{
|
||||
if (child != null)
|
||||
{
|
||||
SetLayerRecursively(child.gameObject, layer);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user