Danil Iarosh 77186697f8 Prepare v0.1 gameplay and hardware foundation
Подробные изменения:

- Расширен основной gameplay loop: джетпак, новые платформы, оборудование, враги, прогрессия сложности и ограничения взаимодействий игрока.

- Добавлены Bootstrap-сервисы запуска приложения, защита, фокус окна, управление курсором и настройки сервисов через DI.

- Добавлена COM-интеграция с технической схемой Input System, обработкой кнопок/ADC, подсветкой и консольной диагностикой.

- Добавлен отдельный debug/logging модуль с каналами, обработчиками консоли и файловым выводом.

- Добавлены asmdef, link.xml, EditMode/PlayMode тесты и обновлена дорожная карта проекта.

Проверки:

- dotnet build .\\DanroJump.Runtime.csproj --no-restore

- dotnet build .\\DanroJump.Tests.EditMode.csproj --no-restore

- dotnet build .\\DanroJump.Tests.PlayMode.csproj --no-restore
2026-06-08 14:22:48 +03:00

83 lines
2.8 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using UnityEngine;
namespace DanroJump.Gameplay
{
/// <summary>
/// Базовый класс collectible-предметов с trigger-контактом и защитой от повторного подбора.
/// </summary>
[RequireComponent(typeof(Collider2D))]
public abstract class CollectibleBase : MonoBehaviour, ICollectible, IPlayerContactHandler
{
[SerializeField] private bool disableOnCollected = true;
/// <summary>
/// Показывает, был ли предмет уже подобран в текущем цикле жизни объекта.
/// </summary>
public bool IsCollected { get; private set; }
/// <summary>
/// В редакторе автоматически переводит коллайдер предмета в trigger.
/// </summary>
protected virtual void Reset()
{
if (TryGetComponent(out Collider2D collectibleCollider))
{
collectibleCollider.isTrigger = true;
}
}
/// <summary>
/// При переиспользовании prefab сбрасывает состояние подбора.
/// </summary>
protected virtual void OnEnable()
{
IsCollected = false;
}
/// <summary>
/// Реагирует на вход игрока в trigger-зону предмета.
/// </summary>
private void OnTriggerEnter2D(Collider2D other)
{
if (PlayerContactUtility.TryGetAlivePlayer(other, out var player))
{
HandlePlayerContact(player, this);
}
}
/// <summary>
/// Обрабатывает контакт через общий интерфейс игровых объектов.
/// </summary>
public void HandlePlayerContact(JumpPlayerController player, Component source)
{
Collect(player);
}
/// <summary>
/// Применяет эффект предмета и при необходимости выключает объект.
/// </summary>
public void Collect(JumpPlayerController player)
{
if (IsCollected || player == null || player.IsDead || player.IgnoresEnvironmentInteractions)
{
return;
}
IsCollected = true;
OnCollected(player);
if (disableOnCollected)
{
gameObject.SetActive(false);
}
}
/// <summary>
/// Точка расширения для конкретного эффекта collectible.
/// </summary>
protected virtual void OnCollected(JumpPlayerController player)
{
}
}
}