Первый коммит с LFS.
This commit is contained in:
1 parent
4fcb1e2f24
commit
179816dc4b
5084 files changed
+3714098
-1
No files matched your search
@@ -0,0 +1,86 @@
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Quest_Environment.Q2
|
||||
{
|
||||
public class DirtSpot : MonoBehaviour, IInteractable
|
||||
{
|
||||
[Header("Settings")]
|
||||
public ItemData requiredBroomItem;
|
||||
[SerializeField] private float cleanDuration = 1.5f;
|
||||
|
||||
private bool isCleaning = false;
|
||||
private Renderer _renderer;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
_renderer = GetComponent<Renderer>();
|
||||
if (_renderer == null)
|
||||
{
|
||||
_renderer = GetComponentInChildren<Renderer>();
|
||||
}
|
||||
}
|
||||
|
||||
public void Interact()
|
||||
{
|
||||
if (isCleaning) return;
|
||||
|
||||
bool hasBroom = InventorySystem.Instance.HasItem(requiredBroomItem);
|
||||
|
||||
if (hasBroom)
|
||||
{
|
||||
if (QuestManager.Instance != null && QuestManager.Instance.currentQuest is Q2_SweepDirtQuest)
|
||||
{
|
||||
StartCoroutine(CleanRoutine());
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log("It's dirty here, but I have no reason to clean it right now.");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log("A broom is needed to clean this!");
|
||||
}
|
||||
}
|
||||
|
||||
private IEnumerator CleanRoutine()
|
||||
{
|
||||
isCleaning = true;
|
||||
|
||||
// --- TRIGGER ANIMATION ---
|
||||
PlayerHandsController.Instance?.PlaySweepAnimation();
|
||||
// -------------------------
|
||||
|
||||
InteractionHandler.Instance.NotifyInteraction(gameObject);
|
||||
|
||||
if (_renderer != null)
|
||||
{
|
||||
Material mat = _renderer.material;
|
||||
Color startColor = mat.color;
|
||||
float timer = 0f;
|
||||
|
||||
while (timer < cleanDuration)
|
||||
{
|
||||
timer += Time.deltaTime;
|
||||
float alpha = Mathf.Lerp(startColor.a, 0f, timer / cleanDuration);
|
||||
mat.color = new Color(startColor.r, startColor.g, startColor.b, alpha);
|
||||
yield return null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
yield return new WaitForSeconds(cleanDuration);
|
||||
}
|
||||
|
||||
Debug.Log("Dirt cleaned!");
|
||||
Destroy(gameObject);
|
||||
}
|
||||
|
||||
public string GetDescription()
|
||||
{
|
||||
if (isCleaning) return "";
|
||||
return "Sweep";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 684169532f6d4bb586538dd24ed55a1b
|
||||
timeCreated: 1764782543
|
||||
@@ -0,0 +1,41 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Quest_Environment.Q2
|
||||
{
|
||||
public class PickupBroomAction : MonoBehaviour, IInteractable
|
||||
{
|
||||
[Header("Settings")]
|
||||
public ItemData broomItemData;
|
||||
|
||||
public void Interact()
|
||||
{
|
||||
// Check if the current quest is the correct one for this item
|
||||
if (!(QuestManager.Instance?.currentQuest is Q2_SweepDirtQuest))
|
||||
{
|
||||
Debug.Log("I have no reason to pick this up right now.");
|
||||
return; // Do nothing if it's not the right quest
|
||||
}
|
||||
|
||||
bool added = InventorySystem.Instance.AddItem(broomItemData);
|
||||
|
||||
if (added)
|
||||
{
|
||||
if (InteractionHandler.Instance != null)
|
||||
{
|
||||
InteractionHandler.Instance.NotifyInteraction(gameObject);
|
||||
}
|
||||
Destroy(gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
public string GetDescription()
|
||||
{
|
||||
// Only show the description if the correct quest is active
|
||||
if (QuestManager.Instance?.currentQuest is Q2_SweepDirtQuest)
|
||||
{
|
||||
return "Take the broom";
|
||||
}
|
||||
return ""; // Return empty string to hide the prompt
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 89b798cd1bc445fe999ee96661e67ec0
|
||||
timeCreated: 1764782752
|
||||
@@ -0,0 +1,144 @@
|
||||
using UnityEngine;
|
||||
using Player;
|
||||
|
||||
namespace Quest_Environment.Q2
|
||||
{
|
||||
public class Q2_SweepDirtQuest : MonoBehaviour, IQuest
|
||||
{
|
||||
[Header("Quest Settings")]
|
||||
[SerializeField] private string questName = "Room Cleaning";
|
||||
[SerializeField] private int dirtPilesTotal = 5;
|
||||
[SerializeField] private ItemData broomItem;
|
||||
|
||||
[Header("Target Tags")]
|
||||
[SerializeField] private string broomGiverTag = "BroomLocation";
|
||||
[SerializeField] private string dirtTag = "Dirt";
|
||||
|
||||
[Header("Audio Settings")]
|
||||
[SerializeField] private AudioClip pickupBroomSound;
|
||||
[SerializeField] private AudioClip cleanDirtSound;
|
||||
|
||||
private PlayerController _playerController;
|
||||
|
||||
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();
|
||||
|
||||
_playerController = FindObjectOfType<PlayerController>();
|
||||
|
||||
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;
|
||||
_playerController?.PlayOneShotSound(pickupBroomSound);
|
||||
PlayerHandsController.Instance?.ShowBroom(true);
|
||||
UpdateQuestState();
|
||||
}
|
||||
break;
|
||||
|
||||
case Stage.SweepDirt:
|
||||
if (obj.CompareTag(dirtTag))
|
||||
{
|
||||
cleanedDirtCount++;
|
||||
_playerController?.PlayOneShotSound(cleanDirtSound);
|
||||
QuestManager.Instance.StepCompleted();
|
||||
|
||||
if (cleanedDirtCount >= dirtPilesTotal)
|
||||
{
|
||||
FinishQuest();
|
||||
}
|
||||
else
|
||||
{
|
||||
UpdateQuestState();
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateQuestState()
|
||||
{
|
||||
switch (currentStage)
|
||||
{
|
||||
case Stage.FindBroom:
|
||||
Description = "Find a broom.";
|
||||
break;
|
||||
case Stage.SweepDirt:
|
||||
Description = "Sweep the floors in the rooms.";
|
||||
break;
|
||||
case Stage.Completed:
|
||||
Description = "The floor is clean!";
|
||||
break;
|
||||
}
|
||||
OnQuestStepChanged?.Invoke(Description);
|
||||
}
|
||||
|
||||
private void FinishQuest()
|
||||
{
|
||||
currentStage = Stage.Completed;
|
||||
|
||||
// Hide the broom and remove it from inventory
|
||||
PlayerHandsController.Instance?.ShowBroom(false);
|
||||
if (broomItem != null)
|
||||
{
|
||||
InventorySystem.Instance.RemoveItem(broomItem);
|
||||
}
|
||||
|
||||
UpdateQuestState();
|
||||
QuestManager.Instance.CompleteQuest();
|
||||
}
|
||||
|
||||
public void AdvanceQuestStep() { }
|
||||
public void CompleteQuest()
|
||||
{
|
||||
if (InteractionHandler.Instance != null)
|
||||
{
|
||||
InteractionHandler.Instance.onObjectInteracted -= HandleInteraction;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0b4fa2d4dfc4b6c0fa009fa452a1b5d7
|
||||
Reference in new issue
Block a user