Danro-Jump/Assets/Scripts/Runtime/Gameplay/Spawning/PlatformContentProfile.cs
Danil Iarosh cefb2fd345 Build initial vertical platformer foundation
Подробные изменения:
- Добавлены сцены Bootstrap, MainMenu и Game с текущей вертикальной 9:16 структурой проекта.
- Добавлены runtime-скрипты gameplay-архитектуры: DI через Extenject, спавнер платформ, прогрессия этапов, one-way платформы, игрок, камера и оборудование JumpPad.
- Добавлены ScriptableObject-этапы сложности, weighted-настройки платформ, оборудования, противников и collectibles.
- Добавлены UI Toolkit ресурсы главного меню, preview-материалы, шрифты, спрайты, анимации и игровые prefab-ассеты.
- Перенесена и оформлена новая COM-система для работы с аппаратными портами и StreamingAssets.
- Обновлены проектные гайды, AGENTS.md, правила Git/Git LFS, .gitignore, Unity Packages и ProjectSettings.
- Удалён локальный skill start-required-mcp-servers из репозитория.
2026-05-11 07:41:14 +03:00

89 lines
3.0 KiB
C#

using System.Collections.Generic;
using UnityEngine;
namespace DanroJump.Gameplay
{
public sealed class PlatformContentProfile : IPlatformContentSource
{
private readonly IReadOnlyList<WeightedPrefabOption> collectiblePrefabs;
private readonly IReadOnlyList<WeightedPrefabOption> equipmentPrefabs;
private readonly IReadOnlyList<WeightedPrefabOption> enemyPrefabs;
private readonly float collectibleSpawnChance;
private readonly float equipmentSpawnChance;
private readonly float enemySpawnChance;
public PlatformContentProfile(
IReadOnlyList<WeightedPrefabOption> collectiblePrefabs,
float collectibleSpawnChance,
IReadOnlyList<WeightedPrefabOption> equipmentPrefabs,
float equipmentSpawnChance,
IReadOnlyList<WeightedPrefabOption> enemyPrefabs,
float enemySpawnChance)
{
this.collectiblePrefabs = collectiblePrefabs;
this.collectibleSpawnChance = Mathf.Clamp01(collectibleSpawnChance);
this.equipmentPrefabs = equipmentPrefabs;
this.equipmentSpawnChance = Mathf.Clamp01(equipmentSpawnChance);
this.enemyPrefabs = enemyPrefabs;
this.enemySpawnChance = Mathf.Clamp01(enemySpawnChance);
}
public bool ShouldSpawn(PlatformContentKind kind, System.Random random)
{
var chance = GetSpawnChance(kind);
if (chance <= 0f)
{
return false;
}
if (chance >= 1f)
{
return true;
}
return (random != null ? random.NextDouble() : 0d) <= chance;
}
public bool TryGetPrefab(PlatformContentKind kind, System.Random random, out GameObject prefab)
{
if (WeightedPrefabOption.TrySelect(GetPrefabs(kind), random, out prefab))
{
return true;
}
prefab = null;
return false;
}
private float GetSpawnChance(PlatformContentKind kind)
{
switch (kind)
{
case PlatformContentKind.Collectible:
return collectibleSpawnChance;
case PlatformContentKind.Equipment:
return equipmentSpawnChance;
case PlatformContentKind.Enemy:
return enemySpawnChance;
default:
return 0f;
}
}
private IReadOnlyList<WeightedPrefabOption> GetPrefabs(PlatformContentKind kind)
{
switch (kind)
{
case PlatformContentKind.Collectible:
return collectiblePrefabs;
case PlatformContentKind.Equipment:
return equipmentPrefabs;
case PlatformContentKind.Enemy:
return enemyPrefabs;
default:
return collectiblePrefabs;
}
}
}
}