Introduce background spawning with parallax effect (#86)
Co-authored-by: Michal Pikulski <michal.a.pikulski@gmail.com> Reviewed-on: #86
This commit is contained in:
24
Assets/Scripts/Minigames/Airplane/Data/ParallaxLayer.cs
Normal file
24
Assets/Scripts/Minigames/Airplane/Data/ParallaxLayer.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
namespace Minigames.Airplane.Data
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines parallax layer depth for background elements.
|
||||
/// </summary>
|
||||
public enum ParallaxLayer
|
||||
{
|
||||
/// <summary>
|
||||
/// Furthest back layer, moves slowest (lowest parallax factor).
|
||||
/// </summary>
|
||||
Background,
|
||||
|
||||
/// <summary>
|
||||
/// Middle layer, moves at medium speed.
|
||||
/// </summary>
|
||||
Middle,
|
||||
|
||||
/// <summary>
|
||||
/// Closest layer, moves fastest (highest parallax factor).
|
||||
/// </summary>
|
||||
Foreground
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 30cd4bc1743c44089146678153542aae
|
||||
timeCreated: 1765965854
|
||||
@@ -0,0 +1,27 @@
|
||||
using Minigames.Airplane.Data;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Minigames.Airplane.Data
|
||||
{
|
||||
/// <summary>
|
||||
/// Component to store spawn positioning data on prefabs.
|
||||
/// Attach this to obstacle prefabs that need specific positioning behavior.
|
||||
/// If not present, spawner will use default positioning from AirplaneSettings.
|
||||
/// </summary>
|
||||
[AddComponentMenu("Airplane/Prefab Spawn Entry")]
|
||||
public class PrefabSpawnEntryComponent : MonoBehaviour
|
||||
{
|
||||
[Tooltip("How to position this object vertically")]
|
||||
public SpawnPositionMode spawnPositionMode = SpawnPositionMode.SnapToGround;
|
||||
|
||||
[Tooltip("Y position to use (when mode is SpecifiedY)")]
|
||||
public float specifiedY;
|
||||
|
||||
[Tooltip("Min Y for random range (when mode is RandomRange)")]
|
||||
public float randomYMin = -5f;
|
||||
|
||||
[Tooltip("Max Y for random range (when mode is RandomRange)")]
|
||||
public float randomYMax = 5f;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 90239fb003214b4087d0717f6f417161
|
||||
timeCreated: 1765990367
|
||||
@@ -0,0 +1,32 @@
|
||||
using Core.Settings;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Minigames.Airplane.Data
|
||||
{
|
||||
/// <summary>
|
||||
/// Parameters passed from AirplaneSpawnManager to spawners during initialization.
|
||||
/// Encapsulates shared references and configuration.
|
||||
/// </summary>
|
||||
public class SpawnInitParameters
|
||||
{
|
||||
/// <summary>
|
||||
/// Parent transform for spawned objects (organization)
|
||||
/// </summary>
|
||||
public Transform SpawnContainer { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Settings reference for spawn configuration
|
||||
/// </summary>
|
||||
public IAirplaneSettings Settings { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Create spawn initialization parameters
|
||||
/// </summary>
|
||||
public SpawnInitParameters(Transform spawnContainer, IAirplaneSettings settings)
|
||||
{
|
||||
SpawnContainer = spawnContainer;
|
||||
Settings = settings;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: eb788e2f6d204a5fb1b2ae79ed38e7c2
|
||||
timeCreated: 1765972065
|
||||
45
Assets/Scripts/Minigames/Airplane/Data/SpawnPoolConfig.cs
Normal file
45
Assets/Scripts/Minigames/Airplane/Data/SpawnPoolConfig.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Minigames.Airplane.Data
|
||||
{
|
||||
/// <summary>
|
||||
/// Configuration for a single spawn pool.
|
||||
/// Contains prefabs, unlock timing, and optional spawn parameter overrides.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class SpawnPoolConfig
|
||||
{
|
||||
[Tooltip("Prefabs that can spawn from this pool")]
|
||||
public GameObject[] prefabs;
|
||||
|
||||
[Tooltip("Time (seconds from game start) when this pool becomes available. 0 = available immediately.")]
|
||||
public float unlockTime = 0f;
|
||||
|
||||
[Tooltip("Description for this pool (editor reference only)")]
|
||||
public string description = "Pool";
|
||||
|
||||
[Header("Spawn Parameter Overrides (0 = use global)")]
|
||||
[Tooltip("Override minimum spawn distance for this pool (0 = use global)")]
|
||||
public float overrideMinDistance = 0f;
|
||||
|
||||
[Tooltip("Override maximum spawn distance for this pool (0 = use global)")]
|
||||
public float overrideMaxDistance = 0f;
|
||||
|
||||
/// <summary>
|
||||
/// Check if this pool has valid prefabs assigned.
|
||||
/// </summary>
|
||||
public bool HasPrefabs => prefabs != null && prefabs.Length > 0;
|
||||
|
||||
/// <summary>
|
||||
/// Get effective minimum distance (uses override if non-zero, otherwise uses global).
|
||||
/// </summary>
|
||||
public float GetMinDistance(float globalMin) => overrideMinDistance > 0f ? overrideMinDistance : globalMin;
|
||||
|
||||
/// <summary>
|
||||
/// Get effective maximum distance (uses override if non-zero, otherwise uses global).
|
||||
/// </summary>
|
||||
public float GetMaxDistance(float globalMax) => overrideMaxDistance > 0f ? overrideMaxDistance : globalMax;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 51d29acb7cdd48819588acd1401456a9
|
||||
timeCreated: 1765965854
|
||||
21
Assets/Scripts/Minigames/Airplane/Data/SpawnPoolMode.cs
Normal file
21
Assets/Scripts/Minigames/Airplane/Data/SpawnPoolMode.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
namespace Minigames.Airplane.Data
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines how multiple spawn pools are combined.
|
||||
/// </summary>
|
||||
public enum SpawnPoolMode
|
||||
{
|
||||
/// <summary>
|
||||
/// All unlocked pools contribute to a single shared spawn stream.
|
||||
/// Objects spawn at regular intervals considering all available pools.
|
||||
/// </summary>
|
||||
Together,
|
||||
|
||||
/// <summary>
|
||||
/// Each pool spawns independently with its own timing.
|
||||
/// Multiple objects can spawn simultaneously from different pools.
|
||||
/// </summary>
|
||||
Exclusive
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5206332ad0e54ed4b20df47663202967
|
||||
timeCreated: 1765965854
|
||||
Reference in New Issue
Block a user