Move around scripts to cleanup the Minigame structure
This commit is contained in:
3
Assets/Scripts/Minigames/DivingForPictures/Bubbles.meta
Normal file
3
Assets/Scripts/Minigames/DivingForPictures/Bubbles.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 625b24c8ed0e4c41bce0893b2ed07a25
|
||||
timeCreated: 1758543705
|
||||
@@ -145,7 +145,7 @@ namespace Minigames.DivingForPictures
|
||||
_isSurfacing = true;
|
||||
|
||||
// Slow down all existing bubbles
|
||||
Bubble[] activeBubbles = FindObjectsOfType<Bubble>();
|
||||
Bubble[] activeBubbles = FindObjectsByType<Bubble>(FindObjectsSortMode.None);
|
||||
foreach (Bubble bubble in activeBubbles)
|
||||
{
|
||||
bubble.speed *= surfacingSpeedFactor;
|
||||
3
Assets/Scripts/Minigames/DivingForPictures/Monster.meta
Normal file
3
Assets/Scripts/Minigames/DivingForPictures/Monster.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 03f105b6ec1a4b63be259f257aad2cdb
|
||||
timeCreated: 1758543817
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a48ab1197e3d4c6890be54c9102e4091
|
||||
timeCreated: 1758543716
|
||||
@@ -29,13 +29,6 @@ namespace Minigames.DivingForPictures
|
||||
[Tooltip("Radius around spawn point to check for tile collisions")]
|
||||
[SerializeField] private float spawnCollisionRadius = 1f;
|
||||
|
||||
[Header("Spawn Position")]
|
||||
[Tooltip("How far below screen to spawn obstacles")]
|
||||
[SerializeField] private float spawnDistanceBelowScreen = 2f;
|
||||
|
||||
[Tooltip("Horizontal spawn range (distance from center)")]
|
||||
[SerializeField] private float spawnRangeX = 8f;
|
||||
|
||||
[Header("Obstacle Properties Randomization")]
|
||||
[Tooltip("Minimum movement speed for spawned obstacles")]
|
||||
[SerializeField] private float minMoveSpeed = 1f;
|
||||
@@ -467,14 +460,6 @@ namespace Minigames.DivingForPictures
|
||||
spawnInterval = interval;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Public method to change spawn range at runtime
|
||||
/// </summary>
|
||||
public void SetSpawnRange(float range)
|
||||
{
|
||||
spawnRangeX = range;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Public method to set speed range at runtime
|
||||
/// </summary>
|
||||
3
Assets/Scripts/Minigames/DivingForPictures/Player.meta
Normal file
3
Assets/Scripts/Minigames/DivingForPictures/Player.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f6ccbb338a48404cae0e954b63e8cd3b
|
||||
timeCreated: 1758543727
|
||||
@@ -0,0 +1,46 @@
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// Makes this object follow a target (bottleTransform) horizontally, optionally using a wobble offset for vertical movement.
|
||||
/// </summary>
|
||||
public class RockFollower : MonoBehaviour
|
||||
{
|
||||
[Header("References")]
|
||||
public Transform bottleTransform;
|
||||
public WobbleBehavior bottleWobble;
|
||||
|
||||
[Header("Movement Settings")]
|
||||
public float followStiffness = 4f;
|
||||
/// <summary>
|
||||
/// Whether to use the wobble offset for vertical movement.
|
||||
/// </summary>
|
||||
public bool useWobbleOffset = true;
|
||||
/// <summary>
|
||||
/// The base Y position for the rock.
|
||||
/// </summary>
|
||||
public float baseY = -6f;
|
||||
|
||||
private float velocityX; // For SmoothDamp
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (bottleTransform == null) return;
|
||||
|
||||
// Target horizontal position is bottle's X
|
||||
float targetX = bottleTransform.position.x;
|
||||
float currentX = transform.position.x;
|
||||
|
||||
// Smoothly follow bottle's X with stiffer motion
|
||||
float newX = Mathf.SmoothDamp(currentX, targetX, ref velocityX, 1f / followStiffness);
|
||||
|
||||
// Calculate Y position
|
||||
float newY = baseY;
|
||||
if (useWobbleOffset && bottleWobble != null)
|
||||
{
|
||||
newY += bottleWobble.VerticalOffset;
|
||||
}
|
||||
|
||||
// Set new position (only X and Y, keep Z)
|
||||
transform.position = new Vector3(newX, newY, transform.position.z);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f1a7937fe5974e9486dc7545de8cee6b
|
||||
timeCreated: 1757020153
|
||||
@@ -212,7 +212,7 @@ public class RopeEndPhysicsFollower : MonoBehaviour
|
||||
if (attachedRope == null)
|
||||
{
|
||||
// Find any rope that has this transform as an endpoint
|
||||
Rope[] allRopes = FindObjectsOfType<Rope>();
|
||||
Rope[] allRopes = FindObjectsByType<Rope>(FindObjectsSortMode.None);
|
||||
foreach (var rope in allRopes)
|
||||
{
|
||||
if (rope.EndPoint == transform || rope.StartPoint == transform)
|
||||
@@ -0,0 +1,92 @@
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// Adds a wobble (rocking and vertical movement) effect to the object, based on speed and time.
|
||||
/// </summary>
|
||||
public class WobbleBehavior : MonoBehaviour
|
||||
{
|
||||
[Header("Wobble Settings")]
|
||||
public float wobbleFrequency = 1.5f;
|
||||
/// <summary>
|
||||
/// Max degrees from horizontal.
|
||||
/// </summary>
|
||||
public float baseWobbleAmplitude = 8f;
|
||||
/// <summary>
|
||||
/// How much speed affects amplitude.
|
||||
/// </summary>
|
||||
public float speedToAmplitude = 2f;
|
||||
/// <summary>
|
||||
/// Maximum allowed rotation in degrees.
|
||||
/// </summary>
|
||||
public float maxRotationLimit = 45f;
|
||||
|
||||
[Header("Vertical Movement Settings")]
|
||||
public float verticalFrequency = 0.5f;
|
||||
/// <summary>
|
||||
/// How far the object moves up/down.
|
||||
/// </summary>
|
||||
public float verticalAmplitude = 0.5f;
|
||||
|
||||
[Header("Smoothing Settings")]
|
||||
public float velocitySmoothing = 10f;
|
||||
/// <summary>
|
||||
/// How quickly rotation is smoothed.
|
||||
/// </summary>
|
||||
public float rotationSmoothing = 10f;
|
||||
|
||||
private Vector3 lastPosition;
|
||||
private float wobbleTime;
|
||||
private float velocity;
|
||||
private Vector3 basePosition;
|
||||
private float verticalOffset;
|
||||
private float smoothedVelocity;
|
||||
private float smoothedAngle;
|
||||
|
||||
/// <summary>
|
||||
/// The current velocity of the object (horizontal only).
|
||||
/// </summary>
|
||||
public float Velocity => velocity;
|
||||
/// <summary>
|
||||
/// The current vertical offset due to wobble.
|
||||
/// </summary>
|
||||
public float VerticalOffset => verticalOffset;
|
||||
|
||||
void Start()
|
||||
{
|
||||
lastPosition = transform.position;
|
||||
smoothedVelocity = 0f;
|
||||
smoothedAngle = 0f;
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
// Calculate movement speed (exclude vertical wobble from velocity calculation)
|
||||
Vector3 horizontalPosition = transform.position;
|
||||
horizontalPosition.y = 0f; // Ignore Y for velocity if only horizontal movement matters
|
||||
Vector3 horizontalLastPosition = lastPosition;
|
||||
horizontalLastPosition.y = 0f;
|
||||
velocity = (horizontalPosition - horizontalLastPosition).magnitude / Time.deltaTime;
|
||||
lastPosition = transform.position;
|
||||
|
||||
// Smooth velocity to prevent jitter
|
||||
smoothedVelocity = Mathf.Lerp(smoothedVelocity, velocity, velocitySmoothing * Time.deltaTime);
|
||||
|
||||
// Wobble amplitude scales with smoothed speed, but always has a base value
|
||||
float amplitude = baseWobbleAmplitude + smoothedVelocity * speedToAmplitude;
|
||||
amplitude = Mathf.Min(amplitude, maxRotationLimit); // Prevent amplitude from exceeding limit
|
||||
|
||||
// Oscillate around horizontal (0 degrees)
|
||||
wobbleTime += Time.deltaTime * wobbleFrequency;
|
||||
float targetAngle = Mathf.Sin(wobbleTime) * amplitude;
|
||||
targetAngle = Mathf.Clamp(targetAngle, -maxRotationLimit, maxRotationLimit);
|
||||
|
||||
// Smooth the rotation angle
|
||||
smoothedAngle = Mathf.Lerp(smoothedAngle, targetAngle, rotationSmoothing * Time.deltaTime);
|
||||
|
||||
// Apply rotation (Z axis for 2D)
|
||||
transform.localRotation = Quaternion.Euler(0f, 0f, smoothedAngle);
|
||||
|
||||
// Calculate vertical up/down movement (wave riding) only once
|
||||
verticalOffset = Mathf.Sin(wobbleTime * verticalFrequency) * verticalAmplitude;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9072050a53fc4b539f4f4716bab53c07
|
||||
timeCreated: 1757017852
|
||||
3
Assets/Scripts/Minigames/DivingForPictures/Tiles.meta
Normal file
3
Assets/Scripts/Minigames/DivingForPictures/Tiles.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b3dbc161316c4b41a7555e9139539aee
|
||||
timeCreated: 1758543757
|
||||
19
Assets/Scripts/Minigames/DivingForPictures/Tiles/Tile.cs
Normal file
19
Assets/Scripts/Minigames/DivingForPictures/Tiles/Tile.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// A simple marker component to identify game objects as tiles.
|
||||
/// This allows the pool system to specifically track and manage tile objects.
|
||||
/// </summary>
|
||||
public class Tile : MonoBehaviour
|
||||
{
|
||||
// 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
|
||||
[SerializeField] private int tileIndex;
|
||||
|
||||
public int TileIndex
|
||||
{
|
||||
get => tileIndex;
|
||||
set => tileIndex = value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 41def183b6714aca97663d74cc2d0678
|
||||
timeCreated: 1758027131
|
||||
Reference in New Issue
Block a user