All checks were successful
Build project / Build for (StandaloneLinux64, 6000.0.37f1) (push) Successful in 6m11s
Build project / Build for (StandaloneWindows64, 6000.0.37f1) (push) Successful in 5m51s
Build project / Publish to itch.io (StandaloneLinux64) (push) Successful in 5s
Build project / Publish to itch.io (StandaloneWindows64) (push) Successful in 4s
90 lines
2.6 KiB
C#
90 lines
2.6 KiB
C#
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using TMPro;
|
|
|
|
public class OpenNextLevel : MonoBehaviour
|
|
{
|
|
public TMP_Text interactionPrompt;
|
|
private Outline outline;
|
|
|
|
[SerializeField] private Animator objectAnimator;
|
|
// [SerializeField] private string animationName = "PickupAnimation";
|
|
// [SerializeField] private AudioClip openSound;
|
|
|
|
[SerializeField] private string doorName = "Deck D";
|
|
|
|
[SerializeField] private KeyCardPlayer keyCardPlayer;
|
|
|
|
private bool isOpened = false;
|
|
|
|
|
|
void Awake()
|
|
{
|
|
outline = GetComponent<Outline>();
|
|
if (outline != null)
|
|
{
|
|
outline.enabled = true;
|
|
}
|
|
if (interactionPrompt != null)
|
|
{
|
|
interactionPrompt.enabled = false;
|
|
}
|
|
}
|
|
|
|
void Update()
|
|
{
|
|
if (!isOpened)
|
|
{
|
|
Ray ray = Camera.main.ScreenPointToRay(new Vector3(Screen.width / 2, Screen.height / 2, 0));
|
|
if (Physics.Raycast(ray, out RaycastHit hit, 10f))
|
|
{
|
|
if (hit.collider.gameObject == gameObject)
|
|
{
|
|
if (interactionPrompt != null)
|
|
{
|
|
interactionPrompt.text = "Use Key Card to open door to " + doorName;
|
|
interactionPrompt.enabled = true;
|
|
}
|
|
|
|
// get state of keycard from player
|
|
|
|
if (Input.GetMouseButtonDown(0) && keyCardPlayer.hasKeyCard)
|
|
{
|
|
isOpened = true;
|
|
if (outline != null)
|
|
{
|
|
outline.enabled = false;
|
|
}
|
|
if (interactionPrompt != null)
|
|
{
|
|
interactionPrompt.enabled = false;
|
|
}
|
|
// if (objectAnimator != null)
|
|
// {
|
|
// objectAnimator.Play(animationName, 0, 0.0f);
|
|
// }
|
|
// if (openSound != null)
|
|
// {
|
|
// SoundFXManager.instance.PlaySound(openSound, transform, 1.5f);
|
|
// }
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (interactionPrompt != null)
|
|
{
|
|
interactionPrompt.enabled = false;
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (interactionPrompt != null)
|
|
{
|
|
interactionPrompt.enabled = false;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|