Первый коммит с LFS.

This commit is contained in:
vladislove committed 2026-01-11 17:04:23 +03:00
1 parent 4fcb1e2f24
commit 179816dc4b
5084 files changed
+3714098 -1

No files matched your search

@@ -0,0 +1,202 @@
using Player;
using UnityEngine;
namespace Quests
{
public class Q1CollectGarbageQuest : MonoBehaviour, IQuest
{
[Header("Quest Settings")]
[SerializeField] private string questName = "Clean Up The Area";
[SerializeField] private int trashItemsPerBag = 3;
[SerializeField] private int bagsToDisposeTotal = 2;
[SerializeField] private ItemData garbageBagItem;
[Header("Звуки Квеста")]
[SerializeField] private AudioClip pickupBagSound;
[SerializeField] private AudioClip collectTrashSound;
[SerializeField] private AudioClip disposeBagSound;
private PlayerController _playerController;
[Header("Target Tags")]
[SerializeField] private string bagGiverTag = "TrashBagBox";
[SerializeField] private string trashTag = "Trash";
[SerializeField] private string dumpsterTag = "Dumpster";
private enum Stage
{
NotStarted,
FindBag,
FillBag,
DisposeBag,
Completed
}
private Stage currentStage = Stage.NotStarted;
private int currentTrashInBag = 0;
private int disposedBagsCount = 0;
public string QuestName => questName;
public string Description { get; private set; }
public int CurrentStep => disposedBagsCount;
public int TotalSteps => bagsToDisposeTotal;
public bool IsCompleted => currentStage == Stage.Completed;
public event System.Action<string> OnQuestStepChanged;
public void StartQuest()
{
if (garbageBagItem == null)
{
Debug.LogError("[QUEST START CHECK] Reference to 'garbageBagItem' is NULL when the quest starts. Check the quest object's inspector on the scene!");
}
else
{
Debug.Log($"[QUEST START CHECK] Reference to 'garbageBagItem' is SET. Item: '{garbageBagItem.itemName}'.");
}
currentStage = Stage.FindBag;
disposedBagsCount = 0;
currentTrashInBag = 0;
PlayerHandsController.Instance?.HideHands();
if (InteractionHandler.Instance != null)
{
InteractionHandler.Instance.onObjectInteracted += HandleInteraction;
}
else
{
Debug.LogError("InteractionHandler not found! The quest will not work.");
}
_playerController = Object.FindFirstObjectByType<PlayerController>();
UpdateQuestState();
}
void OnDestroy()
{
if (InteractionHandler.Instance != null)
{
InteractionHandler.Instance.onObjectInteracted -= HandleInteraction;
}
}
private void HandleInteraction(GameObject obj)
{
if (currentStage == Stage.Completed || obj == null) return;
switch (currentStage)
{
case Stage.FindBag:
if (obj.CompareTag(bagGiverTag))
{
currentStage = Stage.FillBag;
currentTrashInBag = 0;
PlayerHandsController.Instance?.ShowBag(false);
_playerController?.PlayOneShotSound(pickupBagSound);
UpdateQuestState();
}
break;
case Stage.FillBag:
if (obj.CompareTag(trashTag))
{
currentTrashInBag++;
_playerController?.PlayOneShotSound(collectTrashSound);
if (currentTrashInBag >= trashItemsPerBag)
{
currentStage = Stage.DisposeBag;
PlayerHandsController.Instance?.ShowBag(true);
}
UpdateQuestState();
}
break;
case Stage.DisposeBag:
if (obj.CompareTag(dumpsterTag))
{
if (garbageBagItem != null)
{
InventorySystem.Instance.RemoveItem(garbageBagItem);
}
else
{
Debug.LogError("ItemData for the garbage bag is not specified in the quest!");
}
PlayerHandsController.Instance?.HideHands();
_playerController?.PlayOneShotSound(disposeBagSound);
disposedBagsCount++;
QuestManager.Instance.StepCompleted();
if (disposedBagsCount >= bagsToDisposeTotal)
{
FinishQuest();
}
else
{
currentStage = Stage.FindBag;
UpdateQuestState();
}
}
break;
}
}
private void UpdateQuestState()
{
switch (currentStage)
{
case Stage.FindBag:
Description = "Find a roll of trash bags.";
break;
case Stage.FillBag:
Description = $"Collect trash in the bag: {currentTrashInBag} / {trashItemsPerBag}";
break;
case Stage.DisposeBag:
Description = "Dispose of the full bag in the dumpster.";
break;
case Stage.Completed:
Description = "Clean-up complete!";
break;
}
OnQuestStepChanged?.Invoke(Description);
}
public void AdvanceQuestStep() { }
public bool IsBagFull()
{
if (currentStage == Stage.DisposeBag) return true;
if (currentStage == Stage.FillBag) return currentTrashInBag >= trashItemsPerBag;
return false;
}
private void FinishQuest()
{
currentStage = Stage.Completed;
UpdateQuestState();
QuestManager.Instance.CompleteQuest();
}
public void CompleteQuest()
{
PlayerHandsController.Instance?.HideHands();
if (InteractionHandler.Instance != null)
{
InteractionHandler.Instance.onObjectInteracted -= HandleInteraction;
}
if (!string.IsNullOrEmpty(bagGiverTag))
{
GameObject bagGiver = GameObject.FindGameObjectWithTag(bagGiverTag);
if (bagGiver != null)
{
Object.Destroy(bagGiver);
Debug.Log($"Quest '{QuestName}' completed. Bag source '{bagGiver.name}' destroyed.");
}
else
{
Debug.LogWarning($"Quest '{QuestName}' completed, but could not find the bag source with tag '{bagGiverTag}'.");
}
}
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: e0aed862f90a49d8bcd8e32dad4dcbfd
timeCreated: 1764499781
+138
View File
@@ -0,0 +1,138 @@
using UnityEngine;
namespace Quests
{
public class Q2SweepDirtQuest : MonoBehaviour, IQuest
{
[Header("Quest Settings")]
[SerializeField] private string questName = "Уборка помещений";
[SerializeField] private int dirtPilesTotal = 5;
[SerializeField] private ItemData broomItem;
[Header("Target Tags")]
[SerializeField] private string broomGiverTag = "BroomLocation"; // Тэг места, где стоит метла
[SerializeField] private string dirtTag = "Dirt"; // Тэг самой грязи
private enum Stage
{
NotStarted,
FindBroom,
SweepDirt,
Completed
}
private Stage currentStage = Stage.NotStarted;
private int cleanedDirtCount = 0;
public string QuestName => questName;
public string Description { get; private set; }
public int CurrentStep => cleanedDirtCount;
public int TotalSteps => dirtPilesTotal;
public bool IsCompleted => currentStage == Stage.Completed;
public event System.Action<string> OnQuestStepChanged;
public void StartQuest()
{
if (broomItem == null) Debug.LogError($"[Q2] Broom ItemData is missing!");
currentStage = Stage.FindBroom;
cleanedDirtCount = 0;
// Скрываем руки (убираем мусорный мешок из прошлого квеста)
PlayerHandsController.Instance?.HideHands();
if (InteractionHandler.Instance != null)
{
InteractionHandler.Instance.onObjectInteracted += HandleInteraction;
}
UpdateQuestState();
}
private void OnDestroy()
{
if (InteractionHandler.Instance != null)
{
InteractionHandler.Instance.onObjectInteracted -= HandleInteraction;
}
}
private void HandleInteraction(GameObject obj)
{
if (currentStage == Stage.Completed || obj == null) return;
switch (currentStage)
{
case Stage.FindBroom:
// Если игрок взаимодействовал с объектом метлы (поднял её)
if (obj.CompareTag(broomGiverTag))
{
currentStage = Stage.SweepDirt;
// Показываем визуальную метлу в руках
PlayerHandsController.Instance?.ShowBroom(true);
UpdateQuestState();
}
break;
case Stage.SweepDirt:
// Если игрок взаимодействовал с грязью
if (obj.CompareTag(dirtTag))
{
cleanedDirtCount++;
QuestManager.Instance.StepCompleted();
if (cleanedDirtCount >= dirtPilesTotal)
{
FinishQuest();
}
else
{
UpdateQuestState();
}
}
break;
}
}
private void UpdateQuestState()
{
switch (currentStage)
{
case Stage.FindBroom:
Description = "Найдите метлу.";
break;
case Stage.SweepDirt:
Description = $"Подметите пол в комнатах: {cleanedDirtCount} / {dirtPilesTotal}";
break;
case Stage.Completed:
Description = "Пол чист!";
break;
}
OnQuestStepChanged?.Invoke(Description);
}
private void FinishQuest()
{
currentStage = Stage.Completed;
// Прячем метлу по завершении
PlayerHandsController.Instance?.ShowBroom(false);
// Или PlayerHandsController.Instance?.HideHands();
UpdateQuestState();
QuestManager.Instance.CompleteQuest();
}
public void AdvanceQuestStep() { }
public void CompleteQuest()
{
if (InteractionHandler.Instance != null)
{
InteractionHandler.Instance.onObjectInteracted -= HandleInteraction;
}
InventorySystem.Instance.RemoveItem(broomItem);
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 040b72c86eb545eb9615b16ac561fcea
timeCreated: 1764782725