Surfacing sequence 80% done

This commit is contained in:
2025-09-22 13:56:42 +02:00
parent ae6b995f45
commit 46950aa877
6 changed files with 1533 additions and 35 deletions

8
Assets/Playables.meta Normal file
View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 2c0088270c13b3a4e8ce04a3f672887d
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 5ecd3cfdb172df5439e4522c15c48f75
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -340,15 +340,15 @@ LineRenderer:
m_SortingOrder: 0
m_Positions:
- {x: 0, y: 4.1716814, z: 0}
- {x: -0.0011514801, y: 3.9187107, z: 0}
- {x: -0.00230296, y: 3.6922278, z: 0}
- {x: -0.0034544398, y: 3.4922323, z: 0}
- {x: -0.00460592, y: 3.3187256, z: 0}
- {x: -0.0057574, y: 3.1717062, z: 0}
- {x: -0.0069088796, y: 3.0511749, z: 0}
- {x: -0.008060359, y: 2.9571314, z: 0}
- {x: -0.00921184, y: 2.8895762, z: 0}
- {x: -0.010363319, y: 2.8485086, z: 0}
- {x: -0.0011514801, y: 3.9551861, z: 0}
- {x: -0.00230296, y: 3.757073, z: 0}
- {x: -0.0034544398, y: 3.577342, z: 0}
- {x: -0.00460592, y: 3.4159937, z: 0}
- {x: -0.0057574, y: 3.273027, z: 0}
- {x: -0.0069088796, y: 3.1484427, z: 0}
- {x: -0.008060359, y: 3.042241, z: 0}
- {x: -0.00921184, y: 2.9544215, z: 0}
- {x: -0.010363319, y: 2.884984, z: 0}
- {x: -0.0115148, y: 2.833929, z: 0}
m_Parameters:
serializedVersion: 3
@@ -450,6 +450,7 @@ GameObject:
m_Component:
- component: {fileID: 224729333}
- component: {fileID: 224729332}
- component: {fileID: 224729334}
m_Layer: 0
m_Name: CinemachineCamera
m_TagString: Untagged
@@ -515,6 +516,28 @@ Transform:
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!95 &224729334
Animator:
serializedVersion: 7
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 224729330}
m_Enabled: 1
m_Avatar: {fileID: 0}
m_Controller: {fileID: 0}
m_CullingMode: 0
m_UpdateMode: 0
m_ApplyRootMotion: 0
m_LinearVelocityBlending: 0
m_StabilizeFeet: 0
m_AnimatePhysics: 0
m_WarningMessage:
m_HasTransformHierarchy: 1
m_AllowConstantClipSamplingOptimization: 1
m_KeepAnimatorStateOnDisable: 0
m_WriteDefaultValuesOnDisable: 0
--- !u!1 &323864663
GameObject:
m_ObjectHideFlags: 0
@@ -627,6 +650,10 @@ MonoBehaviour:
- {fileID: 1435210811}
- {fileID: 1062017697}
- {fileID: 173052728}
speedTransitionDuration: 2
surfacingSpeedFactor: 3
surfacingSpawnDelay: 3
surfacingTimeline: {fileID: 2064311130}
--- !u!4 &424805726
Transform:
m_ObjectHideFlags: 0
@@ -652,6 +679,7 @@ GameObject:
m_Component:
- component: {fileID: 461301697}
- component: {fileID: 461301696}
- component: {fileID: 461301698}
m_Layer: 0
m_Name: DivingBackground_0
m_TagString: Untagged
@@ -723,12 +751,34 @@ Transform:
m_GameObject: {fileID: 461301695}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 1.12, z: 0}
m_LocalPosition: {x: 0, y: 1.24, z: 0}
m_LocalScale: {x: 0.81438, y: 0.81438, z: 0.81438}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!95 &461301698
Animator:
serializedVersion: 7
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 461301695}
m_Enabled: 1
m_Avatar: {fileID: 0}
m_Controller: {fileID: 0}
m_CullingMode: 0
m_UpdateMode: 0
m_ApplyRootMotion: 0
m_LinearVelocityBlending: 0
m_StabilizeFeet: 0
m_AnimatePhysics: 0
m_WarningMessage:
m_HasTransformHierarchy: 1
m_AllowConstantClipSamplingOptimization: 1
m_KeepAnimatorStateOnDisable: 0
m_WriteDefaultValuesOnDisable: 0
--- !u!1 &730962732
GameObject:
m_ObjectHideFlags: 0
@@ -832,6 +882,7 @@ GameObject:
- component: {fileID: 747976402}
- component: {fileID: 747976403}
- component: {fileID: 747976404}
- component: {fileID: 747976405}
m_Layer: 0
m_Name: BottleMarine
m_TagString: Player
@@ -1062,6 +1113,28 @@ MonoBehaviour:
blinkRate: 0.15
damageColorAlpha: 0.7
targetSpriteRenderer: {fileID: 730962734}
--- !u!95 &747976405
Animator:
serializedVersion: 7
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 747976396}
m_Enabled: 1
m_Avatar: {fileID: 0}
m_Controller: {fileID: 0}
m_CullingMode: 0
m_UpdateMode: 0
m_ApplyRootMotion: 0
m_LinearVelocityBlending: 0
m_StabilizeFeet: 0
m_AnimatePhysics: 0
m_WarningMessage:
m_HasTransformHierarchy: 1
m_AllowConstantClipSamplingOptimization: 1
m_KeepAnimatorStateOnDisable: 0
m_WriteDefaultValuesOnDisable: 0
--- !u!1 &824396214
GameObject:
m_ObjectHideFlags: 0
@@ -1190,6 +1263,7 @@ MonoBehaviour:
useObjectPooling: 1
initialPoolSize: 10
maxPoolSize: 30
surfacingSpeedFactor: 0.5
--- !u!4 &1003335105
Transform:
m_ObjectHideFlags: 0
@@ -1308,15 +1382,15 @@ LineRenderer:
m_SortingOrder: 0
m_Positions:
- {x: 0, y: 4.1716814, z: 0}
- {x: 0.036271624, y: 3.927396, z: 0}
- {x: 0.07254324, y: 3.7076683, z: 0}
- {x: 0.10881486, y: 3.5124984, z: 0}
- {x: 0.14508648, y: 3.3418865, z: 0}
- {x: 0.1813581, y: 3.195832, z: 0}
- {x: 0.21762972, y: 3.0743358, z: 0}
- {x: 0.25390133, y: 2.9773972, z: 0}
- {x: 0.29017296, y: 2.905017, z: 0}
- {x: 0.32644457, y: 2.857194, z: 0}
- {x: 0.036271624, y: 3.9653695, z: 0}
- {x: 0.07254324, y: 3.7751768, z: 0}
- {x: 0.10881486, y: 3.6011028, z: 0}
- {x: 0.14508648, y: 3.443149, z: 0}
- {x: 0.1813581, y: 3.3013139, z: 0}
- {x: 0.21762972, y: 3.1755984, z: 0}
- {x: 0.25390133, y: 3.066002, z: 0}
- {x: 0.29017296, y: 2.9725251, z: 0}
- {x: 0.32644457, y: 2.8951674, z: 0}
- {x: 0.3627162, y: 2.833929, z: 0}
m_Parameters:
serializedVersion: 3
@@ -1848,15 +1922,15 @@ LineRenderer:
m_SortingOrder: 0
m_Positions:
- {x: 0, y: 4.1716814, z: 0}
- {x: -0.03339292, y: 3.9260902, z: 0}
- {x: -0.066785835, y: 3.705347, z: 0}
- {x: -0.10017875, y: 3.5094519, z: 0}
- {x: -0.13357168, y: 3.3384047, z: 0}
- {x: -0.16696459, y: 3.1922054, z: 0}
- {x: -0.20035751, y: 3.0708542, z: 0}
- {x: -0.2337504, y: 2.9743507, z: 0}
- {x: -0.26714337, y: 2.9026957, z: 0}
- {x: -0.30053627, y: 2.8558884, z: 0}
- {x: -0.03339292, y: 3.9638388, z: 0}
- {x: -0.066785835, y: 3.7724557, z: 0}
- {x: -0.10017875, y: 3.5975313, z: 0}
- {x: -0.13357168, y: 3.4390674, z: 0}
- {x: -0.16696459, y: 3.2970622, z: 0}
- {x: -0.20035751, y: 3.1715167, z: 0}
- {x: -0.2337504, y: 3.0624304, z: 0}
- {x: -0.26714337, y: 2.969804, z: 0}
- {x: -0.30053627, y: 2.8936367, z: 0}
- {x: -0.33392918, y: 2.833929, z: 0}
m_Parameters:
serializedVersion: 3
@@ -2015,6 +2089,9 @@ MonoBehaviour:
m_PersistentCalls:
m_Calls: []
velocityCalculationInterval: 0.5
onLastTileLeft:
m_PersistentCalls:
m_Calls: []
--- !u!1 &1834056336
GameObject:
m_ObjectHideFlags: 0
@@ -2164,6 +2241,61 @@ Transform:
m_Children: []
m_Father: {fileID: 2106431002}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &2064311128
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 2064311129}
- component: {fileID: 2064311130}
m_Layer: 0
m_Name: SurfacingTimeline
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &2064311129
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2064311128}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, 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!320 &2064311130
PlayableDirector:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2064311128}
m_Enabled: 1
serializedVersion: 3
m_PlayableAsset: {fileID: 11400000, guid: 5ecd3cfdb172df5439e4522c15c48f75, type: 2}
m_InitialState: 0
m_WrapMode: 0
m_DirectorUpdateMode: 1
m_InitialTime: 0
m_SceneBindings:
- key: {fileID: 7536617106820686252, guid: 5ecd3cfdb172df5439e4522c15c48f75, type: 2}
value: {fileID: 747976405}
- key: {fileID: 1284158391674687369, guid: 5ecd3cfdb172df5439e4522c15c48f75, type: 2}
value: {fileID: 461301698}
- key: {fileID: -4039891455399305819, guid: 5ecd3cfdb172df5439e4522c15c48f75, type: 2}
value: {fileID: 224729334}
m_ExposedReferences:
m_References: []
--- !u!1 &2106431001
GameObject:
m_ObjectHideFlags: 0
@@ -2256,3 +2388,4 @@ SceneRoots:
- {fileID: 824396217}
- {fileID: 323864665}
- {fileID: 461301697}
- {fileID: 2064311129}

