using System.Collections;
using System.Collections.Generic;
using Unity.VisualScripting;
using UnityEngine;
using UnityEngine.SceneManagement;
public class Stamping : MonoBehaviour
{
public GameObject stampPrefab;
public Transform resumeTransform;
public static bool isStamped = false;
public ResumeManager resumeManager;
public bool greenStamp;
public bool redStamp;
[SerializeField]
private static GameObject currentStamp;
private void OnTriggerEnter(Collider other)
{
Vector3 hitPoint = other.ClosestPoint(transform.position);
if (other.CompareTag("Resume"))
{
if (resumeTransform != null)
{
ClearStamps();
SpawnStampImage(hitPoint, resumeTransform);
isStamped = true;
}
}
if (other.CompareTag("TutorialPlay"))
{
SceneManager.LoadScene("Tutorial Scene");
}
if (other.CompareTag("ScenePlay"))
{
SceneManager.LoadScene("SampleSceneHandInteraction");
}
}
// Removes any existing stamp before placing a new one
private void ClearStamps()
{
if (currentStamp != null)
{
Destroy(currentStamp);
}
}
// Spawns a stamp image at the resume's surface and sends events based on the type
private void SpawnStampImage(Vector3 worldPosition, Transform parentTransform)
{
worldPosition.y = parentTransform.position.y + 0.02f;
currentStamp = Instantiate(stampPrefab, worldPosition, Quaternion.identity);
if (stampPrefab.name == "approved")
{
StampCheck stampCheck = Events.StampCheck;
stampCheck.isCorrectlyStamped = true;
EventManager.Broadcast(stampCheck);
}
else if (stampPrefab.name == "denied")
{
StampCheck stampCheck = Events.StampCheck;
stampCheck.isCorrectlyStamped = false;
EventManager.Broadcast(stampCheck);
}
currentStamp.transform.SetParent(parentTransform);
currentStamp.transform.localRotation = Quaternion.Euler(90, 0, 0);
}
// Set the transform of the resume to be stamped
public void SetResumeTransform(Transform resumeTransform)
{
this.resumeTransform = resumeTransform;
}
}