Первый коммит с LFS.
This commit is contained in:
1 parent
4fcb1e2f24
commit
179816dc4b
5084 files changed
+3714098
-1
No files matched your search
@@ -0,0 +1,75 @@
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Quest_Environment.Q3
|
||||
{
|
||||
public class WipeableSurface : MonoBehaviour, IInteractable
|
||||
{
|
||||
[Header("Settings")]
|
||||
public ItemData requiredRagItem;
|
||||
[SerializeField] private float wipeDuration = 1.0f;
|
||||
|
||||
[Header("Object References")]
|
||||
[Tooltip("The clean version of the surface to be activated.")]
|
||||
[SerializeField] private GameObject cleanSurfaceObject;
|
||||
[Tooltip("The dirty version of the surface to be deactivated.")]
|
||||
[SerializeField] private GameObject dirtySurfaceObject;
|
||||
|
||||
private bool isWiping = false;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
// Ensure the clean version is hidden at the start
|
||||
if (cleanSurfaceObject != null) cleanSurfaceObject.SetActive(false);
|
||||
}
|
||||
|
||||
public void Interact()
|
||||
{
|
||||
if (isWiping) return;
|
||||
|
||||
bool hasRag = InventorySystem.Instance.HasItem(requiredRagItem);
|
||||
|
||||
if (hasRag)
|
||||
{
|
||||
if (QuestManager.Instance != null && QuestManager.Instance.currentQuest is Q3_WipeSurfacesQuest)
|
||||
{
|
||||
StartCoroutine(WipeRoutine());
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log("This is dirty, but I have no reason to clean it right now.");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log("A rag is needed to clean this!");
|
||||
}
|
||||
}
|
||||
|
||||
private IEnumerator WipeRoutine()
|
||||
{
|
||||
isWiping = true;
|
||||
|
||||
PlayerHandsController.Instance?.PlayWipeAnimation();
|
||||
InteractionHandler.Instance.NotifyInteraction(gameObject);
|
||||
|
||||
// Wait for the animation to finish
|
||||
yield return new WaitForSeconds(wipeDuration);
|
||||
|
||||
if (dirtySurfaceObject != null) dirtySurfaceObject.SetActive(false);
|
||||
if (cleanSurfaceObject != null) cleanSurfaceObject.SetActive(true);
|
||||
|
||||
Debug.Log("Surface wiped clean!");
|
||||
|
||||
// We don't destroy the parent object, just disable this script
|
||||
// to prevent further interaction.
|
||||
this.enabled = false;
|
||||
}
|
||||
|
||||
public string GetDescription()
|
||||
{
|
||||
if (isWiping || !this.enabled) return "";
|
||||
return "Wipe surface";
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user