View File

@@ -1,7 +1,9 @@
using UnityEngine;
using System.Collections.Generic;
using System;
using System.Collections;
using UnityEngine.Events;
using UnityEngine.Playables;
namespace Minigames.DivingForPictures
{
@@ -35,6 +37,16 @@ namespace Minigames.DivingForPictures
[Tooltip("Ropes that will break one by one as player takes damage")]
[SerializeField] private RopeBreaker[] playerRopes;
[Header("Surfacing Settings")]
[Tooltip("Duration in seconds for speed transition when surfacing")]
[SerializeField] private float speedTransitionDuration = 2.0f;
[Tooltip("Factor to multiply speed by when surfacing (usually 1.0 for same speed)")]
[SerializeField] private float surfacingSpeedFactor = 3.0f;
[Tooltip("How long to continue spawning tiles after surfacing begins (seconds)")]
[SerializeField] private float surfacingSpawnDelay = 5.0f;
[Tooltip("Reference to the PlayableDirector that will play the surfacing timeline")]
[SerializeField] private PlayableDirector surfacingTimeline;
// Private state variables
private int playerScore = 0;
private float currentSpawnProbability;
@@ -43,15 +55,10 @@ namespace Minigames.DivingForPictures
private List<Monster> activeMonsters = new List<Monster>();
// Velocity management
[Header("Surfacing Settings")]
[Tooltip("Duration in seconds for speed transition when surfacing")]
[SerializeField] private float speedTransitionDuration = 2.0f;
[Tooltip("Factor to multiply speed by when surfacing (usually 1.0 for same speed)")]
[SerializeField] private float surfacingSpeedFactor = 3.0f;
// Velocity state tracking
private float _currentVelocityFactor = 1.0f; // 1.0 = normal descent speed, -1.0 * surfacingSpeedFactor = full surfacing speed
private Coroutine _velocityTransitionCoroutine;
private Coroutine _surfacingSequenceCoroutine;
// Public properties
public int PlayerScore => playerScore;
@@ -360,6 +367,10 @@ namespace Minigames.DivingForPictures
OnVelocityFactorChanged -= tileSpawner.OnVelocityFactorChanged;
OnVelocityFactorChanged += tileSpawner.OnVelocityFactorChanged;
// Subscribe to the last tile event
tileSpawner.onLastTileLeft.RemoveListener(OnLastTileLeft);
tileSpawner.onLastTileLeft.AddListener(OnLastTileLeft);
// Tell spawner to reverse spawn/despawn logic
tileSpawner.StartSurfacing();
@@ -389,8 +400,50 @@ namespace Minigames.DivingForPictures
obstacleSpawner.OnVelocityFactorChanged(_currentVelocityFactor);
}
// Start the surfacing sequence coroutine
if (_surfacingSequenceCoroutine != null)
{
StopCoroutine(_surfacingSequenceCoroutine);
}
_surfacingSequenceCoroutine = StartCoroutine(SurfacingSequence());
Debug.Log($"[DivingGameManager] Started surfacing with target velocity factor: {targetVelocityFactor}");
}
/// <summary>
/// Coroutine to handle the surfacing sequence timing
/// </summary>
private IEnumerator SurfacingSequence()
{
// Wait for the configured delay
yield return new WaitForSeconds(surfacingSpawnDelay);
// Find tile spawner and tell it to stop spawning
TrenchTileSpawner tileSpawner = FindFirstObjectByType<TrenchTileSpawner>();
if (tileSpawner != null)
{
// Tell it to stop spawning new tiles
tileSpawner.StopSpawning();
Debug.Log("[DivingGameManager] Stopped spawning new tiles after delay");
}
}
/// <summary>
/// Called when the last tile leaves the screen
/// </summary>
private void OnLastTileLeft()
{
// Play the timeline
if (surfacingTimeline != null)
{
surfacingTimeline.Play();
Debug.Log("[DivingGameManager] Last tile left the screen, playing timeline");
}
else
{
Debug.LogWarning("[DivingGameManager] No surfacing timeline assigned!");
}
}
// Call this when the game ends
public void EndGame()

View File

@@ -61,6 +61,10 @@ namespace Minigames.DivingForPictures
// Direction state
private bool _isSurfacing = false;
private bool _stopSpawning = false;
// Event triggered when the last tile leaves the screen after stopping spawning
public UnityEvent onLastTileLeft = new UnityEvent();
// Velocity management
private float _baseMoveSpeed;
@@ -311,6 +315,14 @@ namespace Minigames.DivingForPictures
Debug.Log("[TrenchTileSpawner] Started surfacing - reversed array order");
}
/// <summary>
/// Stops spawning new tiles
/// </summary>
public void StopSpawning()
{
_stopSpawning = true;
}
/// <summary>
/// Handles the movement of all active tiles based on the current velocity
/// </summary>
@@ -388,7 +400,15 @@ namespace Minigames.DivingForPictures
/// </summary>
private void HandleTileSpawning()
{
if (_activeTiles.Count == 0) return;
if (_activeTiles.Count == 0)
{
// If we have no active tiles and spawning is stopped, trigger the event
if (_stopSpawning)
{
onLastTileLeft.Invoke();
}
return;
}
GameObject bottomTile = _activeTiles[^1];
if (bottomTile == null)
@@ -397,8 +417,36 @@ namespace Minigames.DivingForPictures
return;
}
// Get the tile height once to use in all calculations
float tileHeight = GetTileHeight(bottomTile);
// If we're in stop spawning mode, don't spawn new tiles
if (_stopSpawning)
{
// Check if this is the last tile, and if it's about to leave the screen
if (_activeTiles.Count == 1)
{
bool isLastTileLeaving;
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 + 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 - tileSpawnBuffer;
}
if (isLastTileLeaving)
{
onLastTileLeft.Invoke();
}
}
return;
}
bool shouldSpawn;
float newY;